Skip to content

Commit 337d2e5

Browse files
committed
fix: model property tax accounts as arrays
1 parent 8119a34 commit 337d2e5

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/main/java/io/facturapi/models/InvoiceItem.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public class InvoiceItem {
1414
private InvoiceItemThirdParty thirdParty;
1515
private String complement;
1616
private List<InvoiceItemPart> parts = new ArrayList<>();
17-
private String propertyTaxAccount;
17+
@JsonProperty("property_tax_account")
18+
private List<String> propertyTaxAccounts = new ArrayList<>();
1819

1920
public Double getQuantity() { return quantity; }
2021
public void setQuantity(Double quantity) { this.quantity = quantity; }
@@ -30,6 +31,8 @@ public class InvoiceItem {
3031
public void setComplement(String complement) { this.complement = complement; }
3132
public List<InvoiceItemPart> getParts() { return parts; }
3233
public void setParts(List<InvoiceItemPart> parts) { this.parts = parts; }
33-
public String getPropertyTaxAccount() { return propertyTaxAccount; }
34-
public void setPropertyTaxAccount(String propertyTaxAccount) { this.propertyTaxAccount = propertyTaxAccount; }
34+
@JsonProperty("property_tax_account")
35+
public List<String> getPropertyTaxAccounts() { return propertyTaxAccounts; }
36+
@JsonProperty("property_tax_account")
37+
public void setPropertyTaxAccounts(List<String> propertyTaxAccounts) { this.propertyTaxAccounts = propertyTaxAccounts; }
3538
}

src/test/java/io/facturapi/FacturapiResourcesTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
import io.facturapi.enums.Taxability;
1717
import io.facturapi.http.FacturapiConfig;
1818
import io.facturapi.models.Customer;
19+
import io.facturapi.models.InvoiceItem;
1920
import java.io.InputStream;
2021
import java.nio.charset.StandardCharsets;
2122
import java.time.Instant;
2223
import java.time.LocalDate;
24+
import java.util.List;
2325
import java.util.Map;
2426
import org.junit.jupiter.api.Test;
2527

@@ -320,4 +322,18 @@ void objectMapperDeserializesCodeEnums() throws Exception {
320322
assertEquals(TaxType.IEPS, tax.getType());
321323
assertEquals(TaxFactor.EXENTO, tax.getFactor());
322324
}
325+
326+
@Test
327+
void objectMapperDeserializesPropertyTaxAccountsAsArrays() throws Exception {
328+
var mapper = FacturapiConfig.builder("sk_test").build().getObjectMapper();
329+
330+
var empty = mapper.readValue("{\"property_tax_account\":[]}", InvoiceItem.class);
331+
var accounts = mapper.readValue(
332+
"{\"property_tax_account\":[\"0102030405\"]}",
333+
InvoiceItem.class
334+
);
335+
336+
assertEquals(List.of(), empty.getPropertyTaxAccounts());
337+
assertEquals(List.of("0102030405"), accounts.getPropertyTaxAccounts());
338+
}
323339
}

0 commit comments

Comments
 (0)