Unify the values of taxes

Concerning ApplicableHeaderTradeSettlement:
The amount in ApplicableTradeTax.CalculatedAmount is different from SpecifiedTradeSettlementHeaderMonetarySummation.TaxTotalAmount. To avoid this I removed the rounding from totalAmount.
This commit is contained in:
Sebastian Sieber
2020-11-25 12:34:15 +01:00
parent 1e78866040
commit a1c4f4a2d6
3 changed files with 7 additions and 5 deletions

View File

@@ -31,7 +31,7 @@ public class TransactionCalculator implements IAbsoluteValueProvider {
VATAmount amount = VATPercentAmountMap.get(currentTaxPercent); VATAmount amount = VATPercentAmountMap.get(currentTaxPercent);
res = res.add(amount.getCalculated()); res = res.add(amount.getCalculated());
} }
return res.setScale(2, RoundingMode.HALF_UP); return res;
} }
/*** /***

View File

@@ -6,6 +6,7 @@ import org.w3c.dom.NodeList;
import javax.xml.xpath.*; import javax.xml.xpath.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@@ -259,7 +260,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
} }
TransactionCalculator tc = new TransactionCalculator(zpp); TransactionCalculator tc = new TransactionCalculator(zpp);
String expectedStringTotalGross = tc.getTotalGross().toPlainString(); String expectedStringTotalGross = tc.getTotalGross().setScale(2, RoundingMode.HALF_UP).toPlainString();
if (!expectedStringTotalGross.equals(XMLTools.nDigitFormat(expectedGrandTotal, 2))) { if (!expectedStringTotalGross.equals(XMLTools.nDigitFormat(expectedGrandTotal, 2))) {
throw new ParseException("Could not reproduce the invoice, this could mean that it could not be read properly", 0); throw new ParseException("Could not reproduce the invoice, this could mean that it could not be read properly", 0);
} }

View File

@@ -20,6 +20,7 @@
package org.mustangproject.ZUGFeRD; package org.mustangproject.ZUGFeRD;
import org.mustangproject.Invoice; import org.mustangproject.Invoice;
import org.mustangproject.XMLTools;
import org.junit.FixMethodOrder; import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
@@ -81,7 +82,7 @@ public class ZF2ZInvoiceImporterTest extends TestCase {
assertEquals("Stadthausen", invoice.getSender().getLocation()); assertEquals("Stadthausen", invoice.getSender().getLocation());
TransactionCalculator tc=new TransactionCalculator(invoice); TransactionCalculator tc=new TransactionCalculator(invoice);
assertEquals(new BigDecimal("571.04"),tc.getTotalGross()); assertEquals("571.04", XMLTools.nDigitFormat(tc.getTotalGross(),2));
// name street location zip country, contact name phone email, total amount // name street location zip country, contact name phone email, total amount
@@ -102,7 +103,7 @@ public class ZF2ZInvoiceImporterTest extends TestCase {
} }
assertFalse(hasExceptions); assertFalse(hasExceptions);
TransactionCalculator tc=new TransactionCalculator(invoice); TransactionCalculator tc=new TransactionCalculator(invoice);
assertEquals(new BigDecimal("18.33"),tc.getTotalGross()); assertEquals("18.33", XMLTools.nDigitFormat(tc.getTotalGross(),2));
} }
public void testAllowancesChargesImport() { public void testAllowancesChargesImport() {
@@ -118,7 +119,7 @@ public class ZF2ZInvoiceImporterTest extends TestCase {
} }
assertFalse(hasExceptions); assertFalse(hasExceptions);
TransactionCalculator tc=new TransactionCalculator(invoice); TransactionCalculator tc=new TransactionCalculator(invoice);
assertEquals(new BigDecimal("11.07"),tc.getTotalGross()); assertEquals("11.07", XMLTools.nDigitFormat(tc.getTotalGross(),2));
// name street location zip country, contact name phone email, total amount // name street location zip country, contact name phone email, total amount