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

Invoice rounding problem #31

Closed
andras-minicrm opened this issue Nov 3, 2022 · 5 comments
Closed

Invoice rounding problem #31

andras-minicrm opened this issue Nov 3, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@andras-minicrm
Copy link

Hi!

It seems there is rounding problem with the xml generator:
[BR-CO-15]-Invoice total amount with VAT (BT-112) = Invoice total amount without VAT (BT-109) + Invoice total VAT amount (BT-110).

example data input:

$line = new InvoiceLine();
$line->setPrice(0.25)
    ->setQuantity(26935.78)
    ->setVatRate(19)

Which generates this nodes:

<cac:TaxTotal>
<cbc:TaxableAmount currencyID="RON">6733.95</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="RON">1279.45</cbc:TaxAmount>
...
<cac:LegalMonetaryTotal>
    <cbc:LineExtensionAmount currencyID="RON">6733.95</cbc:LineExtensionAmount>
    <cbc:TaxExclusiveAmount currencyID="RON">6733.95</cbc:TaxExclusiveAmount>
    <cbc:TaxInclusiveAmount currencyID="RON">8013.39</cbc:TaxInclusiveAmount>
    <cbc:PayableAmount currencyID="RON">8013.39</cbc:PayableAmount>
</cac:LegalMonetaryTotal>

The final amounts should be 8013.40, not 8013.39

And here is the generated xml:
factura-102-o2u-2022-e-ron-00066.txt

@quamis
Copy link

quamis commented Nov 14, 2022

@andras-minicrm 6733,945×1,19=8013,39455. Rounding this will lead to 8013,39. How did you determine it should be 8013.40?

@andras-minicrm
Copy link
Author

@quamis

Yea, you are probably right, based on the error message 6733.95 + 1279.45 = (8013.40) should be equal cbc:TaxInclusiveAmount (8013.39) . Probably the TaxAmount should be 1279.44 to get the correct 8013.39 value.

@josemmo
Copy link
Owner

josemmo commented Nov 22, 2022

Hello @andras-minicrm,

Hmm, given BR-CO-15 is a Business Rule from the EN 16931, I'm guessing the final roundings performed by this library need to be updated to comply with the standard.

I'll investigate further and prepare a new implementation as soon as I have some spare time.

@josemmo josemmo added the bug Something isn't working label Nov 22, 2022
@josemmo josemmo self-assigned this Nov 22, 2022
josemmo added a commit that referenced this issue Dec 4, 2022
- Updated InvoiceTotalsTest class
- Added "peppol-rounding.xml" integration test sample

> Related to #31
@josemmo
Copy link
Owner

josemmo commented Dec 4, 2022

Hello @andras-minicrm,

This should be fixed now. Give it a try to make sure it works:

composer require josemmo/einvoicing:dev-develop

@andras-minicrm
Copy link
Author

Hello @josemmo,

It seems the fix works, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants