Skip to content

Commit

Permalink
Fixed the mapping of the Due Date Type Code for BT-8; #29
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed May 8, 2024
1 parent f06b0ad commit 2094b87
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ CII to UBL Converter for EN 16931 invoices

* v2.2.3 - work in progress
* Added additional mapping of BT-41. See [issue #28](https://github.com/phax/en16931-cii2ubl/issues/28) - thx @bdewein
* Fixed the mapping of the Due Date Type Code for BT-8. See [issue #29](https://github.com/phax/en16931-cii2ubl/issues/29) - thx @bdewein
* v2.2.2 - 2024-04-12
* Added support for providing the default UBL order reference ID, in case the empty String is not good enough. See [issue #23](https://github.com/phax/en16931-cii2ubl/issues/23) - thx @lkumai
* v2.2.1 - 2024-03-29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,19 @@ protected static boolean isValidDocumentReferenceTypeCode (@Nullable final Strin
return isOriginatorDocumentReferenceTypeCode (s) || "130".equals (s);
}

@Nullable
protected static String mapDueDateTypeCode (@Nullable final String s)
{
// BT-8 mapping; see #29
if ("5".equals (s))
return "3";
if ("29".equals (s))
return "35";
if ("72".equals (s))
return "432";
return s;
}

protected static boolean isLT0Strict (@Nullable final BigDecimal aBD)
{
return aBD != null && MathHelper.isLT0 (aBD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ public InvoiceType convertToInvoice (@Nonnull final CrossIndustryInvoiceType aCI
{
final TradeTaxType aTradeTax = aHeaderSettlement.getApplicableTradeTaxAtIndex (0);
if (StringHelper.hasText (aTradeTax.getDueDateTypeCodeValue ()))
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (aTradeTax.getDueDateTypeCodeValue ()));
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (mapDueDateTypeCode (aTradeTax.getDueDateTypeCodeValue ())));
}

if (aUBLPeriod.getStartDate () != null ||
Expand Down Expand Up @@ -1567,7 +1567,7 @@ public CreditNoteType convertToCreditNote (@Nonnull final CrossIndustryInvoiceTy
{
final TradeTaxType aTradeTax = aHeaderSettlement.getApplicableTradeTaxAtIndex (0);
if (StringHelper.hasText (aTradeTax.getDueDateTypeCodeValue ()))
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (aTradeTax.getDueDateTypeCodeValue ()));
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (mapDueDateTypeCode (aTradeTax.getDueDateTypeCodeValue ())));
}

if (aUBLPeriod.getStartDate () != null ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ public InvoiceType convertToInvoice (@Nonnull final CrossIndustryInvoiceType aCI
{
final TradeTaxType aTradeTax = aHeaderSettlement.getApplicableTradeTaxAtIndex (0);
if (StringHelper.hasText (aTradeTax.getDueDateTypeCodeValue ()))
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (aTradeTax.getDueDateTypeCodeValue ()));
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (mapDueDateTypeCode (aTradeTax.getDueDateTypeCodeValue ())));
}

if (aUBLPeriod.getStartDate () != null ||
Expand Down Expand Up @@ -1563,7 +1563,7 @@ public CreditNoteType convertToCreditNote (@Nonnull final CrossIndustryInvoiceTy
{
final TradeTaxType aTradeTax = aHeaderSettlement.getApplicableTradeTaxAtIndex (0);
if (StringHelper.hasText (aTradeTax.getDueDateTypeCodeValue ()))
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (aTradeTax.getDueDateTypeCodeValue ()));
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (mapDueDateTypeCode (aTradeTax.getDueDateTypeCodeValue ())));
}

if (aUBLPeriod.getStartDate () != null ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ public InvoiceType convertToInvoice (@Nonnull final CrossIndustryInvoiceType aCI
{
final TradeTaxType aTradeTax = aHeaderSettlement.getApplicableTradeTaxAtIndex (0);
if (StringHelper.hasText (aTradeTax.getDueDateTypeCodeValue ()))
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (aTradeTax.getDueDateTypeCodeValue ()));
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (mapDueDateTypeCode (aTradeTax.getDueDateTypeCodeValue ())));
}

if (aUBLPeriod.getStartDate () != null ||
Expand Down Expand Up @@ -1565,7 +1565,7 @@ public CreditNoteType convertToCreditNote (@Nonnull final CrossIndustryInvoiceTy
{
final TradeTaxType aTradeTax = aHeaderSettlement.getApplicableTradeTaxAtIndex (0);
if (StringHelper.hasText (aTradeTax.getDueDateTypeCodeValue ()))
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (aTradeTax.getDueDateTypeCodeValue ()));
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (mapDueDateTypeCode (aTradeTax.getDueDateTypeCodeValue ())));
}

if (aUBLPeriod.getStartDate () != null ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ public InvoiceType convertToInvoice (@Nonnull final CrossIndustryInvoiceType aCI
{
final TradeTaxType aTradeTax = aHeaderSettlement.getApplicableTradeTaxAtIndex (0);
if (StringHelper.hasText (aTradeTax.getDueDateTypeCodeValue ()))
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (aTradeTax.getDueDateTypeCodeValue ()));
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (mapDueDateTypeCode (aTradeTax.getDueDateTypeCodeValue ())));
}

if (aUBLPeriod.getStartDate () != null ||
Expand Down Expand Up @@ -1565,7 +1565,7 @@ public CreditNoteType convertToCreditNote (@Nonnull final CrossIndustryInvoiceTy
{
final TradeTaxType aTradeTax = aHeaderSettlement.getApplicableTradeTaxAtIndex (0);
if (StringHelper.hasText (aTradeTax.getDueDateTypeCodeValue ()))
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (aTradeTax.getDueDateTypeCodeValue ()));
aUBLPeriod.addDescriptionCode (new DescriptionCodeType (mapDueDateTypeCode (aTradeTax.getDueDateTypeCodeValue ())));
}

if (aUBLPeriod.getStartDate () != null ||
Expand Down

0 comments on commit 2094b87

Please sign in to comment.