From 5bd04e0bbc005e5b126a62cfee949992b791c063 Mon Sep 17 00:00:00 2001 From: Bharti Date: Mon, 25 Nov 2024 14:52:38 +0100 Subject: [PATCH] UBL updates : line charge / allowance --- .../java/org/mustangproject/TradeParty.java | 39 +++++++++++++++++-- .../ZUGFeRD/ZUGFeRDInvoiceImporter.java | 18 ++++++--- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/library/src/main/java/org/mustangproject/TradeParty.java b/library/src/main/java/org/mustangproject/TradeParty.java index 3590e9e1..42838984 100644 --- a/library/src/main/java/org/mustangproject/TradeParty.java +++ b/library/src/main/java/org/mustangproject/TradeParty.java @@ -171,7 +171,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { NodeList taxSchemechilds = partyTaxScheme.item(partyTaxSchemeIndex).getChildNodes(); for (int taxSchemechildsIndex = 0; taxSchemechildsIndex < taxSchemechilds.getLength(); taxSchemechildsIndex++) { if (taxSchemechilds.item(taxSchemechildsIndex).getLocalName() != null){ - if (taxSchemechilds.item(taxSchemechildsIndex).getTextContent().equals("FC")) { + if (taxSchemechilds.item(taxSchemechildsIndex).getTextContent().equals("FC") ||(taxSchemechilds.item(taxSchemechildsIndex).getTextContent().equals("NOVAT"))) { setTaxID(CompanyId); } else{ @@ -252,8 +252,6 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { } } - - } if (postal.item(postalChildIndex).getLocalName().equals("Name")) { setName(postal.item(postalChildIndex).getTextContent()); @@ -284,6 +282,41 @@ public class TradeParty implements IZUGFeRDExportableTradeParty { NodeList contact = nodes.item(nodeIndex).getChildNodes(); setContact(new Contact(contact)); } + if(currentUBLChild.equals("PayeeParty")){ + NodeList payeeParty = nodes.item(nodeIndex).getChildNodes(); + for (int payeePartyIndex = 0; payeePartyIndex < payeeParty.getLength(); payeePartyIndex++) { + if (payeeParty.item(payeePartyIndex).getLocalName() != null) { + if (payeeParty.item(payeePartyIndex).getLocalName().equals("PartyIdentification")) { + NodeList partyID = payeeParty.item(payeePartyIndex).getChildNodes(); + for (int partyIDIndex = 0; partyIDIndex < partyID.getLength(); partyIDIndex++) { + if (partyID.item(partyIDIndex).getLocalName() != null) { + if (partyID.item(partyIDIndex).getLocalName().equals("ID")) { + Node currentNode = partyID.item(partyIDIndex); + + if ((currentNode.getAttributes() != null && + (currentNode.getAttributes().getNamedItem("schemeID") != null)) + ) { + //SchemedID gid = new SchemedID().setScheme(nodes.item(nodeIndex).getAttributes().getNamedItem("schemeID").getNodeValue()).setId(nodes.item(nodeIndex).getTextContent()); + // addGlobalID(gid); + SchemedID sID = new SchemedID(currentNode.getAttributes().getNamedItem("schemeID").getTextContent(), currentNode.getTextContent()); + addGlobalID(sID); + + //&& ((currentNode.getAttributes().getNamedItem("schemeID").getNodeValue().equals("0110") && currentNode.getAttributes().getNamedItem("schemeID").getNodeValue().equals("0100")) + } + else{ + setID(currentNode.getTextContent()); + } + + } + } + } + } + + + } + } + + } } } } diff --git a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java index 08397508..8932d50c 100644 --- a/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java +++ b/library/src/main/java/org/mustangproject/ZUGFeRD/ZUGFeRDInvoiceImporter.java @@ -302,8 +302,8 @@ public class ZUGFeRDInvoiceImporter { } //UBL... - shipEx = xpath.compile("//*[local-name()=\"DeliveryLocation\"]"); - deliveryNodes = (NodeList) shipEx.evaluate(getDocument(), XPathConstants.NODESET); + XPathExpression shipExUBL = xpath.compile("//*[local-name()=\"DeliveryLocation\"]"); + deliveryNodes = (NodeList) shipExUBL.evaluate(getDocument(), XPathConstants.NODESET); if (deliveryNodes != null) { String street, name, additionalStreet, city, postal, countrySubentity, line, country = null; street = extractString("//*[local-name() = \"Address\"]/*[local-name() = \"StreetName\"]"); @@ -315,7 +315,15 @@ public class ZUGFeRDInvoiceImporter { country = extractString("//*[local-name() = \"Address\"]//*[local-name() = \"Country\"]/*[local-name() = \"IdentificationCode\"]"); name = extractString("//*[local-name() = \"DeliveryParty\"]//*[local-name() = \"PartyName\"]/*[local-name() = \"Name\"]"); - zpp.setDeliveryAddress(new TradeParty(deliveryNodes).setStreet(street).setAdditionalAddress(additionalStreet).setLocation(city).setZIP(postal).setAdditionalAddressExtension(line).setCountry(country).setName(name)); + zpp.setDeliveryAddress(new TradeParty(deliveryNodes) + .setStreet(street) + .setAdditionalAddress(additionalStreet) + .setLocation(city) + .setZIP(postal) + .setAdditionalAddressExtension(line) + .setCountry(country) + .setName(name) + ); } @@ -613,7 +621,7 @@ public class ZUGFeRDInvoiceImporter { zpp.setDespatchAdviceReferencedDocumentID(extractString("//*[local-name()=\"DespatchDocumentReference\"]/*[local-name()=\"ID\"]")); } - //zpp.setOwnOrganisationName(extractString("//*[local-name()=\"SellerTradeParty\"]/*[local-name()=\"Name\"]|//*[local-name()=\"AccountingSupplierParty\"]/*[local-name()=\"Party\"]/*[local-name()=\"PartyName\"]").trim()); + zpp.setOwnOrganisationName(extractString("//*[local-name()=\"SellerTradeParty\"]/*[local-name()=\"Name\"]|//*[local-name()=\"AccountingSupplierParty\"]/*[local-name()=\"Party\"]/*[local-name()=\"PartyName\"]").trim()); xpr = xpath.compile("//*[local-name()=\"BuyerReference\"]"); String buyerReference = null; @@ -651,7 +659,7 @@ public class ZUGFeRDInvoiceImporter { // be read, // so the invoice remains arithmetically correct // -> parse document level charges+allowances - xpr = xpath.compile("//*[local-name()=\"SpecifiedTradeAllowanceCharge\"]|/*[local-name()=\"Invoice\"]/*[local-name()=\"AllowanceCharge\"]");//CII and UBL + xpr = xpath.compile("//*[local-name()=\"SpecifiedTradeAllowanceCharge\"]|//*[local-name()=\"AllowanceCharge\"]");//CII and UBL NodeList chargeNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET); for (int i = 0; i < chargeNodes.getLength(); i++) { NodeList chargeNodeChilds = chargeNodes.item(i).getChildNodes();