also import deliveryaddress
This commit is contained in:
@@ -52,6 +52,7 @@ import org.xml.sax.SAXException;
|
|||||||
|
|
||||||
public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter {
|
public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ZUGFeRDImporter.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ZUGFeRDImporter.class);
|
||||||
|
|
||||||
public ZUGFeRDImporter() {
|
public ZUGFeRDImporter() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -65,8 +66,6 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Wrapper for protected method extractString
|
* Wrapper for protected method extractString
|
||||||
* @param xpathStr the xpath expression to be evaluated
|
* @param xpathStr the xpath expression to be evaluated
|
||||||
@@ -77,7 +76,6 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -221,7 +219,16 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter {
|
|||||||
* @return the BuyerTradeParty SpecifiedTaxRegistration ID
|
* @return the BuyerTradeParty SpecifiedTaxRegistration ID
|
||||||
*/
|
*/
|
||||||
public String getBuyertradePartySpecifiedTaxRegistrationID() {
|
public String getBuyertradePartySpecifiedTaxRegistrationID() {
|
||||||
return importedInvoice.getRecipient().getLegalOrganisation().getID();
|
String id = null;
|
||||||
|
if ((importedInvoice.getRecipient()!=null) && (importedInvoice.getRecipient().getLegalOrganisation()!=null)) {
|
||||||
|
// this *should* be the official result
|
||||||
|
id = importedInvoice.getRecipient().getLegalOrganisation().getID();
|
||||||
|
}
|
||||||
|
// but also provide some fallback
|
||||||
|
if (id == null) {
|
||||||
|
id = getBuyerTradePartyID();
|
||||||
|
}
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -421,7 +428,12 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter {
|
|||||||
* @return the BuyerTradeParty ID
|
* @return the BuyerTradeParty ID
|
||||||
*/
|
*/
|
||||||
public String getBuyerTradePartyID() {
|
public String getBuyerTradePartyID() {
|
||||||
return importedInvoice.getRecipient().getID();
|
String id = importedInvoice.getRecipient().getID();
|
||||||
|
if (id == null) {
|
||||||
|
// provide some fallback
|
||||||
|
id = importedInvoice.getRecipient().getVATID();
|
||||||
|
}
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -508,7 +520,6 @@ public class ZUGFeRDImporter extends ZUGFeRDInvoiceImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the raw XML data as extracted from the ZUGFeRD PDF file.
|
* Returns the raw XML data as extracted from the ZUGFeRD PDF file.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -300,6 +300,12 @@ public class ZUGFeRDInvoiceImporter {
|
|||||||
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);
|
||||||
|
XPathExpression shipEx = xpath.compile("//*[local-name()=\"ShipToTradeParty\"]");
|
||||||
|
NodeList deliveryNodes = (NodeList) shipEx.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
if (deliveryNodes!=null) {
|
||||||
|
zpp.setDeliveryAddress(new TradeParty(deliveryNodes));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
|
|
||||||
/** **********************************************************************
|
/**
|
||||||
*
|
* *********************************************************************
|
||||||
|
* <p>
|
||||||
* Copyright 2019 Jochen Staerk
|
* Copyright 2019 Jochen Staerk
|
||||||
*
|
* <p>
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
* of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
*
|
* <p>
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
*
|
* <p>
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
* <p>
|
||||||
*********************************************************************** */
|
* **********************************************************************
|
||||||
|
*/
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -244,7 +246,9 @@ public class ZF2Test extends MustangReaderTestCase {
|
|||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} /**
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* The exporter test bases on @{code
|
* The exporter test bases on @{code
|
||||||
* ./src/test/MustangBeispiel20221026.pdf}, adds
|
* ./src/test/MustangBeispiel20221026.pdf}, adds
|
||||||
* metadata, writes to @{code ./target/testout-*} and then imports to check the
|
* metadata, writes to @{code ./target/testout-*} and then imports to check the
|
||||||
|
|||||||
Reference in New Issue
Block a user