Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BR-CO-16 triggered on UBL for 1.3.3 #242

Closed
phax opened this issue Oct 5, 2020 · 14 comments
Closed

BR-CO-16 triggered on UBL for 1.3.3 #242

phax opened this issue Oct 5, 2020 · 14 comments
Assignees

Comments

@phax
Copy link
Collaborator

phax commented Oct 5, 2020

Hi guys,
since the latest 1.3.3 update, the following UBL block is invalid:

 <cac:LegalMonetaryTotal>
    <cbc:LineExtensionAmount currencyID="EUR">10781.25</cbc:LineExtensionAmount>
      <cbc:TaxExclusiveAmount currencyID="EUR">10781.25</cbc:TaxExclusiveAmount>
      <cbc:TaxInclusiveAmount currencyID="EUR">12829.69</cbc:TaxInclusiveAmount>
      <cbc:AllowanceTotalAmount currencyID="EUR">0</cbc:AllowanceTotalAmount>
      <cbc:ChargeTotalAmount currencyID="EUR">0</cbc:ChargeTotalAmount>
      <cbc:PrepaidAmount currencyID="EUR">12829.69</cbc:PrepaidAmount>
      <cbc:PayableRoundingAmount currencyID="EUR">0</cbc:PayableRoundingAmount>
      <cbc:PayableAmount currencyID="EUR">0</cbc:PayableAmount>
  </cac:LegalMonetaryTotal>

I think the calculation model would now require TaxInclusiveAmount to be 0???

[BR-CO-16]-Amount due for payment (BT-115) = Invoice total amount with VAT (BT-112) -Paid amount (BT-113) +Rounding amount (BT-114).]]; 

(exists(cbc:PrepaidAmount) and not(exists(cbc:PayableRoundingAmount)) and (xs:decimal(cbc:PayableAmount) = (round((xs:decimal(cbc:TaxInclusiveAmount) - xs:decimal(cbc:PrepaidAmount)) * 10 * 10) div 100))) or (not(xs:decimal(cbc:PrepaidAmount)) and not(xs:decimal(cbc:PayableRoundingAmount)) and xs:decimal(cbc:PayableAmount) = xs:decimal(cbc:TaxInclusiveAmount)) or (xs:decimal(cbc:PrepaidAmount) and xs:decimal(cbc:PayableRoundingAmount) and ((round((xs:decimal(cbc:PayableAmount) - xs:decimal(cbc:PayableRoundingAmount)) * 10 * 10) div 100) = (round((xs:decimal(cbc:TaxInclusiveAmount) - xs:decimal(cbc:PrepaidAmount)) * 10 * 10) div 100))) or (not(xs:decimal(cbc:PrepaidAmount)) and xs:decimal(cbc:PayableRoundingAmount) and ((round((xs:decimal(cbc:PayableAmount) - xs:decimal(cbc:PayableRoundingAmount)) * 10 * 10) div 100) = xs:decimal(cbc:TaxInclusiveAmount)))
@oriol
Copy link
Collaborator

oriol commented Oct 6, 2020

No, the problem is the expression. Should be

(exists(cbc:PrepaidAmount) and not(exists(cbc:PayableRoundingAmount)) and (xs:decimal(cbc:PayableAmount) = (round((xs:decimal(cbc:TaxInclusiveAmount) - xs:decimal(cbc:PrepaidAmount)) * 10 * 10) div 100))) or (not(exists(xs:decimal(cbc:PrepaidAmount))) and not(exists(xs:decimal(cbc:PayableRoundingAmount))) and xs:decimal(cbc:PayableAmount) = xs:decimal(cbc:TaxInclusiveAmount)) or (exists(xs:decimal(cbc:PrepaidAmount)) and exists(xs:decimal(cbc:PayableRoundingAmount)) and ((round((xs:decimal(cbc:PayableAmount) - xs:decimal(cbc:PayableRoundingAmount)) * 10 * 10) div 100) = (round((xs:decimal(cbc:TaxInclusiveAmount) - xs:decimal(cbc:PrepaidAmount)) * 10 * 10) div 100))) or (not(exists(xs:decimal(cbc:PrepaidAmount))) and exists(xs:decimal(cbc:PayableRoundingAmount)) and ((round((xs:decimal(cbc:PayableAmount) - xs:decimal(cbc:PayableRoundingAmount)) * 10 * 10) div 100) = xs:decimal(cbc:TaxInclusiveAmount)))

