ubl impoter to parse contacts

This commit is contained in:
jstaerk
2024-04-01 08:45:29 +02:00
parent df0eef061f
commit 6cea38f57b
6 changed files with 251 additions and 149 deletions

View File

@@ -1,7 +1,10 @@
- EN16931 validation 1.3.11 codelists v11 #357
- Fonts removed #358
- 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
- UBL importer to also parse contacts
2.10.0
=======

View File

@@ -455,7 +455,7 @@ public class Invoice implements IExportableTransaction {
}
@Override
public IZUGFeRDExportableTradeParty getSender() {
public TradeParty getSender() {
return sender;
}
@@ -473,7 +473,7 @@ public class Invoice implements IExportableTransaction {
}
@Override
public IZUGFeRDExportableTradeParty getRecipient() {
public TradeParty getRecipient() {
return recipient;
}

View File

@@ -65,154 +65,159 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
//nodes.item(i).getTextContent())) {
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();
for (int partyIndex = 0; partyIndex < party.getLength(); partyIndex++) {
if (party.item(partyIndex).getLocalName() != null) {
NodeList party = nodes.item(nodeIndex).getChildNodes();
for (int partyIndex = 0; partyIndex < party.getLength(); partyIndex++) {
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++) {
if (partyName.item(partyNameIndex).getLocalName() != null) {
if (partyName.item(partyNameIndex).getLocalName().equals("Name")) {
setName(partyName.item(partyNameIndex).getTextContent());
}
NodeList partyName = party.item(partyIndex).getChildNodes();
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 (party.item(partyIndex).getLocalName().equals("PostalAddress")) {
}
if (party.item(partyIndex).getLocalName().equals("PostalAddress")) {
NodeList postal = party.item(partyIndex).getChildNodes();
for (int postalChildIndex = 0; postalChildIndex < postal.getLength(); postalChildIndex++) {
if (postal.item(postalChildIndex).getLocalName() != null) {
NodeList postal = party.item(partyIndex).getChildNodes();
for (int postalChildIndex = 0; postalChildIndex < postal.getLength(); postalChildIndex++) {
if (postal.item(postalChildIndex).getLocalName() != null) {
if (postal.item(postalChildIndex).getLocalName().equals("StreetName")) {
setStreet(postal.item(postalChildIndex).getTextContent());
}
if (postal.item(postalChildIndex).getLocalName().equals("AdditionalStreetName")) {
setAdditionalAddress(postal.item(postalChildIndex).getTextContent());
}
//unknow correspondence if (postal.item(postalChildIndex).getLocalName().equals("LineThree")) {
if (postal.item(postalChildIndex).getLocalName().equals("StreetName")) {
setStreet(postal.item(postalChildIndex).getTextContent());
}
if (postal.item(postalChildIndex).getLocalName().equals("AdditionalStreetName")) {
setAdditionalAddress(postal.item(postalChildIndex).getTextContent());
}
//unknow correspondence if (postal.item(postalChildIndex).getLocalName().equals("LineThree")) {
if (postal.item(postalChildIndex).getLocalName().equals("CityName")) {
setLocation(postal.item(postalChildIndex).getTextContent());
}
if (postal.item(postalChildIndex).getLocalName().equals("PostalZone")) {
setZIP(postal.item(postalChildIndex).getTextContent());
}
if (postal.item(postalChildIndex).getLocalName().equals("Country")) {
NodeList country = postal.item(postalChildIndex).getChildNodes();
for (int countryIndex = 0; countryIndex < country.getLength(); countryIndex++) {
if (country.item(countryIndex).getLocalName() != null) {
if (country.item(countryIndex).getLocalName().equals("IdentificationCode")) {
setCountry(country.item(countryIndex).getTextContent());
}
if (postal.item(postalChildIndex).getLocalName().equals("CityName")) {
setLocation(postal.item(postalChildIndex).getTextContent());
}
if (postal.item(postalChildIndex).getLocalName().equals("PostalZone")) {
setZIP(postal.item(postalChildIndex).getTextContent());
}
if (postal.item(postalChildIndex).getLocalName().equals("Country")) {
NodeList country = postal.item(postalChildIndex).getChildNodes();
for (int countryIndex = 0; countryIndex < country.getLength(); countryIndex++) {
if (country.item(countryIndex).getLocalName() != null) {
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 (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 (party.item(partyIndex).getLocalName().equals("Contact")) {
NodeList contact = party.item(partyIndex).getChildNodes();
setContact(new Contact(contact));
}
}
}
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 ((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());
}
}
if (nodes.item(nodeIndex).getLocalName().equals("GlobalID")) {
if (nodes.item(nodeIndex).getAttributes().getNamedItem("schemeID") != null) {
SchemedID gid = new SchemedID().setScheme(nodes.item(nodeIndex).getAttributes().getNamedItem("schemeID").getNodeValue()).setId(nodes.item(nodeIndex).getTextContent());
addGlobalID(gid);
}
}
if (nodes.item(nodeIndex).getLocalName().equals("DefinedTradeContact")) {
NodeList contact = nodes.item(nodeIndex).getChildNodes();
setContact(new Contact(contact));
}
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++) {
//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);
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")) {
parseFromUBL(nodes);
return;
}
if (itemChilds.item(itemChildIndex).getLocalName().equals("Name")) {
setName(itemChilds.item(itemChildIndex).getTextContent());
}
@@ -328,10 +334,8 @@ public class TradeParty implements IZUGFeRDExportableTradeParty {
if (postal.item(postalChildIndex).getLocalName().equals("CountryID")) {
setCountry(postal.item(postalChildIndex).getTextContent());
}
}
}
}
if (itemChilds.item(itemChildIndex).getLocalName().equals("URIUniversalCommunication")) {
NodeList URIchilds = itemChilds.item(itemChildIndex).getChildNodes();

View File

@@ -16,16 +16,7 @@ import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.mustangproject.Allowance;
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.mustangproject.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
@@ -75,10 +66,10 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
*/
XPathFactory xpathFact = XPathFactory.newInstance();
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);
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);
xpr = xpath.compile("//*[local-name()=\"ExchangedDocument\"]|//*[local-name()=\"HeaderExchangedDocument\"]");
NodeList ExchangedDocumentNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
@@ -118,21 +109,20 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
}
}
}
String rootNode=extractString("local-name(/*)");
if (rootNode.equals("Invoice"))
{
// UBL...
String rootNode = extractString("local-name(/*)");
if (rootNode.equals("Invoice")) {
// UBL...
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());
String dueDt=extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"DueDate\"]").trim();
if (dueDt.length()>0) {
dueDate=new SimpleDateFormat("yyyy-MM-dd")
String dueDt = extractString("//*[local-name()=\"Invoice\"]/*[local-name()=\"DueDate\"]").trim();
if (dueDt.length() > 0) {
dueDate = new SimpleDateFormat("yyyy-MM-dd")
.parse(dueDt);
}
String deliveryDt=extractString("//*[local-name()=\"Delivery\"]/*[local-name()=\"ActualDeliveryDate\"]").trim();
if (deliveryDt.length()>0) {
deliveryDate=new SimpleDateFormat("yyyy-MM-dd")
String deliveryDt = extractString("//*[local-name()=\"Delivery\"]/*[local-name()=\"ActualDeliveryDate\"]").trim();
if (deliveryDt.length() > 0) {
deliveryDate = new SimpleDateFormat("yyyy-MM-dd")
.parse(deliveryDt);
}
}
@@ -214,6 +204,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
xpr = xpath.compile("//*[local-name()=\"ApplicableHeaderTradeSettlement\"]|//*[local-name()=\"ApplicableSupplyChainTradeSettlement\"]");
NodeList headerTradeSettlementNodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
String IBAN = null, BIC = null;
for (int i = 0; i < headerTradeSettlementNodes.getLength(); i++) {
// 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)
.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) {
zpp.setBuyerOrderReferencedDocumentID(buyerOrderIssuerAssignedID);
}
@@ -269,8 +324,7 @@ public class ZUGFeRDInvoiceImporter extends ZUGFeRDImporter {
xpr = xpath.compile("//*[local-name()=\"IncludedSupplyChainTradeLineItem\"]|//*[local-name()=\"InvoiceLine\"]");
NodeList nodes = (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
if (nodes.getLength() == 0) {
} else {
if (nodes.getLength() != 0) {
for (int i = 0; i < nodes.getLength(); i++) {
Node currentItemNode = nodes.item(i);

View File

@@ -21,12 +21,15 @@
*/
package org.mustangproject.ZUGFeRD;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.mustangproject.*;
import org.junit.FixMethodOrder;
@@ -54,6 +57,7 @@ public class ZF2PushTest extends TestCase {
final String TARGET_CHARGESALLOWANCESPDF = "./target/testout-ZF2PushChargesAllowances.pdf";
final String TARGET_RELATIVECHARGESALLOWANCESPDF = "./target/testout-ZF2PushRelativeChargesAllowances.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_INTRACOMMUNITYSUPPLYPDF = "./target/testout-ZF2PushIntraCommunitySupply.pdf";
final String TARGET_REVERSECHARGEPDF = "./target/testout-ZF2PushReverseCharge.pdf";
@@ -122,11 +126,11 @@ public class ZF2PushTest extends TestCase {
String taxID = "9990815";
BigDecimal price = new BigDecimal(priceStr);
try (InputStream SOURCE_PDF = this.getClass()
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
ZUGFeRDExporterFromA1 ze = new ZUGFeRDExporterFromA1().setProducer("My Application")
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
.load(SOURCE_PDF)) {
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).ignorePDFAErrors()
.load(SOURCE_PDF)) {
byte[] b = {12, 13};
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() {

View File

@@ -193,8 +193,7 @@ public class ZF2ZInvoiceImporterTest extends ResourceCase {
assertEquals("04011000-12345-03", invoice.getReferenceNumber());
assertEquals("seller@email.de", invoice.getSender().getContact().getEMail());
assertEquals("12345", invoice.getRecipient().getZIP());
invoice.getPaymentTerms().get
assertEquals("DE75512108001245126199", invoice.getDeliveryAddress().getBankDetails().getIBAN());
assertEquals("DE75512108001245126199", invoice.getSender().getBankDetails().get(0).getIBAN());
}