Revert all changes
This reverts commit90b1d7c7aa,95998b820aand9af73473b7
This commit is contained in:
@@ -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;
|
return res.setScale(2, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -48,7 +48,7 @@ public class ZUGFeRDImporter {
|
|||||||
/**
|
/**
|
||||||
* if metadata has been found
|
* if metadata has been found
|
||||||
*/
|
*/
|
||||||
protected boolean containsMeta = false;
|
private boolean containsMeta = false;
|
||||||
/**
|
/**
|
||||||
* map filenames of additional XML files to their contents
|
* map filenames of additional XML files to their contents
|
||||||
*/
|
*/
|
||||||
@@ -67,10 +67,6 @@ public class ZUGFeRDImporter {
|
|||||||
private Document document;
|
private Document document;
|
||||||
|
|
||||||
|
|
||||||
protected ZUGFeRDImporter() {
|
|
||||||
//constructor for extending classes
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZUGFeRDImporter(String pdfFilename) {
|
public ZUGFeRDImporter(String pdfFilename) {
|
||||||
try (InputStream bis = Files.newInputStream(Paths.get(pdfFilename), StandardOpenOption.READ)) {
|
try (InputStream bis = Files.newInputStream(Paths.get(pdfFilename), StandardOpenOption.READ)) {
|
||||||
extractLowLevel(bis);
|
extractLowLevel(bis);
|
||||||
@@ -792,7 +788,8 @@ public class ZUGFeRDImporter {
|
|||||||
List<Node> nodeList = getLineItemNodes();
|
List<Node> nodeList = getLineItemNodes();
|
||||||
List<Item> lineItemList = new ArrayList<>();
|
List<Item> lineItemList = new ArrayList<>();
|
||||||
|
|
||||||
for (Node n: nodeList) {
|
for (Node n: nodeList
|
||||||
|
) {
|
||||||
Item lineItem = new Item(null, null, null);
|
Item lineItem = new Item(null, null, null);
|
||||||
lineItem.setProduct(new Product(null,null,null,null));
|
lineItem.setProduct(new Product(null,null,null,null));
|
||||||
|
|
||||||
@@ -806,21 +803,13 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
node = getNodeByName(nn.getChildNodes(), "ram:NetPriceProductTradePrice");
|
node = getNodeByName(nn.getChildNodes(), "ram:NetPriceProductTradePrice");
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
NodeList tradeAgreementChildren = node.getChildNodes();
|
node = getNodeByName(node.getChildNodes(), "ram:ChargeAmount");
|
||||||
node = getNodeByName(tradeAgreementChildren, "ram:ChargeAmount");
|
lineItem.setPrice(tryBigDecimal(getNodeValue(node)));
|
||||||
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(nn.getChildNodes(), "ram:GrossPriceProductTradePrice");
|
node = getNodeByName(nn.getChildNodes(), "ram:GrossPriceProductTradePrice");
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
node = getNodeByName(node.getChildNodes(), "ram:ChargeAmount");
|
node = getNodeByName(node.getChildNodes(), "ram:ChargeAmount");
|
||||||
lineItem.setGrossPrice(tryBigDecimal(getNodeValue(node)));
|
lineItem.setGrossPrice(tryBigDecimal(getNodeValue(node)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ 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;
|
||||||
@@ -260,7 +259,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TransactionCalculator tc = new TransactionCalculator(zpp);
|
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))) {
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
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;
|
||||||
|
|
||||||
@@ -82,7 +81,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("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
|
// name street location zip country, contact name phone email, total amount
|
||||||
@@ -103,7 +102,7 @@ public class ZF2ZInvoiceImporterTest extends TestCase {
|
|||||||
}
|
}
|
||||||
assertFalse(hasExceptions);
|
assertFalse(hasExceptions);
|
||||||
TransactionCalculator tc=new TransactionCalculator(invoice);
|
TransactionCalculator tc=new TransactionCalculator(invoice);
|
||||||
assertEquals("18.33", XMLTools.nDigitFormat(tc.getTotalGross(),2));
|
assertEquals(new BigDecimal("18.33"),tc.getTotalGross());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllowancesChargesImport() {
|
public void testAllowancesChargesImport() {
|
||||||
@@ -119,7 +118,7 @@ public class ZF2ZInvoiceImporterTest extends TestCase {
|
|||||||
}
|
}
|
||||||
assertFalse(hasExceptions);
|
assertFalse(hasExceptions);
|
||||||
TransactionCalculator tc=new TransactionCalculator(invoice);
|
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
|
// name street location zip country, contact name phone email, total amount
|
||||||
|
|||||||
Reference in New Issue
Block a user