invoiceimporter to read global IDs
This commit is contained in:
@@ -93,6 +93,13 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
if (itemChilds.item(itemChildIndex).getLocalName().equals("Name")) {
|
if (itemChilds.item(itemChildIndex).getLocalName().equals("Name")) {
|
||||||
setName(itemChilds.item(itemChildIndex).getTextContent());
|
setName(itemChilds.item(itemChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
|
if (itemChilds.item(itemChildIndex).getLocalName().equals("GlobalID")) {
|
||||||
|
if (itemChilds.item(itemChildIndex).getAttributes().getNamedItem("schemeID") != null) {
|
||||||
|
SchemedID gid=new SchemedID().setScheme(itemChilds.item(itemChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue()).setId(itemChilds.item(itemChildIndex).getTextContent());
|
||||||
|
addGlobalID(gid);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
if (itemChilds.item(itemChildIndex).getLocalName().equals("DefinedTradeContact")) {
|
if (itemChilds.item(itemChildIndex).getLocalName().equals("DefinedTradeContact")) {
|
||||||
NodeList contact = itemChilds.item(itemChildIndex).getChildNodes();
|
NodeList contact = itemChilds.item(itemChildIndex).getChildNodes();
|
||||||
setContact(new Contact(contact));
|
setContact(new Contact(contact));
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
String price = "0";
|
String price = "0";
|
||||||
String name = "";
|
String name = "";
|
||||||
String description = "";
|
String description = "";
|
||||||
|
SchemedID gid = null;
|
||||||
String quantity = "0";
|
String quantity = "0";
|
||||||
String vatPercent = "0";
|
String vatPercent = "0";
|
||||||
String lineTotal = "0";
|
String lineTotal = "0";
|
||||||
@@ -229,6 +230,12 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
if ((tradeProductChilds.item(tradeProductChildIndex).getLocalName() != null) && (tradeProductChilds.item(tradeProductChildIndex).getLocalName().equals("Name"))) {
|
if ((tradeProductChilds.item(tradeProductChildIndex).getLocalName() != null) && (tradeProductChilds.item(tradeProductChildIndex).getLocalName().equals("Name"))) {
|
||||||
name = tradeProductChilds.item(tradeProductChildIndex).getTextContent();
|
name = tradeProductChilds.item(tradeProductChildIndex).getTextContent();
|
||||||
}
|
}
|
||||||
|
if ((tradeProductChilds.item(tradeProductChildIndex).getLocalName() != null) && (tradeProductChilds.item(tradeProductChildIndex).getLocalName().equals("GlobalID"))) {
|
||||||
|
if (tradeProductChilds.item(tradeProductChildIndex).getAttributes().getNamedItem("schemeID") != null) {
|
||||||
|
gid = new SchemedID().setScheme(tradeProductChilds.item(tradeProductChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue()).setId(tradeProductChilds.item(tradeProductChildIndex).getTextContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((itemChilds.item(itemChildIndex).getLocalName() != null) && (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedLineTradeSettlement"))) {
|
if ((itemChilds.item(itemChildIndex).getLocalName() != null) && (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedLineTradeSettlement"))) {
|
||||||
@@ -262,7 +269,11 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
if ((recalcPrice) && (!qty.equals(BigDecimal.ZERO))) {
|
if ((recalcPrice) && (!qty.equals(BigDecimal.ZERO))) {
|
||||||
prc = new BigDecimal(lineTotal.trim()).divide(qty, 4, RoundingMode.HALF_UP);
|
prc = new BigDecimal(lineTotal.trim()).divide(qty, 4, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
Item it=new Item(new Product(name, description, unitCode, new BigDecimal(vatPercent.trim())), prc, qty);
|
Product p = new Product(name, description, unitCode, new BigDecimal(vatPercent.trim()));
|
||||||
|
if (gid != null) {
|
||||||
|
p.addGlobalID(gid);
|
||||||
|
}
|
||||||
|
Item it = new Item(p, prc, qty);
|
||||||
if (rdocs != null) {
|
if (rdocs != null) {
|
||||||
for (ReferencedDocument rdoc : rdocs) {
|
for (ReferencedDocument rdoc : rdocs) {
|
||||||
it.addReferencedDocument(rdoc);
|
it.addReferencedDocument(rdoc);
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ import org.xmlunit.builder.Input;
|
|||||||
import org.xmlunit.xpath.JAXPXPathEngine;
|
import org.xmlunit.xpath.JAXPXPathEngine;
|
||||||
import org.xmlunit.xpath.XPathEngine;
|
import org.xmlunit.xpath.XPathEngine;
|
||||||
|
|
||||||
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
|
|
||||||
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
import static org.xmlunit.assertj.XmlAssert.assertThat;
|
||||||
|
|
||||||
|
|
||||||
@@ -428,6 +430,24 @@ public class ZF2PushTest extends TestCase {
|
|||||||
assertTrue(zi.getUTF8().contains("document level 2/2"));
|
assertTrue(zi.getUTF8().contains("document level 2/2"));
|
||||||
assertFalse(zi.getUTF8().contains("++49555123456")); // in profile EN16931 contact fax number is not allowed
|
assertFalse(zi.getUTF8().contains("++49555123456")); // in profile EN16931 contact fax number is not allowed
|
||||||
|
|
||||||
|
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(TARGET_PUSHEDGE);
|
||||||
|
try {
|
||||||
|
Invoice i = zii.extractInvoice();
|
||||||
|
|
||||||
|
assertEquals("4304171000002", i.getRecipient().getGlobalID());
|
||||||
|
assertEquals("2001015001325", i.getZFItems()[0].getProduct().getGlobalID());
|
||||||
|
|
||||||
|
|
||||||
|
} 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 */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAllowancesExport() {
|
public void testAllowancesExport() {
|
||||||
|
|||||||
Reference in New Issue
Block a user