Skip to content

Commit 7425cd7

Browse files
Aman Aalammortondaniel
Aman Aalam
andauthored
RC 2.1.1 - Updated types for fees and taxes from primitive to Object to allow null values and fix serialization issues. (#49)
<!-- We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below. Please format the PR title appropriately based on the type of change: <type>[!]: <description> Where <type> is one of: docs, chore, feat, fix, test. Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature). **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.** Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! e.g. Fixes #1 Closes #2 --> # Fixes # Updated types for fees and taxes from primitive to Object to allow null values and fix serialization issues. closes #48 ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) - [ ] I have titled the PR appropriately - [ ] I have updated my branch with the main branch - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation about the functionality in the appropriate .md file - [ ] I have added inline documentation to the code I modified If you have questions, create a GitHub Issue in this repository. --------- Co-authored-by: Daniel Morton <[email protected]>
1 parent 0fdb6ff commit 7425cd7

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Add this dependency to your project's POM:
1212
<dependency>
1313
<groupId>com.trolley</groupId>
1414
<artifactId>java-sdk</artifactId>
15-
<version>2.0.1</version>
15+
<version>2.1.1</version>
1616
</dependency>
1717
```
1818

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.trolley</groupId>
55
<artifactId>java-sdk</artifactId>
6-
<version>2.0.1</version>
6+
<version>2.1.1</version>
77
<description>Java SDK for Trolley API</description>
88
<packaging>jar</packaging>
99
<name>Trolley Java SDK</name>

src/main/java/com/trolley/types/InvoiceLine.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ public class InvoiceLine
2727
private Amount paidAmount;
2828
private String externalId;
2929

30-
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
31-
private boolean taxReportable;
30+
private Boolean taxReportable;
3231

3332
private List<String> tags;
3433
private InvoiceCategories category;
3534

36-
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
37-
private boolean forceUsTaxActivity;
35+
private Boolean forceUsTaxActivity;
3836

3937
public static enum InvoiceCategories{
4038
SERVICES("services"),
@@ -89,8 +87,8 @@ public InvoiceLine(
8987
InvoiceCategories category,
9088
String description,
9189
String externalId,
92-
boolean taxReportable,
93-
boolean forceUsTaxActivity,
90+
Boolean taxReportable,
91+
Boolean forceUsTaxActivity,
9492
List<String> tags,
9593
String quantity,
9694
Amount discountAmount,
@@ -223,11 +221,11 @@ public void setExternalId(String externalId) {
223221
this.externalId = externalId;
224222
}
225223

226-
public boolean isTaxReportable() {
224+
public Boolean isTaxReportable() {
227225
return taxReportable;
228226
}
229227

230-
public void setTaxReportable(boolean taxReportable) {
228+
public void setTaxReportable(Boolean taxReportable) {
231229
this.taxReportable = taxReportable;
232230
}
233231

@@ -247,11 +245,11 @@ public void setCategory(InvoiceCategories category) {
247245
this.category = category;
248246
}
249247

250-
public boolean isForceUsTaxActivity() {
248+
public Boolean isForceUsTaxActivity() {
251249
return forceUsTaxActivity;
252250
}
253251

254-
public void setForceUsTaxActivity(boolean forceUsTaxActivity) {
252+
public void setForceUsTaxActivity(Boolean forceUsTaxActivity) {
255253
this.forceUsTaxActivity = forceUsTaxActivity;
256254
}
257255

src/main/java/com/trolley/types/supporting/InvoicePaymentPart.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package com.trolley.types.supporting;
22

3-
import java.util.ArrayList;
4-
53
public class InvoicePaymentPart{
64
private String invoiceId;
75
private String invoiceLineId;
86
private String paymentId;
97
private Amount amount;
108

119
//These fields are to hold values from parsed JSON, not for request body
12-
private boolean coverFees;
10+
private Boolean coverFees;
1311
private String memo;
1412
private String externalId;
1513
private String[] tags;
@@ -25,10 +23,10 @@ public InvoicePaymentPart(String invoiceId, String invoiceLineId, String payment
2523
}
2624

2725
/**
28-
* IMPORTANT: Use as request only while updating an InvoicePayment. For "Create Invoice Payment" request, use {@link InvoicePaymentRequest#InvoicePaymentRequest(String, boolean, String, String, String[], InvoicePaymentPart) InvoicePaymentRequest}.
26+
* IMPORTANT: Use as request only while updating an InvoicePayment. For "Create Invoice Payment" request, use {@link InvoicePaymentRequest#InvoicePaymentRequest(String, Boolean, String, String, String[], InvoicePaymentPart) InvoicePaymentRequest}.
2927
*/
3028
public InvoicePaymentPart(String invoiceId, String invoiceLineId, String paymentId, Amount amount,
31-
boolean coverFees, String memo, String externalId, String[] tags) {
29+
Boolean coverFees, String memo, String externalId, String[] tags) {
3230
this.invoiceId = invoiceId;
3331
this.invoiceLineId = invoiceLineId;
3432
this.paymentId = paymentId;
@@ -71,7 +69,7 @@ public void setAmount(Amount amount) {
7169
this.amount = amount;
7270
}
7371

74-
public boolean shouldCoverFees() {
72+
public Boolean shouldCoverFees() {
7573
return coverFees;
7674
}
7775

src/main/java/com/trolley/types/supporting/InvoicePaymentRequest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
public class InvoicePaymentRequest{
77
private String batchId;
8-
private boolean coverFees;
8+
private Boolean coverFees;
99
private String memo;
1010
private String externalId;
1111
private String[] tags;
@@ -17,13 +17,13 @@ public InvoicePaymentRequest() {
1717
/**
1818
* Constructor to create a new request when you have more than one Invoices or InvoiceLines to create payment for.
1919
* @param batchId ID of the batch you'd want to add this payment to. If it's {@code null} or {@code ""}, a new payment will be created.
20-
* @param coverFees Denotes whether you want to cover fees with this payment.
20+
* @param coverFees Denotes whether you want to cover fees with this payment. If it's {@code null} the parameter will be ignored.
2121
* @param memo A recipient viewable Memo that you'd want the created payment to have.
2222
* @param externalId A unique External ID that you'd want to assign to the created payment.
2323
* @param tags A {@code String[]} array where each element is a merchant-viewable tag that you want to assign to the created payment.
2424
* @param ids An {@code InvoicePaymentPart[]} array representing InvoicePaymentPart objects containing IDs and Amounts of Invoices and InvoiceLines you want to create payments for.
2525
*/
26-
public InvoicePaymentRequest(String batchId, boolean coverFees, String memo, String externalId,
26+
public InvoicePaymentRequest(String batchId, Boolean coverFees, String memo, String externalId,
2727
String[] tags, InvoicePaymentPart[] ids) {
2828
this.batchId = batchId;
2929
this.coverFees = coverFees;
@@ -36,13 +36,13 @@ public InvoicePaymentRequest(String batchId, boolean coverFees, String memo, Str
3636
/**
3737
* Constructor to create a new request when you have only one Invoice/InvoiceLine to create a payment for.
3838
* @param batchId ID of the batch you'd want to add this payment to. If it's {@code null} or {@code ""}, a new payment will be created.
39-
* @param coverFees Denotes whether you want to cover fees with this payment.
39+
* @param coverFees Denotes whether you want to cover fees with this payment. If it's {@code null} the parameter will be ignored.
4040
* @param memo A recipient viewable Memo that you'd want the created payment to have.
4141
* @param externalId A unique External ID that you'd want to assign to the created payment.
4242
* @param tags A {@code String[]} array where each element is a merchant-viewable tag that you want to assign to the created payment.
4343
* @param paymentPart An {@code InvoicePaymentPart[]} array representing InvoicePaymentPart objects containing IDs and Amounts of Invoices and InvoiceLines you want to create payments for.
4444
*/
45-
public InvoicePaymentRequest(String batchId, boolean coverFees, String memo, String externalId,
45+
public InvoicePaymentRequest(String batchId, Boolean coverFees, String memo, String externalId,
4646
String[] tags, InvoicePaymentPart paymentPart) {
4747
this.batchId = batchId;
4848
this.coverFees = coverFees;
@@ -60,11 +60,11 @@ public void setBatchId(String batchId) {
6060
this.batchId = batchId;
6161
}
6262

63-
public boolean shouldCoverFees() {
63+
public Boolean shouldCoverFees() {
6464
return coverFees;
6565
}
6666

67-
public void setCoverFees(boolean coverFees) {
67+
public void setCoverFees(Boolean coverFees) {
6868
this.coverFees = coverFees;
6969
}
7070

src/test/java/com/trolley/integration/InvoiceTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public void testInvoices() throws Exception {
4444

4545
InvoiceLine invoiceLine = new InvoiceLine();
4646
invoiceLine.setUnitAmount(new Amount("100", "USD"));
47+
invoiceLine.setForceUsTaxActivity(false);
48+
invoiceLine.setTaxReportable(false);
4749

4850
ArrayList<InvoiceLine> invoiceLines = new ArrayList<InvoiceLine>(){
4951
{
@@ -261,7 +263,7 @@ public void testInvoicePayments() throws Exception {
261263

262264
InvoicePaymentRequest invoicePaymentRequest = new InvoicePaymentRequest(
263265
null,
264-
false,
266+
null,
265267
"Integration Test Payment",
266268
"ext-id-"+System.currentTimeMillis(),
267269
tags,
@@ -278,7 +280,7 @@ public void testInvoicePayments() throws Exception {
278280
paymentPart.setPaymentId(invoicePayment.getPaymentId());
279281
paymentPart.setAmount(new Amount("10","USD"));
280282
paymentPart.setExternalId("ext-id-"+System.currentTimeMillis());
281-
paymentPart.setCoverFees(true);
283+
paymentPart.setCoverFees(false);
282284

283285
boolean paymentUpdateResult = client.invoicePayment.update(paymentPart);
284286
assertTrue(paymentUpdateResult);

0 commit comments

Comments
 (0)