Skip to content

Commit

Permalink
Merge pull request #164 from avadev/jwenger/162
Browse files Browse the repository at this point in the history
Jwenger/162
  • Loading branch information
svc-developer authored Jul 9, 2024
2 parents 3bb10c1 + 2e1fb78 commit e5fae73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/main/java/net/avalara/avatax/rest/client/AvaTaxPath.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.avalara.avatax.rest.client;

import java.util.HashMap;
import java.text.SimpleDateFormat;
import java.util.Date;

public class AvaTaxPath {
private String path;
Expand All @@ -15,7 +17,13 @@ public void applyField(String fieldName, Object value) {
if (fieldName.startsWith("$")) {
addQuery(fieldName, value);
} else {
this.path = path.replace("{" + fieldName + "}", value.toString());
if (value instanceof Date) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String formattedDate = dateFormat.format((Date) value);
this.path = path.replace("{" + fieldName + "}", formattedDate);
} else {
this.path = path.replace("{" + fieldName + "}", value.toString());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,22 +271,26 @@ public TransactionBuilder withLine(String lineNo, BigDecimal amount, BigDecimal
}

public TransactionBuilder withLine(BigDecimal amount, BigDecimal quantity, String taxCode, String itemCode, String description) {
return withLine(null, amount, quantity, taxCode, itemCode, description, null, null, null, null);
return withLine(null, amount, quantity, taxCode, itemCode, description, null, null, null, null, null);
}

public TransactionBuilder withLine(String lineNo, BigDecimal amount, BigDecimal quantity, String taxCode, String itemCode, String description, String ref1, String ref2) {
return withLine(lineNo, amount, quantity, taxCode, itemCode, description, ref1, ref2, null, null);
return withLine(lineNo, amount, quantity, taxCode, itemCode, description, ref1, ref2, null, null, null);
}

public TransactionBuilder withLine(BigDecimal amount, BigDecimal quantity, String taxCode, String itemCode, String description, String ref1, String ref2) {
return withLine(amount, quantity, taxCode, itemCode, description, ref1, ref2, null);
}

public TransactionBuilder withLine(BigDecimal amount, BigDecimal quantity, String taxCode, String itemCode, String description, String ref1, String ref2, String customerUsageType) {
return withLine(null, amount, quantity, taxCode, itemCode, description, ref1, ref2, customerUsageType, null);
return withLine(null, amount, quantity, taxCode, itemCode, description, ref1, ref2, customerUsageType, null, null);
}

public TransactionBuilder withLine(String lineNo, BigDecimal amount, BigDecimal quantity, String taxCode, String itemCode, String description, String ref1, String ref2, String customerUsageType, String hsCode) {
public TransactionBuilder withLine(BigDecimal amount, BigDecimal quantity, String taxCode, String itemCode, String description, String ref1, String ref2, String customerUsageType, String category) {
return withLine(null, amount, quantity, taxCode, itemCode, description, ref1, ref2, customerUsageType, null, category);
}

public TransactionBuilder withLine(String lineNo, BigDecimal amount, BigDecimal quantity, String taxCode, String itemCode, String description, String ref1, String ref2, String customerUsageType, String hsCode, String category) {
if (quantity == null) {
quantity = BigDecimal.ONE;
}
Expand All @@ -311,6 +315,10 @@ public TransactionBuilder withLine(String lineNo, BigDecimal amount, BigDecimal
line.setItemCode(itemCode);
}

if (category != null && !category.isEmpty()) {
line.setCategory(category);
}

if (description != null && !description.isEmpty()) {
line.setDescription(description);
}
Expand Down

0 comments on commit e5fae73

Please sign in to comment.