Revert all changes

This reverts commit 90b1d7c7aa,
95998b820a and
9af73473b7
This commit is contained in:
Sebastian Sieber
2020-11-25 12:57:21 +01:00
parent 90b1d7c7aa
commit cc561a8f66
5 changed files with 12 additions and 46 deletions

View File

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

View File

@@ -1,21 +0,0 @@
package org.mustangproject.ZUGFeRD;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class XRechnungImporter extends ZUGFeRDImporter {
public XRechnungImporter(byte[] rawXml) {
super();
try {
setRawXML(rawXml);
containsMeta = true;
} catch (final IOException e) {
Logger.getLogger(ZUGFeRDImporter.class.getName()).log(Level.SEVERE, null, e);
throw new ZUGFeRDExportException(e);
}
}
}

View File

@@ -48,7 +48,7 @@ public class ZUGFeRDImporter {
/**
* if metadata has been found
*/
protected boolean containsMeta = false;
private boolean containsMeta = false;
/**
* map filenames of additional XML files to their contents
*/
@@ -67,10 +67,6 @@ public class ZUGFeRDImporter {
private Document document;
protected ZUGFeRDImporter() {
//constructor for extending classes
}
public ZUGFeRDImporter(String pdfFilename) {
try (InputStream bis = Files.newInputStream(Paths.get(pdfFilename), StandardOpenOption.READ)) {
extractLowLevel(bis);
@@ -792,7 +788,8 @@ public class ZUGFeRDImporter {
List<Node> nodeList = getLineItemNodes();
List<Item> lineItemList = new ArrayList<>();
for (Node n: nodeList) {
for (Node n: nodeList
) {
Item lineItem = new Item(null, null, null);
lineItem.setProduct(new Product(null,null,null,null));
@@ -806,21 +803,13 @@ public class ZUGFeRDImporter {
node = getNodeByName(nn.getChildNodes(), "ram:NetPriceProductTradePrice");
if (node != null) {
NodeList tradeAgreementChildren = node.getChildNodes();
node = getNodeByName(tradeAgreementChildren, "ram:ChargeAmount");
lineItem.setPrice(tryBigDecimal(getNodeValue(node)));
node = getNodeByName(tradeAgreementChildren, "ram:BasisQuantity");
if(node.getAttributes()!=null) {
Node unitCodeAttribute = node.getAttributes().getNamedItem("unitCode");
if(unitCodeAttribute != null) {
lineItem.getProduct().setUnit(unitCodeAttribute.getNodeValue());
}
}
node = getNodeByName(node.getChildNodes(), "ram:ChargeAmount");
lineItem.setPrice(tryBigDecimal(getNodeValue(node)));
}
node = getNodeByName(nn.getChildNodes(), "ram:GrossPriceProductTradePrice");
if (node != null) {
node = getNodeByName(node.getChildNodes(), "ram:ChargeAmount");
node = getNodeByName(node.getChildNodes(), "ram:ChargeAmount");
lineItem.setGrossPrice(tryBigDecimal(getNodeValue(node)));
}
break;

View File

@@ -6,7 +6,6 @@ import org.w3c.dom.NodeList;
import javax.xml.xpath.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -260,7 +259,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
}
TransactionCalculator tc = new TransactionCalculator(zpp);
String expectedStringTotalGross = tc.getTotalGross().setScale(2, RoundingMode.HALF_UP).toPlainString();
String expectedStringTotalGross = tc.getTotalGross().toPlainString();
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);
}

View File

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