@phax
Copy link
Collaborator Author

phax commented Oct 6, 2020

Okay thanks. Meaning there will be a 1.3.4 release soon?

@oriol
Copy link
Collaborator

oriol commented Oct 6, 2020

spring 2021 release

@phax
Copy link
Collaborator Author

phax commented Oct 6, 2020

Ah okay. That renders the 1.3.3 release quite useless if such a showstopper bug is in it. Can you eventually consider releasing a 1.3.3.1 bugfix release?

@oriol
Copy link
Collaborator

oriol commented Oct 6, 2020

This is an old bug. The error has not been noticed because it only appears when there is a PayableRoundingAmount with value 0.

I would then suggest waiting to the next release to fix the bug.

@phax
Copy link
Collaborator Author

phax commented Oct 6, 2020

The issue poped up when converting CII documents to UBL and that was not changed.
The output validated with 1.3.2 validation artefacts but fails with 1.3.3 - so something in this regard was changed.

@phax
Copy link
Collaborator Author

phax commented Oct 19, 2020

The problem was caused by commit d925641 which was meant to resolve #222

@phax
Copy link
Collaborator Author

phax commented Oct 19, 2020

I guess your proposal can be simplified to:

(exists(cbc:PrepaidAmount) and not(exists(cbc:PayableRoundingAmount)) and (xs:decimal(cbc:PayableAmount) = (round((xs:decimal(cbc:TaxInclusiveAmount) - xs:decimal(cbc:PrepaidAmount)) * 10 * 10) div 100))) or 
(not(exists(cbc:PrepaidAmount)) and not(exists(cbc:PayableRoundingAmount)) and xs:decimal(cbc:PayableAmount) = xs:decimal(cbc:TaxInclusiveAmount)) or 
(exists(cbc:PrepaidAmount) and exists(cbc:PayableRoundingAmount) and ((round((xs:decimal(cbc:PayableAmount) - xs:decimal(cbc:PayableRoundingAmount)) * 10 * 10) div 100) = (round((xs:decimal(cbc:TaxInclusiveAmount) - xs:decimal(cbc:PrepaidAmount)) * 10 * 10) div 100))) or 
(not(exists(cbc:PrepaidAmount)) and exists(cbc:PayableRoundingAmount) and ((round((xs:decimal(cbc:PayableAmount) - xs:decimal(cbc:PayableRoundingAmount)) * 10 * 10) div 100) = xs:decimal(cbc:TaxInclusiveAmount)))

oriol added a commit that referenced this issue Oct 20, 2020
@phax
Copy link
Collaborator Author

phax commented Oct 20, 2020

Not emitting PayableRoundingAmount if the value is 0 is a suitable work around

@oriol
Copy link
Collaborator

oriol commented Oct 20, 2020

Ok @phax, I have added a test on this and will fix it for the next release.

@juskoljo
Copy link

Should this introduced bug be communicated somehow? At least mentioned in "News and noteworthy" section ✌️

juskoljo referenced this issue in OpenPEPPOL/peppol-bis-invoice-3 Nov 11, 2020
@oriol
Copy link
Collaborator

oriol commented Nov 12, 2020

Should this introduced bug be communicated somehow? At least mentioned in "News and noteworthy" section ✌️

Added a Note in the Release explaining the error.

@senikk
Copy link

senikk commented Dec 9, 2020

@oriol where is this note added? Can't see it commited to README.

@phax
Copy link
Collaborator Author

phax commented Dec 9, 2020

It is referenced at https://github.com/ConnectingEurope/eInvoicing-EN16931/releases/tag/validation-1.3.3

oriol added a commit that referenced this issue Jan 20, 2021
@oriol oriol closed this as completed Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants