Merge branch 'issues/503-ubl'
# Conflicts: # library/src/test/java/org/mustangproject/ZUGFeRD/ZF2ZInvoiceImporterTest.java
This commit is contained in:
@@ -84,19 +84,19 @@ public class BankDetails implements IZUGFeRDTradeSettlementPayment {
|
||||
/***
|
||||
* getOwn... methods will be removed in the future in favor of Tradeparty (e.g. Sender) class
|
||||
* */
|
||||
@Override
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public String getOwnBIC() {
|
||||
return getBIC();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
@JsonIgnore
|
||||
public String getOwnIBAN() {
|
||||
return getIBAN();
|
||||
}
|
||||
// @Override
|
||||
// @Deprecated
|
||||
// @JsonIgnore
|
||||
// public String getOwnBIC() {
|
||||
// return getBIC();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Deprecated
|
||||
// @JsonIgnore
|
||||
// public String getOwnIBAN() {
|
||||
// return getIBAN();
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,8 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* describes any invoice line
|
||||
@@ -37,6 +39,7 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
protected ArrayList<ReferencedDocument> additionalReference = null;
|
||||
protected ArrayList<IZUGFeRDAllowanceCharge> Allowances = new ArrayList<>();
|
||||
protected ArrayList<IZUGFeRDAllowanceCharge> Charges = new ArrayList<>();
|
||||
//protected HashMap<String, String> attributes = new HashMap<>();
|
||||
|
||||
/***
|
||||
* default constructor
|
||||
@@ -64,8 +67,33 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
// ubl
|
||||
//we need: name description unitcode
|
||||
//and we additionally have vat%
|
||||
|
||||
// Bharti's homework 20241126:Streams https://www.youtube.com/watch?v=Lf01cBzmuXw
|
||||
// and Lambdas https://www.youtube.com/watch?v=HCyx31NW8xg
|
||||
setProduct(new Product());
|
||||
icnm.getAsString("Name").ifPresent(product::setName);
|
||||
icnm.getAsString("Description").ifPresent(product::setDescription);
|
||||
|
||||
icnm.getAsNodeMap("SellersItemIdentification").ifPresent(SellersItemIdentification -> {
|
||||
SellersItemIdentification.getAsString("ID").ifPresent(product::setSellerAssignedID);
|
||||
});
|
||||
|
||||
icnm.getAsNodeMap("BuyersItemIdentification").ifPresent(BuyersItemIdentification -> {
|
||||
BuyersItemIdentification.getAsString("ID").ifPresent(product::setBuyerAssignedID);
|
||||
});
|
||||
|
||||
// String name = icnm.getAsStringOrNull("Name");
|
||||
// String val = icnm.getAsStringOrNull("Value");
|
||||
// if (name != null && val != null) {
|
||||
// if (attributes == null) {
|
||||
// attributes = new HashMap<>();
|
||||
// }
|
||||
// product.attributes.put(name, val);
|
||||
// }
|
||||
//icnm.getNode("AdditionalItemProperty").flatMap(n ->n.getAttributes()).ifPresent(product::setAttributes);
|
||||
|
||||
|
||||
|
||||
icnm.getAsNodeMap("ClassifiedTaxCategory").flatMap(m -> m.getAsBigDecimal("Percent"))
|
||||
.ifPresent(product::setVATPercent);
|
||||
});
|
||||
@@ -86,11 +114,21 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
product.setUnit(icn.getAttributes().getNamedItem("unitCode").getNodeValue());
|
||||
});
|
||||
|
||||
itemMap.getAsNodeMap("OrderLineReference")
|
||||
.flatMap(bordNodes -> bordNodes.getAsString("LineID"))
|
||||
.ifPresent(this::addReferencedLineID);
|
||||
|
||||
|
||||
|
||||
itemMap.getAllNodes("DocumentReference").map(ReferencedDocument::fromNode)
|
||||
.forEach(this::addAdditionalReference);
|
||||
|
||||
itemMap.getAsNodeMap("SpecifiedLineTradeAgreement", "SpecifiedSupplyChainTradeAgreement").ifPresent(icnm -> {
|
||||
icnm.getAsNodeMap("BuyerOrderReferencedDocument")
|
||||
.flatMap(bordNodes -> bordNodes.getAsString("LineID"))
|
||||
.ifPresent(this::addReferencedLineID);
|
||||
|
||||
|
||||
icnm.getAsNodeMap("NetPriceProductTradePrice").ifPresent(npptpNodes -> {
|
||||
npptpNodes.getAsBigDecimal("ChargeAmount").ifPresent(this::setPrice);
|
||||
npptpNodes.getAsBigDecimal("BasisQuantity").ifPresent(this::setBasisQuantity);
|
||||
@@ -100,7 +138,8 @@ public class Item implements IZUGFeRDExportableItem {
|
||||
.forEach(this::addReferencedDocument);
|
||||
});
|
||||
|
||||
itemMap.getNode("SpecifiedTradeProduct").map(Product::new).ifPresent(this::setProduct);
|
||||
itemMap.getNode("SpecifiedTradeProduct").map(Product::new).ifPresent(this::setProduct);//CII
|
||||
itemMap.getNode("SpecifiedTradeProduct").map(Product::new).ifPresent(this::setProduct);//UBL
|
||||
|
||||
// RequestedQuantity is for Order-X, BilledQuantity for FX and ZF
|
||||
itemMap.getAsNodeMap("SpecifiedLineTradeDelivery", "SpecifiedSupplyChainTradeDelivery")
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.mustangproject.ZUGFeRD.IDesignatedProductClassification;
|
||||
import org.mustangproject.ZUGFeRD.IZUGFeRDExportableProduct;
|
||||
import org.mustangproject.util.NodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
@@ -59,11 +60,15 @@ public class Product implements IZUGFeRDExportableProduct {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
nodeMap.getAsString("SellerAssignedID").ifPresent(this::setSellerAssignedID);
|
||||
nodeMap.getAsString("BuyerAssignedID").ifPresent(this::setBuyerAssignedID);
|
||||
nodeMap.getAsString("Name").ifPresent(this::setName);
|
||||
nodeMap.getAsString("Description").ifPresent(this::setDescription);
|
||||
|
||||
|
||||
nodeMap.getAsNodeMap("ApplicableProductCharacteristic").ifPresent(apcNodes -> {
|
||||
String key = apcNodes.getAsStringOrNull("Description");
|
||||
String value = apcNodes.getAsStringOrNull("Value");
|
||||
@@ -75,6 +80,18 @@ public class Product implements IZUGFeRDExportableProduct {
|
||||
}
|
||||
});
|
||||
|
||||
//UBL
|
||||
nodeMap.getAsNodeMap("AdditionalItemProperty").ifPresent(aipNodes -> {
|
||||
String name = aipNodes.getAsStringOrNull("Name");
|
||||
String val = aipNodes.getAsStringOrNull("Value");
|
||||
if (name != null && val != null) {
|
||||
if (attributes == null) {
|
||||
attributes = new HashMap<>();
|
||||
}
|
||||
attributes.put(name, val);
|
||||
}
|
||||
});
|
||||
|
||||
nodeMap.getAsNodeMap("DesignatedProductClassification").ifPresent(dpcNodes -> {
|
||||
String className = dpcNodes.getAsStringOrNull("ClassName");
|
||||
dpcNodes.getNode("ClassCode").map(ClassCode::fromNode).ifPresent(classCode ->
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.mustangproject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -16,6 +17,7 @@ import org.w3c.dom.NodeList;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
|
||||
/***
|
||||
* A organisation, i.e. usually a company
|
||||
*/
|
||||
@@ -62,6 +64,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void parseFromUBL(NodeList nodes) {
|
||||
if (nodes.getLength() > 0) {
|
||||
|
||||
@@ -71,6 +74,33 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
|
||||
if (currentItemNode.getLocalName() != null) {
|
||||
String currentUBLChild = currentItemNode.getLocalName();
|
||||
if (currentUBLChild.equals("Delivery")) {
|
||||
NodeList delivery = currentItemNode.getChildNodes();
|
||||
for (int deliveryIndex = 0; deliveryIndex < delivery.getLength(); deliveryIndex++) {
|
||||
if (delivery.item(deliveryIndex).getLocalName() != null) {
|
||||
Node currentNode = delivery.item(deliveryIndex);
|
||||
if (currentNode.getLocalName().equals("DeliveryLocation")) {
|
||||
NodeList deliveryLocation = currentNode.getChildNodes();
|
||||
for (int deliveryLocationIndex = 0; deliveryLocationIndex < deliveryLocation.getLength(); deliveryLocationIndex++) {
|
||||
if (deliveryLocation.item(deliveryLocationIndex).getLocalName() != null) {
|
||||
if (deliveryLocation.item(deliveryLocationIndex).getLocalName().equals("ID")) {
|
||||
//Node currentNode = partyID.item(partyIDIndex);
|
||||
setID(deliveryLocation.item(deliveryLocationIndex).getTextContent());
|
||||
if ((deliveryLocation.item(deliveryLocationIndex).getAttributes() != null &&
|
||||
(deliveryLocation.item(deliveryLocationIndex).getAttributes().getNamedItem("schemeID") != null))
|
||||
) {
|
||||
SchemedID sID = new SchemedID().setScheme(deliveryLocation.item(deliveryLocationIndex).getAttributes().getNamedItem("schemeID").getTextContent());
|
||||
addGlobalID(sID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentUBLChild.equals("Party")) {
|
||||
|
||||
NodeList party = currentItemNode.getChildNodes();
|
||||
@@ -90,42 +120,105 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (party.item(partyIndex).getLocalName().equals("EndpointID")) {
|
||||
Node currentNode = party.item(partyIndex);
|
||||
if ((currentNode.getAttributes() != null &&
|
||||
(currentNode.getAttributes().getNamedItem("schemeID") != null))
|
||||
&& (party.item(partyIndex).getAttributes().getNamedItem("schemeID").getNodeValue().equals("EM"))
|
||||
) {
|
||||
setEmail(currentNode.getTextContent());
|
||||
}
|
||||
|
||||
if (currentTopElementName.equals("PartyTaxScheme")) {
|
||||
NodeList partyTaxScheme = party.item(partyIndex).getChildNodes();
|
||||
for (int partyTaxSchemeIndex = 0; partyTaxSchemeIndex < partyTaxScheme.getLength(); partyTaxSchemeIndex++) {
|
||||
if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName() != null) {
|
||||
if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName().equals("CompanyID")) {
|
||||
setTaxID(partyTaxScheme.item(partyTaxSchemeIndex).getTextContent());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (party.item(partyIndex).getLocalName().equals("AccountingSupplierParty")) {
|
||||
// NodeList payeeParty = party.item(partyIndex).getChildNodes();
|
||||
// for (int payeePartyIndex = 0; payeePartyIndex < payeeParty.getLength(); payeePartyIndex++) {
|
||||
// if (payeeParty.item(payeePartyIndex).getLocalName() != null) {
|
||||
if (currentTopElementName.equals("PartyIdentification")) {
|
||||
NodeList partyID = party.item(partyIndex).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().setScheme(currentNode.getAttributes().getNamedItem("schemeID").getTextContent()).setId(currentNode.getTextContent());
|
||||
addGlobalID(sID);
|
||||
|
||||
|
||||
// if (currentTopElementName.equals("PartyTaxScheme")) {
|
||||
// NodeList partyTaxScheme = party.item(partyIndex).getChildNodes();
|
||||
// for (int partyTaxSchemeIndex = 0; partyTaxSchemeIndex < partyTaxScheme.getLength(); partyTaxSchemeIndex++) {
|
||||
// if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName() != null) {
|
||||
// if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName().equals("TaxScheme")) {
|
||||
// NodeList taxScheme = partyTaxScheme.item(partyTaxSchemeIndex).getChildNodes();
|
||||
// for (int taxSchemeIndex = 0 ; taxSchemeIndex < taxScheme.getLength(); taxSchemeIndex++) {
|
||||
// if (taxScheme.item(taxSchemeIndex).getLocalName() != null) {
|
||||
// if(taxScheme.item(taxSchemeIndex).getLocalName().equals("ID")){
|
||||
// if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName().equals("CompanyID")) {
|
||||
// setTaxID(partyTaxScheme.item(partyTaxSchemeIndex).getTextContent());
|
||||
// } else {
|
||||
// setVATID(partyTaxScheme.item(partyTaxSchemeIndex).getTextContent());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//&& ((currentNode.getAttributes().getNamedItem("schemeID").getNodeValue().equals("0110") && currentNode.getAttributes().getNamedItem("schemeID").getNodeValue().equals("0100"))
|
||||
}
|
||||
// else {
|
||||
// setID(currentNode.getTextContent());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (currentTopElementName.equals("AccountingCustomerParty")) {
|
||||
// NodeList partyID = party.item(partyIndex).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);
|
||||
// //setID(currentNode.getTextContent());
|
||||
//
|
||||
// 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);
|
||||
// // SchemedID sID = new SchemedID().setScheme(deliveryLocation.item(deliveryLocationIndex).getAttributes().getNamedItem("schemeID").getTextContent());
|
||||
// // addGlobalID(sID);
|
||||
// SchemedID sID = new SchemedID().setScheme(currentNode.getAttributes().getNamedItem("schemeID").getTextContent()).setId(currentNode.getTextContent());
|
||||
// addGlobalID(sID);
|
||||
//
|
||||
// //&& ((currentNode.getAttributes().getNamedItem("schemeID").getNodeValue().equals("0110") && currentNode.getAttributes().getNamedItem("schemeID").getNodeValue().equals("0100"))
|
||||
// } else {
|
||||
// setID(currentNode.getTextContent());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
if (currentTopElementName.equals("PartyTaxScheme")) {
|
||||
NodeList partyTaxScheme = party.item(partyIndex).getChildNodes();
|
||||
String CompanyId = null;
|
||||
for (int partyTaxSchemeIndex = 0; partyTaxSchemeIndex < partyTaxScheme.getLength(); partyTaxSchemeIndex++) {
|
||||
if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName() != null) {
|
||||
if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName().equals("CompanyID")) {
|
||||
CompanyId = (partyTaxScheme.item(partyTaxSchemeIndex).getTextContent());
|
||||
}
|
||||
if (partyTaxScheme.item(partyTaxSchemeIndex).getLocalName().equals("TaxScheme")) {
|
||||
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") || (taxSchemechilds.item(taxSchemechildsIndex).getTextContent().equals("NOVAT"))) {
|
||||
setTaxID(CompanyId);
|
||||
} else {
|
||||
setVATID(CompanyId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
UBL only: formally it can have a name as well but BT27 party name *should* be stored in
|
||||
so overwrite if one exists
|
||||
@@ -135,15 +228,34 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
NodeList legal = party.item(partyIndex).getChildNodes();
|
||||
for (int legalChildIndex = 0; legalChildIndex < legal.getLength(); legalChildIndex++) {
|
||||
if (legal.item(legalChildIndex).getLocalName() != null) {
|
||||
LegalOrganisation lo = null;
|
||||
if (legal.item(legalChildIndex).getLocalName().equals("RegistrationName")) {
|
||||
setName(legal.item(legalChildIndex).getTextContent());
|
||||
if (lo == null) {
|
||||
lo = new LegalOrganisation();
|
||||
}
|
||||
lo.setTradingBusinessName(legal.item(legalChildIndex).getTextContent());
|
||||
}
|
||||
if (legal.item(legalChildIndex).getLocalName().equals("CompanyLegalForm")) {
|
||||
setDescription(legal.item(legalChildIndex).getTextContent());
|
||||
}
|
||||
if (legal.item(legalChildIndex).getLocalName().equals("CompanyID")) {
|
||||
if (lo == null) {
|
||||
lo = new LegalOrganisation();
|
||||
}
|
||||
if (legal.item(legalChildIndex).getAttributes().getNamedItem("schemeID")!=null) {
|
||||
SchemedID sid = new SchemedID(legal.item(legalChildIndex).getAttributes().getNamedItem("schemeID").getNodeValue(), legal.item(legalChildIndex).getTextContent());
|
||||
lo.setSchemedID(sid);
|
||||
}
|
||||
}
|
||||
// we dont have that attribute yet in the legalorganisation: CompanyLegalForm
|
||||
if (lo != null) {
|
||||
setLegalOrganisation(lo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentTopElementName.equals("PostalAddress")) {
|
||||
|
||||
NodeList postal = party.item(partyIndex).getChildNodes();
|
||||
@@ -191,8 +303,6 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (postal.item(postalChildIndex).getLocalName().equals("Name")) {
|
||||
setName(postal.item(postalChildIndex).getTextContent());
|
||||
@@ -210,7 +320,6 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (currentUBLChild.equals("GlobalID")) {
|
||||
@@ -224,57 +333,6 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
NodeList contact = nodes.item(nodeIndex).getChildNodes();
|
||||
setContact(new Contact(contact));
|
||||
}
|
||||
|
||||
if (currentUBLChild.equals("PostalTradeAddress")) {
|
||||
NodeList postal = nodes.item(nodeIndex).getChildNodes();
|
||||
for (int postalChildIndex = 0; postalChildIndex < postal.getLength(); postalChildIndex++) {
|
||||
if (postal.item(postalChildIndex).getLocalName() != null) {
|
||||
if (postal.item(postalChildIndex).getLocalName().equals("LineOne")) {
|
||||
setStreet(postal.item(postalChildIndex).getTextContent());
|
||||
}
|
||||
if (postal.item(postalChildIndex).getLocalName().equals("LineTwo")) {
|
||||
setAdditionalAddress(postal.item(postalChildIndex).getTextContent());
|
||||
}
|
||||
if (postal.item(postalChildIndex).getLocalName().equals("LineThree")) {
|
||||
setAdditionalAddressExtension(postal.item(postalChildIndex).getTextContent());
|
||||
}
|
||||
if (postal.item(postalChildIndex).getLocalName().equals("CityName")) {
|
||||
setLocation(postal.item(postalChildIndex).getTextContent());
|
||||
}
|
||||
if (postal.item(postalChildIndex).getLocalName().equals("PostcodeCode")) {
|
||||
setZIP(postal.item(postalChildIndex).getTextContent());
|
||||
}
|
||||
if (postal.item(postalChildIndex).getLocalName().equals("CountryID")) {
|
||||
setCountry(postal.item(postalChildIndex).getTextContent());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (currentUBLChild.equals("PartyTaxScheme")) {
|
||||
NodeList taxChilds = nodes.item(nodeIndex).getChildNodes();
|
||||
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
|
||||
if (taxChilds.item(taxChildIndex).getLocalName() != null) {
|
||||
if ((taxChilds.item(taxChildIndex).getLocalName().equals("TaxScheme"))) {
|
||||
if (taxChilds.item(taxChildIndex).getLocalName().equals("CompanyID")) {
|
||||
if (taxChilds.item(taxChildIndex).getLocalName().equals("ID")) {
|
||||
if (taxChilds.item(taxChildIndex).getLocalName().equals("CompanyID")) {
|
||||
setVATID(taxChilds.item(taxChildIndex).getTextContent());
|
||||
}
|
||||
// setTaxID(partyTaxScheme.item(partyTaxSchemeIndex).getTextContent());
|
||||
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("ID").getNodeValue().equals("FC")) {
|
||||
if (taxChilds.item(taxChildIndex).getLocalName().equals("CompanyID")) {
|
||||
setTaxID(taxChilds.item(taxChildIndex).getTextContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -558,6 +616,7 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
||||
|
||||
/**
|
||||
* primarily for invoiceimporter and JSON
|
||||
*
|
||||
* @return the list of sepa mandates
|
||||
*/
|
||||
public List<DirectDebit> getDebitDetails() {
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile;
|
||||
import org.mustangproject.*;
|
||||
import org.mustangproject.Exceptions.ArithmetricException;
|
||||
import org.mustangproject.Exceptions.StructureException;
|
||||
import org.mustangproject.util.NodeMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -273,6 +274,9 @@ public class ZUGFeRDInvoiceImporter {
|
||||
}
|
||||
}
|
||||
|
||||
public void setID(String id) {
|
||||
String ud=id;
|
||||
}
|
||||
/***
|
||||
* This will parse a XML into the given invoice object
|
||||
* @param zpp the invoice to be altered
|
||||
@@ -302,10 +306,82 @@ public class ZUGFeRDInvoiceImporter {
|
||||
}
|
||||
|
||||
|
||||
//UBL...
|
||||
XPathExpression shipExUBL = xpath.compile("//*[local-name()=\"Delivery\"]");
|
||||
Node deliveryNode = (Node) shipExUBL.evaluate(getDocument(), XPathConstants.NODE);
|
||||
|
||||
if (deliveryNode != null) {
|
||||
TradeParty delivery=new TradeParty();
|
||||
NodeMap nodeMap = new NodeMap(deliveryNode).getAsNodeMap("DeliveryLocation").get();
|
||||
|
||||
if (nodeMap != null) {
|
||||
nodeMap.getNode("ID").ifPresent(s -> {
|
||||
SchemedID sID = new SchemedID().setScheme(s.getAttributes().getNamedItem("schemeID").getTextContent()).setId(s.getTextContent());
|
||||
delivery.addGlobalID(sID);
|
||||
});
|
||||
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
|
||||
s.getAsString("StreetName").ifPresent(t -> delivery.setStreet(t));
|
||||
});
|
||||
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
|
||||
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
|
||||
});
|
||||
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
|
||||
s.getAsString("CityName").ifPresent(t -> delivery.setLocation(t));
|
||||
});
|
||||
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
|
||||
s.getAsString("PostalZone").ifPresent(t -> delivery.setZIP(t));
|
||||
});
|
||||
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
|
||||
s.getAsNodeMap("Country").ifPresent(t -> t.getAsString("IdentificationCode").ifPresent(u -> delivery.setCountry(u)));
|
||||
});
|
||||
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
|
||||
s.getAsNodeMap("AddressLine").ifPresent(t -> t.getAsString("Line").ifPresent(u -> delivery.setAdditionalAddressExtension(u)));
|
||||
});
|
||||
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
|
||||
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
|
||||
});
|
||||
nodeMap.getAsNodeMap("Address").ifPresent(s -> {
|
||||
s.getAsString("AdditionalStreetName").ifPresent(t -> delivery.setAdditionalAddress(t));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
NodeMap partyMap = new NodeMap(deliveryNode).getAsNodeMap("DeliveryParty").get();
|
||||
if (partyMap!=null) {
|
||||
partyMap.getAsNodeMap("PartyName").ifPresent(s->{s.getAsString("Name").ifPresent(t->delivery.setName(t));});
|
||||
}
|
||||
String street, name, additionalStreet, city, postal, countrySubentity, line, country = null;
|
||||
/*
|
||||
String idx = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"ID\"]");
|
||||
street = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name()=\"Address\"]/*[local-name()=\"StreetName\"]");
|
||||
additionalStreet = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"Address\"]/*[local-name() = \"AdditionalStreetName\"]");
|
||||
city = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"Address\"]/*[local-name() = \"CityName\"]");
|
||||
postal = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"Address\"]/*[local-name() = \"PostalZone\"]");
|
||||
countrySubentity = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"Address\"]/*[local-name() = \"CountrySubentity\"]");
|
||||
line = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"Address\"]//*[local-name() = \"AddressLine\"]/*[local-name() = \"Line\"]");
|
||||
country = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"Address\"]//*[local-name() = \"Country\"]/*[local-name() = \"IdentificationCode\"]");
|
||||
name = extractString("//*[local-name()=\"DeliveryLocation\"]/*[local-name() = \"DeliveryParty\"]//*[local-name() = \"PartyName\"]/*[local-name() = \"Name\"]");
|
||||
*/
|
||||
zpp.setDeliveryAddress(delivery);
|
||||
/*
|
||||
zpp.setDeliveryAddress(new TradeParty()
|
||||
.setStreet(street)
|
||||
.setAdditionalAddress(additionalStreet)
|
||||
.setLocation(city)
|
||||
.setZIP(postal)
|
||||
.setAdditionalAddressExtension(line)
|
||||
.setCountry(country)
|
||||
.setName(name)
|
||||
);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
xpr = xpath.compile("//*[local-name()=\"BuyerTradeParty\"]|//*[local-name()=\"AccountingCustomerParty\"]/*");
|
||||
NodeList BuyerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||
|
||||
xpr = xpath.compile("//*[local-name()=\"PayeeTradeParty\"]|//*[local-name()=\"PayeeParty\"]/*");
|
||||
xpr = xpath.compile("//*[local-name()=\"PayeeTradeParty\"]|//*[local-name()=\"PayeeParty\"]//*");
|
||||
NodeList payeeNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||
|
||||
xpr = xpath.compile("//*[local-name()=\"ExchangedDocument\"]|//*[local-name()=\"HeaderExchangedDocument\"]");
|
||||
@@ -408,7 +484,7 @@ public class ZUGFeRDInvoiceImporter {
|
||||
deliveryDate = new SimpleDateFormat("yyyy-MM-dd").parse(deliveryDt);
|
||||
}
|
||||
}
|
||||
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeDelivery\"]");
|
||||
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeDelivery\"]|//*[local-name()=\"Delivery\"]");
|
||||
NodeList headerTradeDeliveryNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||
|
||||
for (int i = 0; i < headerTradeDeliveryNodes.getLength(); i++) {
|
||||
@@ -480,7 +556,7 @@ public class ZUGFeRDInvoiceImporter {
|
||||
}
|
||||
|
||||
|
||||
String currency = extractString("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]/*[local-name()=\"InvoiceCurrencyCode\"]|//*[local-name()=\"DocumentCurrencyCode\"]") ;
|
||||
String currency = extractString("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]/*[local-name()=\"InvoiceCurrencyCode\"]|//*[local-name()=\"DocumentCurrencyCode\"]");
|
||||
zpp.setCurrency(currency);
|
||||
|
||||
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]|//*[local-name()=\"ApplicableSupplyChainTradeSettlement\"]");
|
||||
@@ -599,7 +675,21 @@ public class ZUGFeRDInvoiceImporter {
|
||||
}
|
||||
}
|
||||
}
|
||||
// if ((paymentMeansChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds.item(paymentTermChildIndex).getLocalName().equals("DirectDebitMandateID"))) {
|
||||
// directDebitMandateID = paymentTermChilds.item(paymentTermChildIndex).getTextContent();
|
||||
// }
|
||||
if((paymentMeansChilds.item(meansChildIndex).getLocalName() != null)
|
||||
&& (paymentMeansChilds.item(meansChildIndex).getLocalName().equals("PaymentMandate"))){
|
||||
NodeList paymentMandateChilds = paymentMeansChilds.item(meansChildIndex).getChildNodes();
|
||||
for (int paymentMandateChildIndex = 0; paymentMandateChildIndex < paymentMandateChilds.getLength(); paymentMandateChildIndex++) {
|
||||
if ((paymentMandateChilds.item(paymentMandateChildIndex).getLocalName() != null) && (paymentMandateChilds.item(paymentMandateChildIndex).getLocalName().equals("ID"))) {
|
||||
directDebitMandateID = paymentMandateChilds.item(paymentMandateChildIndex).getTextContent();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
zpp.setDueDate(dueDate).setDeliveryDate(deliveryDate).setIssueDate(issueDate).setSender(new TradeParty(SellerNodes)).setRecipient(new TradeParty(BuyerNodes)).setNumber(number).setDocumentCode(typeCode);
|
||||
@@ -617,15 +707,18 @@ public class ZUGFeRDInvoiceImporter {
|
||||
|
||||
if (buyerOrderIssuerAssignedID != null) {
|
||||
zpp.setBuyerOrderReferencedDocumentID(buyerOrderIssuerAssignedID);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
zpp.setBuyerOrderReferencedDocumentID(extractString("//*[local-name()=\"OrderReference\"]/*[local-name()=\"ID\"]"));
|
||||
}
|
||||
if (sellerOrderIssuerAssignedID != null) {
|
||||
zpp.setSellerOrderReferencedDocumentID(sellerOrderIssuerAssignedID);
|
||||
} else {
|
||||
zpp.setSellerOrderReferencedDocumentID(extractString("//*[local-name()=\"OrderReference\"]/*[local-name()=\"SalesOrderID\"]"));
|
||||
}
|
||||
if (despatchAdviceReferencedDocument != null) {
|
||||
zpp.setDespatchAdviceReferencedDocumentID(despatchAdviceReferencedDocument);
|
||||
} else {
|
||||
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());
|
||||
@@ -671,7 +764,7 @@ public class ZUGFeRDInvoiceImporter {
|
||||
// be read,
|
||||
// so the invoice remains arithmetically correct
|
||||
// -> parse document level charges+allowances
|
||||
xpr = xpath.compile("//*[local-name()=\"SpecifiedTradeAllowanceCharge\"]");
|
||||
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();
|
||||
@@ -685,24 +778,34 @@ public class ZUGFeRDInvoiceImporter {
|
||||
if (chargeChildName != null) {
|
||||
|
||||
if (chargeChildName.equals("ChargeIndicator")) {
|
||||
NodeList indicatorChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
|
||||
for (int indicatorChildIndex = 0; indicatorChildIndex < indicatorChilds.getLength(); indicatorChildIndex++) {
|
||||
if ((indicatorChilds.item(indicatorChildIndex).getLocalName() != null)
|
||||
&& (indicatorChilds.item(indicatorChildIndex).getLocalName().equals("Indicator"))) {
|
||||
isCharge = XMLTools.trimOrNull(indicatorChilds.item(indicatorChildIndex)).equalsIgnoreCase("true");
|
||||
if (chargeNodeChilds.item(chargeChildIndex).getTextContent().trim().equalsIgnoreCase("false")) {
|
||||
// UBL
|
||||
isCharge = false;
|
||||
} else if (chargeNodeChilds.item(chargeChildIndex).getTextContent().trim().equalsIgnoreCase("true")) {
|
||||
// still UBL
|
||||
isCharge = true;
|
||||
} else {
|
||||
//CII
|
||||
NodeList indicatorChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
|
||||
for (int indicatorChildIndex = 0; indicatorChildIndex < indicatorChilds.getLength(); indicatorChildIndex++) {
|
||||
if ((indicatorChilds.item(indicatorChildIndex).getLocalName() != null)
|
||||
&& (indicatorChilds.item(indicatorChildIndex).getLocalName().equals("Indicator"))) {
|
||||
isCharge = XMLTools.trimOrNull(indicatorChilds.item(indicatorChildIndex)).equalsIgnoreCase("true");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (chargeChildName.equals("ActualAmount")) {
|
||||
|
||||
} else if (chargeChildName.equals("ActualAmount") || chargeChildName.equals("Amount")) {
|
||||
chargeAmount = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex));
|
||||
} else if (chargeChildName.equals("Reason")) {
|
||||
} else if (chargeChildName.equals("Reason") || chargeChildName.equals("AllowanceChargeReason")) {
|
||||
reason = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex));
|
||||
} else if (chargeChildName.equals("ReasonCode")) {
|
||||
} else if (chargeChildName.equals("ReasonCode") || chargeChildName.equals("AllowanceChargeReasonCode")) {
|
||||
reasonCode = XMLTools.trimOrNull(chargeNodeChilds.item(chargeChildIndex));
|
||||
} else if (chargeChildName.equals("CategoryTradeTax")) {
|
||||
} else if (chargeChildName.equals("CategoryTradeTax")||chargeChildName.equals("TaxCategory")) {
|
||||
NodeList taxChilds = chargeNodeChilds.item(chargeChildIndex).getChildNodes();
|
||||
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
|
||||
String taxItemName = taxChilds.item(taxChildIndex).getLocalName();
|
||||
if ((taxItemName != null) && (taxItemName.equals("RateApplicablePercent") || taxItemName.equals("ApplicablePercent"))) {
|
||||
if ((taxItemName != null) && (taxItemName.equals("RateApplicablePercent") || taxItemName.equals("ApplicablePercent") || taxItemName.equals("Percent"))) {
|
||||
taxPercent = XMLTools.trimOrNull(taxChilds.item(taxChildIndex));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user