I want to generate an xml base invoice using the the Java lib from Mustangproject. I use the profile "XRechnung". It works fine. But there are rounding inconsitencies: The mustanglib calculates VAT and sums itself.
Now the problem is: We have a price including VAT, for example 120€. We calculate 7,85 as VAT. When we have a large quantity, for example 250, we get the problem: We like to have exactly 7,85 * 250 as VAT, and exactly 120 * 250 as total sum. But we get some cents more in the output: GrandTotal in xml is 30000.13 :-( and VAT is 1.962,62.
It looks like it sums up the price without VAT, and then calculates the price with VAT again.
So I tried to set the sum value it explicitly by using CalculatedInvoice. I tried:
void fillSums(CalculatedInvoice xInvoice, InputData invoiceData) {
xInvoice.calculate();
xInvoice.setLineTotalAmount(euroPriceOfCents(invoiceData.getInvoiceTotal()));
xInvoice.setGrandTotal(euroPriceOfCents(invoiceData.getInvoiceTotal()));
xInvoice.setTaxBasis(euroPriceOfCents(invoiceData.getInvoiceTaxValue()));
xInvoice.setDuePayable(euroPriceOfCents(invoiceData.getInvoiceTotal());
}
I see in the debugger the code is executed, but nevertheless the xml shows the wrong results.