ubl impoter to parse contacts
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
- EN16931 validation 1.3.11 codelists v11 #357
|
- EN16931 validation 1.3.11 codelists v11 #357
|
||||||
- Fonts removed #358
|
- Fonts removed #358
|
||||||
- xrechnungimporter to read from filename, inputstream
|
- xrechnungimporter to read from filename, inputstream
|
||||||
|
- invoice's getSender/getRecipient() now return tradeparty no IZUGFeRDExportableTradeParty
|
||||||
|
- (first) IBAN is now parsed into sender's getBankDetails
|
||||||
- zugferdimporter to accept xml files
|
- zugferdimporter to accept xml files
|
||||||
|
- UBL importer to also parse contacts
|
||||||
|
|
||||||
2.10.0
|
2.10.0
|
||||||
=======
|
=======
|
||||||
|
|||||||
@@ -455,7 +455,7 @@ public class Invoice implements IExportableTransaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDExportableTradeParty getSender() {
|
public TradeParty getSender() {
|
||||||
return sender;
|
return sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,7 +473,7 @@ public class Invoice implements IExportableTransaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IZUGFeRDExportableTradeParty getRecipient() {
|
public TradeParty getRecipient() {
|
||||||
return recipient;
|
return recipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,154 +65,159 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
|
for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
|
||||||
//nodes.item(i).getTextContent())) {
|
//nodes.item(i).getTextContent())) {
|
||||||
Node currentItemNode = nodes.item(nodeIndex);
|
Node currentItemNode = nodes.item(nodeIndex);
|
||||||
NodeList itemChilds = currentItemNode.getChildNodes();
|
|
||||||
for (int itemChildIndex = 0; itemChildIndex < itemChilds.getLength(); itemChildIndex++) {
|
|
||||||
if (itemChilds.item(itemChildIndex).getLocalName() != null) {
|
|
||||||
|
|
||||||
if (itemChilds.item(itemChildIndex).getLocalName().equals("Party")) {
|
if (nodes.item(nodeIndex).getLocalName() != null) {
|
||||||
|
String debcurrentChild = nodes.item(nodeIndex).getLocalName();
|
||||||
|
if (nodes.item(nodeIndex).getLocalName().equals("Party")) {
|
||||||
|
|
||||||
NodeList party = itemChilds.item(itemChildIndex).getChildNodes();
|
NodeList party = nodes.item(nodeIndex).getChildNodes();
|
||||||
for (int partyIndex = 0; partyIndex < party.getLength(); partyIndex++) {
|
for (int partyIndex = 0; partyIndex < party.getLength(); partyIndex++) {
|
||||||
if (party.item(partyIndex).getLocalName() != null) {
|
if (party.item(partyIndex).getLocalName() != null) {
|
||||||
|
String debCN = party.item(partyIndex).getLocalName();
|
||||||
|
if (party.item(partyIndex).getLocalName().equals("PartyName")) {
|
||||||
|
|
||||||
if (party.item(partyIndex).getLocalName().equals("PartyName")) {
|
NodeList partyName = party.item(partyIndex).getChildNodes();
|
||||||
|
for (int partyNameIndex = 0; partyNameIndex < partyName.getLength(); partyNameIndex++) {
|
||||||
NodeList partyName = party.item(partyIndex).getChildNodes();
|
if (partyName.item(partyNameIndex).getLocalName() != null) {
|
||||||
for (int partyNameIndex = 0; partyNameIndex < partyName.getLength(); partyNameIndex++) {
|
|
||||||
if (partyName.item(partyNameIndex).getLocalName() != null) {
|
|
||||||
|
|
||||||
if (partyName.item(partyNameIndex).getLocalName().equals("Name")) {
|
|
||||||
setName(partyName.item(partyNameIndex).getTextContent());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (partyName.item(partyNameIndex).getLocalName().equals("Name")) {
|
||||||
|
setName(partyName.item(partyNameIndex).getTextContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (party.item(partyIndex).getLocalName().equals("PostalAddress")) {
|
}
|
||||||
|
if (party.item(partyIndex).getLocalName().equals("PostalAddress")) {
|
||||||
|
|
||||||
NodeList postal = party.item(partyIndex).getChildNodes();
|
NodeList postal = party.item(partyIndex).getChildNodes();
|
||||||
for (int postalChildIndex = 0; postalChildIndex < postal.getLength(); postalChildIndex++) {
|
for (int postalChildIndex = 0; postalChildIndex < postal.getLength(); postalChildIndex++) {
|
||||||
if (postal.item(postalChildIndex).getLocalName() != null) {
|
if (postal.item(postalChildIndex).getLocalName() != null) {
|
||||||
|
|
||||||
if (postal.item(postalChildIndex).getLocalName().equals("StreetName")) {
|
if (postal.item(postalChildIndex).getLocalName().equals("StreetName")) {
|
||||||
setStreet(postal.item(postalChildIndex).getTextContent());
|
setStreet(postal.item(postalChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
if (postal.item(postalChildIndex).getLocalName().equals("AdditionalStreetName")) {
|
if (postal.item(postalChildIndex).getLocalName().equals("AdditionalStreetName")) {
|
||||||
setAdditionalAddress(postal.item(postalChildIndex).getTextContent());
|
setAdditionalAddress(postal.item(postalChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
//unknow correspondence if (postal.item(postalChildIndex).getLocalName().equals("LineThree")) {
|
//unknow correspondence if (postal.item(postalChildIndex).getLocalName().equals("LineThree")) {
|
||||||
|
|
||||||
|
|
||||||
if (postal.item(postalChildIndex).getLocalName().equals("CityName")) {
|
if (postal.item(postalChildIndex).getLocalName().equals("CityName")) {
|
||||||
setLocation(postal.item(postalChildIndex).getTextContent());
|
setLocation(postal.item(postalChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
if (postal.item(postalChildIndex).getLocalName().equals("PostalZone")) {
|
if (postal.item(postalChildIndex).getLocalName().equals("PostalZone")) {
|
||||||
setZIP(postal.item(postalChildIndex).getTextContent());
|
setZIP(postal.item(postalChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
if (postal.item(postalChildIndex).getLocalName().equals("Country")) {
|
if (postal.item(postalChildIndex).getLocalName().equals("Country")) {
|
||||||
NodeList country = postal.item(postalChildIndex).getChildNodes();
|
NodeList country = postal.item(postalChildIndex).getChildNodes();
|
||||||
for (int countryIndex = 0; countryIndex < country.getLength(); countryIndex++) {
|
for (int countryIndex = 0; countryIndex < country.getLength(); countryIndex++) {
|
||||||
if (country.item(countryIndex).getLocalName() != null) {
|
if (country.item(countryIndex).getLocalName() != null) {
|
||||||
|
|
||||||
if (country.item(countryIndex).getLocalName().equals("IdentificationCode")) {
|
|
||||||
setCountry(country.item(countryIndex).getTextContent());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (country.item(countryIndex).getLocalName().equals("IdentificationCode")) {
|
||||||
|
setCountry(country.item(countryIndex).getTextContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (postal.item(postalChildIndex).getLocalName().equals("AddressLine")) {
|
|
||||||
NodeList AddressLine = postal.item(postalChildIndex).getChildNodes();
|
|
||||||
for (int lineIndex = 0; lineIndex < AddressLine.getLength(); lineIndex++) {
|
|
||||||
if (AddressLine.item(lineIndex).getLocalName() != null) {
|
|
||||||
|
|
||||||
if (AddressLine.item(lineIndex).getLocalName().equals("Line")) {
|
}
|
||||||
setAdditionalAddressExtension(AddressLine.item(lineIndex).getTextContent());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (postal.item(postalChildIndex).getLocalName().equals("AddressLine")) {
|
||||||
|
NodeList AddressLine = postal.item(postalChildIndex).getChildNodes();
|
||||||
|
for (int lineIndex = 0; lineIndex < AddressLine.getLength(); lineIndex++) {
|
||||||
|
if (AddressLine.item(lineIndex).getLocalName() != null) {
|
||||||
|
|
||||||
|
if (AddressLine.item(lineIndex).getLocalName().equals("Line")) {
|
||||||
|
setAdditionalAddressExtension(AddressLine.item(lineIndex).getTextContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
if (postal.item(postalChildIndex).getLocalName().equals("Name")) {
|
|
||||||
setName(postal.item(postalChildIndex).getTextContent());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (postal.item(postalChildIndex).getLocalName().equals("Name")) {
|
||||||
|
setName(postal.item(postalChildIndex).getTextContent());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if (party.item(partyIndex).getLocalName().equals("Contact")) {
|
||||||
}
|
NodeList contact = party.item(partyIndex).getChildNodes();
|
||||||
|
setContact(new Contact(contact));
|
||||||
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")) {
|
|
||||||
NodeList contact = itemChilds.item(itemChildIndex).getChildNodes();
|
|
||||||
setContact(new Contact(contact));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemChilds.item(itemChildIndex).getLocalName().equals("PostalTradeAddress")) {
|
|
||||||
NodeList postal = itemChilds.item(itemChildIndex).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 (itemChilds.item(itemChildIndex).getLocalName().equals("SpecifiedTaxRegistration")) {
|
|
||||||
NodeList taxChilds = itemChilds.item(itemChildIndex).getChildNodes();
|
}
|
||||||
for (int taxChildIndex = 0; taxChildIndex < taxChilds.getLength(); taxChildIndex++) {
|
|
||||||
if (taxChilds.item(taxChildIndex).getLocalName() != null) {
|
if (nodes.item(nodeIndex).getLocalName().equals("GlobalID")) {
|
||||||
if ((taxChilds.item(taxChildIndex).getLocalName().equals("ID"))) {
|
if (nodes.item(nodeIndex).getAttributes().getNamedItem("schemeID") != null) {
|
||||||
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID") != null) {
|
SchemedID gid = new SchemedID().setScheme(nodes.item(nodeIndex).getAttributes().getNamedItem("schemeID").getNodeValue()).setId(nodes.item(nodeIndex).getTextContent());
|
||||||
Node firstChild = taxChilds.item(taxChildIndex).getFirstChild();
|
addGlobalID(gid);
|
||||||
if (firstChild != null) {
|
}
|
||||||
if (taxChilds.item(taxChildIndex).getAttributes()
|
|
||||||
.getNamedItem("schemeID").getNodeValue().equals("VA")) {
|
}
|
||||||
setVATID(firstChild.getNodeValue());
|
if (nodes.item(nodeIndex).getLocalName().equals("DefinedTradeContact")) {
|
||||||
}
|
NodeList contact = nodes.item(nodeIndex).getChildNodes();
|
||||||
if (taxChilds.item(taxChildIndex).getAttributes()
|
setContact(new Contact(contact));
|
||||||
.getNamedItem("schemeID").getNodeValue().equals("FC")) {
|
}
|
||||||
setTaxID(firstChild.getNodeValue());
|
|
||||||
}
|
if (nodes.item(nodeIndex).getLocalName().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 (nodes.item(nodeIndex).getLocalName().equals("SpecifiedTaxRegistration")) {
|
||||||
|
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("ID"))) {
|
||||||
|
if (taxChilds.item(taxChildIndex).getAttributes().getNamedItem("schemeID") != null) {
|
||||||
|
Node firstChild = taxChilds.item(taxChildIndex).getFirstChild();
|
||||||
|
if (firstChild != null) {
|
||||||
|
if (taxChilds.item(taxChildIndex).getAttributes()
|
||||||
|
.getNamedItem("schemeID").getNodeValue().equals("VA")) {
|
||||||
|
setVATID(firstChild.getNodeValue());
|
||||||
|
}
|
||||||
|
if (taxChilds.item(taxChildIndex).getAttributes()
|
||||||
|
.getNamedItem("schemeID").getNodeValue().equals("FC")) {
|
||||||
|
setTaxID(firstChild.getNodeValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,15 +289,16 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
|
|
||||||
for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
|
for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
|
||||||
//nodes.item(i).getTextContent())) {
|
//nodes.item(i).getTextContent())) {
|
||||||
|
String debLN = nodes.item(nodeIndex).getLocalName();
|
||||||
|
if (nodes.item(nodeIndex).getLocalName().equals("Party")) {
|
||||||
|
// take one step back and parse from top
|
||||||
|
parseFromUBL(nodes);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Node currentItemNode = nodes.item(nodeIndex);
|
Node currentItemNode = nodes.item(nodeIndex);
|
||||||
NodeList itemChilds = currentItemNode.getChildNodes();
|
NodeList itemChilds = currentItemNode.getChildNodes();
|
||||||
for (int itemChildIndex = 0; itemChildIndex < itemChilds.getLength(); itemChildIndex++) {
|
for (int itemChildIndex = 0; itemChildIndex < itemChilds.getLength(); itemChildIndex++) {
|
||||||
if (itemChilds.item(itemChildIndex).getLocalName() != null) {
|
if (itemChilds.item(itemChildIndex).getLocalName() != null) {
|
||||||
|
|
||||||
if (itemChilds.item(itemChildIndex).getLocalName().equals("Party")) {
|
|
||||||
parseFromUBL(nodes);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (itemChilds.item(itemChildIndex).getLocalName().equals("Name")) {
|
if (itemChilds.item(itemChildIndex).getLocalName().equals("Name")) {
|
||||||
setName(itemChilds.item(itemChildIndex).getTextContent());
|
setName(itemChilds.item(itemChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
@@ -328,10 +334,8 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
|
|||||||
if (postal.item(postalChildIndex).getLocalName().equals("CountryID")) {
|
if (postal.item(postalChildIndex).getLocalName().equals("CountryID")) {
|
||||||
setCountry(postal.item(postalChildIndex).getTextContent());
|
setCountry(postal.item(postalChildIndex).getTextContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (itemChilds.item(itemChildIndex).getLocalName().equals("URIUniversalCommunication")) {
|
if (itemChilds.item(itemChildIndex).getLocalName().equals("URIUniversalCommunication")) {
|
||||||
NodeList URIchilds = itemChilds.item(itemChildIndex).getChildNodes();
|
NodeList URIchilds = itemChilds.item(itemChildIndex).getChildNodes();
|
||||||
|
|||||||
@@ -16,16 +16,7 @@ import javax.xml.xpath.XPathExpression;
|
|||||||
import javax.xml.xpath.XPathExpressionException;
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
|
|
||||||
import org.mustangproject.Allowance;
|
import org.mustangproject.*;
|
||||||
import org.mustangproject.Charge;
|
|
||||||
import org.mustangproject.EStandard;
|
|
||||||
import org.mustangproject.Invoice;
|
|
||||||
import org.mustangproject.Item;
|
|
||||||
import org.mustangproject.Product;
|
|
||||||
import org.mustangproject.ReferencedDocument;
|
|
||||||
import org.mustangproject.SchemedID;
|
|
||||||
import org.mustangproject.TradeParty;
|
|
||||||
import org.mustangproject.XMLTools;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
@@ -75,10 +66,10 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
*/
|
*/
|
||||||
XPathFactory xpathFact = XPathFactory.newInstance();
|
XPathFactory xpathFact = XPathFactory.newInstance();
|
||||||
XPath xpath = xpathFact.newXPath();
|
XPath xpath = xpathFact.newXPath();
|
||||||
XPathExpression xpr = xpath.compile("//*[local-name()=\"SellerTradeParty\"]|//*[local-name()=\"AccountingSupplierParty\"]");
|
XPathExpression xpr = xpath.compile("//*[local-name()=\"SellerTradeParty\"]|//*[local-name()=\"AccountingSupplierParty\"]/*");
|
||||||
NodeList SellerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList SellerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
|
||||||
xpr = xpath.compile("//*[local-name()=\"BuyerTradeParty\"]|//*[local-name()=\"AccountingCustomerParty\"]");
|
xpr = xpath.compile("//*[local-name()=\"BuyerTradeParty\"]|//*[local-name()=\"AccountingCustomerParty\"]/*");
|
||||||
NodeList BuyerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList BuyerNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
xpr = xpath.compile("//*[local-name()=\"ExchangedDocument\"]|//*[local-name()=\"HeaderExchangedDocument\"]");
|
xpr = xpath.compile("//*[local-name()=\"ExchangedDocument\"]|//*[local-name()=\"HeaderExchangedDocument\"]");
|
||||||
NodeList ExchangedDocumentNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList ExchangedDocumentNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
@@ -118,21 +109,20 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String rootNode=extractString("local-name(/*)");
|
String rootNode = extractString("local-name(/*)");
|
||||||
if (rootNode.equals("Invoice"))
|
if (rootNode.equals("Invoice")) {
|
||||||
{
|
// UBL...
|
||||||
// UBL...
|
|
||||||
number = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"ID\"]").trim();
|
number = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"ID\"]").trim();
|
||||||
issueDate=new SimpleDateFormat("yyyy-MM-dd")
|
issueDate = new SimpleDateFormat("yyyy-MM-dd")
|
||||||
.parse(extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"IssueDate\"]").trim());
|
.parse(extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"IssueDate\"]").trim());
|
||||||
String dueDt=extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"DueDate\"]").trim();
|
String dueDt = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"DueDate\"]").trim();
|
||||||
if (dueDt.length()>0) {
|
if (dueDt.length() > 0) {
|
||||||
dueDate=new SimpleDateFormat("yyyy-MM-dd")
|
dueDate = new SimpleDateFormat("yyyy-MM-dd")
|
||||||
.parse(dueDt);
|
.parse(dueDt);
|
||||||
}
|
}
|
||||||
String deliveryDt=extractString("//*[local-name()=\"Delivery\"]/*[local-name()=\"ActualDeliveryDate\"]").trim();
|
String deliveryDt = extractString("//*[local-name()=\"Delivery\"]/*[local-name()=\"ActualDeliveryDate\"]").trim();
|
||||||
if (deliveryDt.length()>0) {
|
if (deliveryDt.length() > 0) {
|
||||||
deliveryDate=new SimpleDateFormat("yyyy-MM-dd")
|
deliveryDate = new SimpleDateFormat("yyyy-MM-dd")
|
||||||
.parse(deliveryDt);
|
.parse(deliveryDt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,6 +204,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
|
|
||||||
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]|//*[local-name()=\"ApplicableSupplyChainTradeSettlement\"]");
|
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]|//*[local-name()=\"ApplicableSupplyChainTradeSettlement\"]");
|
||||||
NodeList headerTradeSettlementNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList headerTradeSettlementNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
String IBAN = null, BIC = null;
|
||||||
|
|
||||||
for (int i = 0; i < headerTradeSettlementNodes.getLength(); i++) {
|
for (int i = 0; i < headerTradeSettlementNodes.getLength(); i++) {
|
||||||
// nodes.item(i).getTextContent())) {
|
// nodes.item(i).getTextContent())) {
|
||||||
@@ -241,11 +232,75 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((headerTradeSettlementChilds.item(settlementChildIndex).getLocalName() != null)
|
||||||
|
&& (headerTradeSettlementChilds.item(settlementChildIndex).getLocalName()
|
||||||
|
.equals("SpecifiedTradeSettlementPaymentMeans"))) {
|
||||||
|
NodeList paymentMeansChilds = headerTradeSettlementChilds.item(settlementChildIndex).getChildNodes();
|
||||||
|
for (int paymentMeansChildIndex = 0; paymentMeansChildIndex < paymentMeansChilds
|
||||||
|
.getLength(); paymentMeansChildIndex++) {
|
||||||
|
if ((paymentMeansChilds.item(paymentMeansChildIndex).getLocalName() != null) && (paymentMeansChilds
|
||||||
|
.item(paymentMeansChildIndex).getLocalName().equals("PayeePartyCreditorFinancialAccount"))) {
|
||||||
|
NodeList accountChilds = paymentMeansChilds.item(paymentMeansChildIndex).getChildNodes();
|
||||||
|
for (int accountChildIndex = 0; accountChildIndex < accountChilds
|
||||||
|
.getLength(); accountChildIndex++) {
|
||||||
|
if ((accountChilds.item(accountChildIndex).getLocalName() != null) && (accountChilds
|
||||||
|
.item(accountChildIndex).getLocalName().equals("IBANID"))) {//CII
|
||||||
|
IBAN = accountChilds.item(accountChildIndex).getTextContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((paymentMeansChilds.item(paymentMeansChildIndex).getLocalName() != null) && (paymentMeansChilds
|
||||||
|
.item(paymentMeansChildIndex).getLocalName().equals("PayeePartyCreditorFinancialInstitution"))) {
|
||||||
|
NodeList accountChilds = paymentMeansChilds.item(paymentMeansChildIndex).getChildNodes();
|
||||||
|
for (int accountChildIndex = 0; accountChildIndex < accountChilds
|
||||||
|
.getLength(); accountChildIndex++) {
|
||||||
|
if ((accountChilds.item(accountChildIndex).getLocalName() != null) && (accountChilds
|
||||||
|
.item(accountChildIndex).getLocalName().equals("BICID"))) {//CII
|
||||||
|
BIC = accountChilds.item(accountChildIndex).getTextContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xpr = xpath.compile("//*[local-name()=\"PaymentMeans\"]"); //UBL only
|
||||||
|
NodeList paymentMeansNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
|
||||||
|
for (int i = 0; i < paymentMeansNodes.getLength(); i++) {
|
||||||
|
// nodes.item(i).getTextContent())) {
|
||||||
|
Node paymentMeansNode = paymentMeansNodes.item(i);
|
||||||
|
NodeList paymentMeansChilds = paymentMeansNode.getChildNodes();
|
||||||
|
for (int meansChildIndex = 0; meansChildIndex < paymentMeansChilds
|
||||||
|
.getLength(); meansChildIndex++) {
|
||||||
|
if ((paymentMeansChilds.item(meansChildIndex).getLocalName() != null)
|
||||||
|
&& (paymentMeansChilds.item(meansChildIndex).getLocalName()
|
||||||
|
.equals("PayeeFinancialAccount"))) {
|
||||||
|
NodeList paymentTermChilds = paymentMeansChilds.item(meansChildIndex).getChildNodes();
|
||||||
|
for (int paymentTermChildIndex = 0; paymentTermChildIndex < paymentTermChilds
|
||||||
|
.getLength(); paymentTermChildIndex++) {
|
||||||
|
if ((paymentTermChilds.item(paymentTermChildIndex).getLocalName() != null) && (paymentTermChilds
|
||||||
|
.item(paymentTermChildIndex).getLocalName().equals("ID"))) {
|
||||||
|
IBAN = paymentTermChilds.item(paymentTermChildIndex).getTextContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zpp.setDueDate(dueDate).setDeliveryDate(deliveryDate).setIssueDate(issueDate)
|
zpp.setDueDate(dueDate).setDeliveryDate(deliveryDate).setIssueDate(issueDate)
|
||||||
.setSender(new TradeParty(SellerNodes)).setRecipient(new TradeParty(BuyerNodes)).setNumber(number);
|
.setSender(new TradeParty(SellerNodes)).setRecipient(new TradeParty(BuyerNodes)).setNumber(number);
|
||||||
|
if (IBAN != null) {
|
||||||
|
BankDetails bd = new BankDetails(IBAN);
|
||||||
|
if (BIC != null) {
|
||||||
|
bd.setBIC(BIC);
|
||||||
|
}
|
||||||
|
zpp.getSender().addBankDetails(bd);
|
||||||
|
}
|
||||||
|
|
||||||
if (buyerOrderIssuerAssignedID != null) {
|
if (buyerOrderIssuerAssignedID != null) {
|
||||||
zpp.setBuyerOrderReferencedDocumentID(buyerOrderIssuerAssignedID);
|
zpp.setBuyerOrderReferencedDocumentID(buyerOrderIssuerAssignedID);
|
||||||
}
|
}
|
||||||
@@ -269,8 +324,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
|
|||||||
xpr = xpath.compile("//*[local-name()=\"IncludedSupplyChainTradeLineItem\"]|//*[local-name()=\"InvoiceLine\"]");
|
xpr = xpath.compile("//*[local-name()=\"IncludedSupplyChainTradeLineItem\"]|//*[local-name()=\"InvoiceLine\"]");
|
||||||
NodeList nodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
NodeList nodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
|
||||||
if (nodes.getLength() == 0) {
|
if (nodes.getLength() != 0) {
|
||||||
} else {
|
|
||||||
for (int i = 0; i < nodes.getLength(); i++) {
|
for (int i = 0; i < nodes.getLength(); i++) {
|
||||||
|
|
||||||
Node currentItemNode = nodes.item(i);
|
Node currentItemNode = nodes.item(i);
|
||||||
|
|||||||
@@ -21,12 +21,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.mustangproject.*;
|
import org.mustangproject.*;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
@@ -54,6 +57,7 @@ public class ZF2PushTest extends TestCase {
|
|||||||
final String TARGET_CHARGESALLOWANCESPDF = "./target/testout-ZF2PushChargesAllowances.pdf";
|
final String TARGET_CHARGESALLOWANCESPDF = "./target/testout-ZF2PushChargesAllowances.pdf";
|
||||||
final String TARGET_RELATIVECHARGESALLOWANCESPDF = "./target/testout-ZF2PushRelativeChargesAllowances.pdf";
|
final String TARGET_RELATIVECHARGESALLOWANCESPDF = "./target/testout-ZF2PushRelativeChargesAllowances.pdf";
|
||||||
final String TARGET_ATTACHMENTSPDF = "./target/testout-ZF2PushAttachments.pdf";
|
final String TARGET_ATTACHMENTSPDF = "./target/testout-ZF2PushAttachments.pdf";
|
||||||
|
final String TARGET_BANKPDF = "./target/testout-ZF2PushBank.pdf";
|
||||||
final String TARGET_PUSHEDGE = "./target/testout-ZF2PushEdge.pdf";
|
final String TARGET_PUSHEDGE = "./target/testout-ZF2PushEdge.pdf";
|
||||||
final String TARGET_INTRACOMMUNITYSUPPLYPDF = "./target/testout-ZF2PushIntraCommunitySupply.pdf";
|
final String TARGET_INTRACOMMUNITYSUPPLYPDF = "./target/testout-ZF2PushIntraCommunitySupply.pdf";
|
||||||
final String TARGET_REVERSECHARGEPDF = "./target/testout-ZF2PushReverseCharge.pdf";
|
final String TARGET_REVERSECHARGEPDF = "./target/testout-ZF2PushReverseCharge.pdf";
|
||||||
@@ -122,11 +126,11 @@ public class ZF2PushTest extends TestCase {
|
|||||||
String taxID = "9990815";
|
String taxID = "9990815";
|
||||||
BigDecimal price = new BigDecimal(priceStr);
|
BigDecimal price = new BigDecimal(priceStr);
|
||||||
try (InputStream SOURCE_PDF = this.getClass()
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
||||||
|
|
||||||
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
||||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||||
.load(SOURCE_PDF)) {
|
.load(SOURCE_PDF)) {
|
||||||
|
|
||||||
byte[] b = {12, 13};
|
byte[] b = {12, 13};
|
||||||
ze.attachFile("one.pdf", b, "application/pdf", "Alternative");
|
ze.attachFile("one.pdf", b, "application/pdf", "Alternative");
|
||||||
@@ -158,6 +162,44 @@ public class ZF2PushTest extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public void testBankTransferExport() {
|
||||||
|
|
||||||
|
String orgname = "Test company";
|
||||||
|
String number = "123";
|
||||||
|
String priceStr = "1.00";
|
||||||
|
String taxID = "9990815";
|
||||||
|
BigDecimal price = new BigDecimal(priceStr);
|
||||||
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
|
||||||
|
|
||||||
|
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
|
||||||
|
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
|
||||||
|
.load(SOURCE_PDF)) {
|
||||||
|
|
||||||
|
String IBAN="DE999888777";
|
||||||
|
String BIC="COBADEFXXX";
|
||||||
|
BankDetails bd=new BankDetails(IBAN, BIC);
|
||||||
|
ze.setTransaction(new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date()).setSender(new TradeParty(orgname, "teststr", "55232", "teststadt", "DE").addBankDetails(bd).addTaxID(taxID)).setOwnVATID("DE0815").setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE").addVATID("DE4711").setContact(new Contact("Franz Müller", "01779999999", "franz@mueller.de", "teststr. 12", "55232", "Entenhausen", "DE"))).setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), price, new BigDecimal(1.0)))
|
||||||
|
|
||||||
|
);
|
||||||
|
String theXML = new String(ze.getProvider().getXML());
|
||||||
|
Invoice read=new Invoice();
|
||||||
|
ZUGFeRDInvoiceImporter zii=new ZUGFeRDInvoiceImporter(new ByteArrayInputStream(theXML.getBytes(StandardCharsets.UTF_8)));
|
||||||
|
zii.extractInto(read);
|
||||||
|
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||||
|
|
||||||
|
//assertEquals(IBAN,read.getSender().getBankDetails().get(0).getIBAN());
|
||||||
|
ze.export(TARGET_BANKPDF);
|
||||||
|
} catch (IOException e) {
|
||||||
|
fail("IOException should not be raised in testEdgeExport");
|
||||||
|
} catch (XPathExpressionException e) {
|
||||||
|
fail("XPathException should not be raised in testEdgeExport");
|
||||||
|
} catch (ParseException e) {
|
||||||
|
fail("ParseException should not be raised in testEdgeExport");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testItemChargesAllowancesExport() {
|
public void testItemChargesAllowancesExport() {
|
||||||
|
|||||||
@@ -193,8 +193,7 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
|
|||||||
assertEquals("04011000-12345-03", invoice.getReferenceNumber());
|
assertEquals("04011000-12345-03", invoice.getReferenceNumber());
|
||||||
assertEquals("seller@email.de", invoice.getSender().getContact().getEMail());
|
assertEquals("seller@email.de", invoice.getSender().getContact().getEMail());
|
||||||
assertEquals("12345", invoice.getRecipient().getZIP());
|
assertEquals("12345", invoice.getRecipient().getZIP());
|
||||||
invoice.getPaymentTerms().get
|
assertEquals("DE75512108001245126199", invoice.getSender().getBankDetails().get(0).getIBAN());
|
||||||
assertEquals("DE75512108001245126199", invoice.getDeliveryAddress().getBankDetails().getIBAN());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user