ZUGFeRD / mustangproject

Open Source Java e-Invoicing library, validator and tool (Factur-X/ZUGFeRD, UNCEFACT/CII XRechnung)
http://www.mustangproject.org
Apache License 2.0
168 stars 99 forks source link

Where can I find the invoice totals lines? #374

Closed paulsen-it closed 2 months ago

paulsen-it commented 2 months ago

When I use the ZUGFeRDInvoiceImporter, I get the invoice object. Unfortunately, I cannot find the totals lines with the VAT information there. Where can I find this out? I can of course run through the items and create the totals line myself, but the XML already contains this information and it is also accessed in Zugferd_1p0_c1p0_s1p0.xslt:

<tbody>
    <xsl:for-each select="rsm:SpecifiedSupplyChainTradeTransaction">
        <xsl:for-each select="ram:ApplicableSupplyChainTradeSettlement">
            <xsl:for-each select="ram:ApplicableTradeTax">

But I cannot find this value in the Invoice object. It would be an advantage to be able to read the value directly. This would prevent possible rounding differences.

jstaerk commented 2 months ago

As mentioned on https://www.mustangproject.org/invoice-class/?lang=de#reading in the last line, you can use

TransactionCalculator tc=new TransactionCalculator(invoice);
assertEquals(new BigDecimal("571.04"),tc.getTotalGross());

In the reader that's left out on purpose because as you mention, it's redundant. And as regards differences: There may be none. If the file validates then at least the line total/tax/grand total amounts comply to the calculation rules as defined in EN16931-2 (available free of charge, even before Malamud, thanks to Stefan Engel-Flechsig :-) )

paulsen-it commented 2 months ago

But I can't really use the TransactionCalculator like this. It only returns the total amount. But I need the VAT values. There can be several invoice lines in an invoice. For example, the total of all products with 7% VAT and the total of all products with 19% VAT.

The TransactionCalculator only returns the total of all values, and that without VAT. I also have invoices here that only show the net price and the quantity. grossPrice is null. Rounding differences will definitely occur here.

paulsen-it commented 2 months ago

I have a rounding difference in the very first calculation. In my opinion, it would make sense to interpret the totals line provided by the creator.

Article 1: Quantity 1, unit price 1079.64 Article 2: Quantity 3, unit price 288.00 Article 3: Quantity 3, unit price 70.00

VAT 19%

Total for me: 2562.84 Total in the totals line from the creator: 2,562.83