allow orderx to be parsed with invoiceimporter
This commit is contained in:
@@ -216,7 +216,8 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
if ((itemChilds.item(itemChildIndex).getLocalName() != null) && (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedLineTradeDelivery"))) {
|
if ((itemChilds.item(itemChildIndex).getLocalName() != null) && (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedLineTradeDelivery"))) {
|
||||||
NodeList tradeLineChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
NodeList tradeLineChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
||||||
for (int tradeLineChildIndex = 0; tradeLineChildIndex < tradeLineChilds.getLength(); tradeLineChildIndex++) {
|
for (int tradeLineChildIndex = 0; tradeLineChildIndex < tradeLineChilds.getLength(); tradeLineChildIndex++) {
|
||||||
if ((tradeLineChilds.item(tradeLineChildIndex).getLocalName() != null) && (tradeLineChilds.item(tradeLineChildIndex).getLocalName().equals("BilledQuantity"))) {
|
if ((tradeLineChilds.item(tradeLineChildIndex).getLocalName() != null) && (tradeLineChilds.item(tradeLineChildIndex).getLocalName().equals("BilledQuantity")||tradeLineChilds.item(tradeLineChildIndex).getLocalName().equals("RequestedQuantity"))) {
|
||||||
|
//RequestedQuantity is for Order-X, BilledQuantity for FX and ZF
|
||||||
quantity = tradeLineChilds.item(tradeLineChildIndex).getTextContent();
|
quantity = tradeLineChilds.item(tradeLineChildIndex).getTextContent();
|
||||||
unitCode = tradeLineChilds.item(tradeLineChildIndex).getAttributes().getNamedItem("unitCode").getNodeValue();
|
unitCode = tradeLineChilds.item(tradeLineChildIndex).getAttributes().getNamedItem("unitCode").getNodeValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ import junit.framework.Test;
|
|||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
|
import org.mustangproject.Invoice;
|
||||||
|
|
||||||
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -31,6 +33,7 @@ import java.math.BigDecimal;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -285,9 +288,26 @@ public class OXTest extends MustangReaderTestCase implements IExportableTransact
|
|||||||
assertFalse(zi.getUTF8().contains("EUR"));
|
assertFalse(zi.getUTF8().contains("EUR"));
|
||||||
assertTrue(zi.getUTF8().contains("USD"));//currency should be USD, test for #150
|
assertTrue(zi.getUTF8().contains("USD"));//currency should be USD, test for #150
|
||||||
|
|
||||||
// Reading ZUGFeRD
|
// Now also check the "invoice"Importer
|
||||||
assertEquals("496.00", zi.getAmount());
|
assertEquals("496.00", zi.getAmount());
|
||||||
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
||||||
|
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(TARGET_PDF);
|
||||||
|
try {
|
||||||
|
Invoice i=zii.extractInvoice();
|
||||||
|
|
||||||
|
assertEquals(new BigDecimal("400.0000"), i.getZFItems()[1].getQuantity());
|
||||||
|
/* getting the Quantity is more difficult than usual because in OrderX it's
|
||||||
|
called requestedQuantity, not BilledQuantity
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
} catch (XPathExpressionException e) {
|
||||||
|
fail("XPathExpressionException should not be raised in testEdgeExport");
|
||||||
|
} catch (ParseException e) {
|
||||||
|
fail("ParseException should not be raised in testEdgeExport");
|
||||||
|
/* a parseException would also be fired if the calculated grand total does not
|
||||||
|
match the read grand total */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user