Implemented method "getSellerTradePartyAddress" to ZUGFeRDImporter.java which gets an instance of PostalTradeAddress.
Removed method "getISODate" from last Commit due lack of implementation - will be implemented at a later time. Also Added Tests for "getSellerTradePartyAddress" to match ZF1 and ZF2
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
public interface IZUGFeRDExportablePostalTradeAddress {
|
||||||
|
default String getPostcodeCode(){return null;}
|
||||||
|
default String getLineOne() {return null;}
|
||||||
|
default String getLineTwo() {return null;}
|
||||||
|
default String getLineThree() {return null;}
|
||||||
|
default String getCityName() {return null;}
|
||||||
|
default String getCountryID() {return null;}
|
||||||
|
default String getCountrySubDivisionName() {return null;}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
|
public class PostalTradeAddress implements IZUGFeRDExportablePostalTradeAddress {
|
||||||
|
|
||||||
|
private String postCodeCode;
|
||||||
|
private String lineOne;
|
||||||
|
private String lineTwo;
|
||||||
|
private String lineThree;
|
||||||
|
private String cityName;
|
||||||
|
private String countryID;
|
||||||
|
private String CountrySubDivisionName;
|
||||||
|
|
||||||
|
public void setPostCodeCode(String postCodeCode) {
|
||||||
|
this.postCodeCode = postCodeCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLineOne(String lineOne) {
|
||||||
|
this.lineOne = lineOne;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLineTwo(String lineTwo) {
|
||||||
|
this.lineTwo = lineTwo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLineThree(String lineThree) {
|
||||||
|
this.lineThree = lineThree;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCityName(String cityName) {
|
||||||
|
this.cityName = cityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCountryID(String countryID) {
|
||||||
|
this.countryID = countryID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCountrySubDivisionName(String countrySubDivisionName) {
|
||||||
|
CountrySubDivisionName = countrySubDivisionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPostcodeCode() {
|
||||||
|
return this.postCodeCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLineOne() {
|
||||||
|
return this.lineOne;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLineTwo() {
|
||||||
|
return this.lineTwo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLineThree() {
|
||||||
|
return this.lineThree;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCityName() {
|
||||||
|
return this.cityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCountryID() {
|
||||||
|
return this.countryID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCountrySubDivisionName() {
|
||||||
|
return this.CountrySubDivisionName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,9 +30,7 @@ import java.util.logging.Logger;
|
|||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.xpath.XPath;
|
import javax.xml.xpath.*;
|
||||||
import javax.xml.xpath.XPathExpressionException;
|
|
||||||
import javax.xml.xpath.XPathFactory;
|
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary;
|
import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary;
|
||||||
@@ -41,6 +39,8 @@ import org.apache.pdfbox.pdmodel.common.PDNameTreeNode;
|
|||||||
import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification;
|
import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification;
|
||||||
import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile;
|
import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
public class ZUGFeRDImporter {
|
public class ZUGFeRDImporter {
|
||||||
@@ -235,7 +235,7 @@ public class ZUGFeRDImporter {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for protected method
|
* Wrapper for protected method exracteString
|
||||||
* @return the extracted String for the specific path in the document
|
* @return the extracted String for the specific path in the document
|
||||||
*/
|
*/
|
||||||
public String wExtractString(String xpathStr) {
|
public String wExtractString(String xpathStr) {
|
||||||
@@ -243,16 +243,6 @@ public class ZUGFeRDImporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return an ISO XXX coded datetime string
|
|
||||||
*/
|
|
||||||
public String getISOdate(String xpathString) {
|
|
||||||
String date = extractString(xpathString);
|
|
||||||
//do some conversion magic here
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the reference (purpose) the sender specified for this invoice
|
* @return the reference (purpose) the sender specified for this invoice
|
||||||
*/
|
*/
|
||||||
@@ -468,4 +458,73 @@ public class ZUGFeRDImporter {
|
|||||||
return s.hasNext() ? s.next() : "";
|
return s.hasNext() ? s.next() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PostalTradeAddress getSellerTradePartyAddress() {
|
||||||
|
|
||||||
|
NodeList nl = null;
|
||||||
|
PostalTradeAddress address = new PostalTradeAddress();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (getVersion() == 1) {
|
||||||
|
nl = getNodeListByPath("//CrossIndustryDocument//SpecifiedSupplyChainTradeTransaction//ApplicableSupplyChainTradeAgreement//SellerTradeParty//PostalTradeAddress");
|
||||||
|
} else {
|
||||||
|
nl = getNodeListByPath("//CrossIndustryInvoice//SupplyChainTradeTransaction//ApplicableHeaderTradeAgreement//SellerTradeParty//PostalTradeAddress");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nl != null) {
|
||||||
|
for (int i = 0; i < nl.getLength(); i++) {
|
||||||
|
Node n = nl.item(i);
|
||||||
|
NodeList nodes = n.getChildNodes();
|
||||||
|
for (int j = 0; j < nodes.getLength(); j++) {
|
||||||
|
n = nodes.item(j);
|
||||||
|
short nodeType = n.getNodeType();
|
||||||
|
if (nodeType==Node.ELEMENT_NODE){
|
||||||
|
switch (n.getNodeName()) {
|
||||||
|
case "ram:PostcodeCode":
|
||||||
|
address.setPostCodeCode(n.getFirstChild().getNodeValue());
|
||||||
|
break;
|
||||||
|
case "ram:LineOne":
|
||||||
|
address.setLineOne(n.getFirstChild().getNodeValue());
|
||||||
|
break;
|
||||||
|
case "ram:LineTwo":
|
||||||
|
address.setLineTwo(n.getFirstChild().getNodeValue());
|
||||||
|
break;
|
||||||
|
case "ram:LineThree":
|
||||||
|
address.setLineThree(n.getFirstChild().getNodeValue());
|
||||||
|
break;
|
||||||
|
case "ram:CityName":
|
||||||
|
address.setCityName(n.getFirstChild().getNodeValue());
|
||||||
|
break;
|
||||||
|
case "ram:CountryID":
|
||||||
|
address.setCountryID(n.getFirstChild().getNodeValue());
|
||||||
|
break;
|
||||||
|
case "ram:CountrySubDivisionName":
|
||||||
|
address.setCountrySubDivisionName(n.getFirstChild().getNodeValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeList getNodeListByPath(String path) {
|
||||||
|
|
||||||
|
XPathFactory xpathFact = XPathFactory.newInstance();
|
||||||
|
XPath xPath = xpathFact.newXPath();
|
||||||
|
String s = path;
|
||||||
|
|
||||||
|
try {
|
||||||
|
XPathExpression xpr = xPath.compile(s);
|
||||||
|
return (NodeList) xpr.evaluate(getDocument(), XPathConstants.NODESET);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,6 +203,13 @@ public class MustangReaderWriterTest extends MustangReaderTestCase {
|
|||||||
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
||||||
assertEquals(zi.getForeignReference(), "RE-20170509/505");
|
assertEquals(zi.getForeignReference(), "RE-20170509/505");
|
||||||
assertEquals(zi.getBankName(), "Commerzbank");
|
assertEquals(zi.getBankName(), "Commerzbank");
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getCityName(), "Stadthausen");
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getCountryID(), "DE");
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getCountrySubDivisionName(), null);
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getLineOne(), "Ecke 12");
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getLineThree(), null);
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getLineTwo(), null);
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getPostcodeCode(), "12345");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testForeignImport() {
|
public void testForeignImport() {
|
||||||
|
|||||||
@@ -1,226 +1,232 @@
|
|||||||
|
|
||||||
/** **********************************************************************
|
/** **********************************************************************
|
||||||
*
|
*
|
||||||
* Copyright 2019 Jochen Staerk
|
* Copyright 2019 Jochen Staerk
|
||||||
*
|
*
|
||||||
* Use is subject to license terms.
|
* Use is subject to license terms.
|
||||||
*
|
*
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
*********************************************************************** */
|
*********************************************************************** */
|
||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
|
|
||||||
import junit.framework.Test;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
import org.junit.FixMethodOrder;
|
|
||||||
import org.junit.runners.MethodSorters;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
|
||||||
public class ZF2Test extends MustangReaderTestCase {
|
|
||||||
final String TARGET_PDF = "./target/testout-ZF2new.pdf";
|
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
@Override
|
import junit.framework.TestSuite;
|
||||||
public Date getDeliveryDate() {
|
import org.junit.FixMethodOrder;
|
||||||
return new GregorianCalendar(2017, Calendar.MAY, 7).getTime();
|
import org.junit.runners.MethodSorters;
|
||||||
}
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
@Override
|
import java.io.IOException;
|
||||||
public Date getDueDate() {
|
import java.io.InputStream;
|
||||||
return new GregorianCalendar(2017, Calendar.MAY, 30).getTime();
|
import java.math.BigDecimal;
|
||||||
}
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
@Override
|
import java.util.Date;
|
||||||
public Date getIssueDate() {
|
import java.util.GregorianCalendar;
|
||||||
return new GregorianCalendar(2017, Calendar.MAY, 9).getTime();
|
|
||||||
}
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
public class ZF2Test extends MustangReaderTestCase {
|
||||||
@Override
|
final String TARGET_PDF = "./target/testout-ZF2new.pdf";
|
||||||
public String getNumber() {
|
|
||||||
return "RE-20170509/505";
|
|
||||||
}
|
@Override
|
||||||
|
public Date getDeliveryDate() {
|
||||||
@Override
|
return new GregorianCalendar(2017, Calendar.MAY, 7).getTime();
|
||||||
public String getOwnCountry() {
|
}
|
||||||
return "DE";
|
|
||||||
}
|
@Override
|
||||||
|
public Date getDueDate() {
|
||||||
@Override
|
return new GregorianCalendar(2017, Calendar.MAY, 30).getTime();
|
||||||
public String getOwnLocation() {
|
}
|
||||||
return "Stadthausen";
|
|
||||||
}
|
@Override
|
||||||
|
public Date getIssueDate() {
|
||||||
@Override
|
return new GregorianCalendar(2017, Calendar.MAY, 9).getTime();
|
||||||
public String getOwnOrganisationName() {
|
}
|
||||||
return "Bei Spiel GmbH";
|
|
||||||
}
|
@Override
|
||||||
|
public String getNumber() {
|
||||||
@Override
|
return "RE-20170509/505";
|
||||||
public String getOwnStreet() {
|
}
|
||||||
return "Ecke 12";
|
|
||||||
}
|
@Override
|
||||||
|
public String getOwnCountry() {
|
||||||
@Override
|
return "DE";
|
||||||
public IZUGFeRDExportableContact getOwnContact() {
|
}
|
||||||
return new SenderContact();
|
|
||||||
|
@Override
|
||||||
}
|
public String getOwnLocation() {
|
||||||
|
return "Stadthausen";
|
||||||
@Override
|
}
|
||||||
public String getOwnTaxID() {
|
|
||||||
return "22/815/0815/4";
|
@Override
|
||||||
}
|
public String getOwnOrganisationName() {
|
||||||
|
return "Bei Spiel GmbH";
|
||||||
@Override
|
}
|
||||||
public String getOwnVATID() {
|
|
||||||
return "DE136695976";
|
@Override
|
||||||
}
|
public String getOwnStreet() {
|
||||||
|
return "Ecke 12";
|
||||||
@Override
|
}
|
||||||
public String getOwnZIP() {
|
|
||||||
return "12345";
|
@Override
|
||||||
}
|
public IZUGFeRDExportableContact getOwnContact() {
|
||||||
|
return new SenderContact();
|
||||||
@Override
|
|
||||||
public IZUGFeRDExportableContact getRecipient() {
|
}
|
||||||
return new RecipientContact();
|
|
||||||
}
|
@Override
|
||||||
|
public String getOwnTaxID() {
|
||||||
@Override
|
return "22/815/0815/4";
|
||||||
public String getOwnOrganisationFullPlaintextInfo() {
|
}
|
||||||
return null;
|
|
||||||
}
|
@Override
|
||||||
|
public String getOwnVATID() {
|
||||||
@Override
|
return "DE136695976";
|
||||||
public String getCurrency() {
|
}
|
||||||
return "EUR";
|
|
||||||
}
|
@Override
|
||||||
|
public String getOwnZIP() {
|
||||||
@Override
|
return "12345";
|
||||||
public IZUGFeRDExportableItem[] getZFItems() {
|
}
|
||||||
Item[] allItems = new Item[3];
|
|
||||||
Product designProduct = new Product("", "Künstlerische Gestaltung (Stunde): Einer Beispielrechnung", "HUR",
|
@Override
|
||||||
new BigDecimal("7.000000"));
|
public IZUGFeRDExportableContact getRecipient() {
|
||||||
Product balloonProduct = new Product("", "Bestellerweiterung für E&F Umbau", "C62",
|
return new RecipientContact();
|
||||||
new BigDecimal("19.000000"));// test for issue 103
|
}
|
||||||
Product airProduct = new Product("", "Heiße Luft pro Liter", "LTR", new BigDecimal("19.000000"));
|
|
||||||
|
@Override
|
||||||
allItems[0] = new Item(new BigDecimal("160"), new BigDecimal("1"), designProduct);
|
public String getOwnOrganisationFullPlaintextInfo() {
|
||||||
allItems[1] = new Item(new BigDecimal("0.79"), new BigDecimal("400"), balloonProduct);
|
return null;
|
||||||
allItems[2] = new Item(new BigDecimal("0.10"), new BigDecimal("200"), airProduct);
|
}
|
||||||
return allItems;
|
|
||||||
}
|
@Override
|
||||||
|
public String getCurrency() {
|
||||||
@Override
|
return "EUR";
|
||||||
public String getPaymentTermDescription() {
|
}
|
||||||
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
|
||||||
return "Zahlbar ohne Abzug bis zum " + germanDateFormat.format(getDueDate());
|
@Override
|
||||||
}
|
public IZUGFeRDExportableItem[] getZFItems() {
|
||||||
|
Item[] allItems = new Item[3];
|
||||||
@Override
|
Product designProduct = new Product("", "Künstlerische Gestaltung (Stunde): Einer Beispielrechnung", "HUR",
|
||||||
public IZUGFeRDAllowanceCharge[] getZFAllowances() {
|
new BigDecimal("7.000000"));
|
||||||
return null;
|
Product balloonProduct = new Product("", "Bestellerweiterung für E&F Umbau", "C62",
|
||||||
}
|
new BigDecimal("19.000000"));// test for issue 103
|
||||||
|
Product airProduct = new Product("", "Heiße Luft pro Liter", "LTR", new BigDecimal("19.000000"));
|
||||||
@Override
|
|
||||||
public IZUGFeRDAllowanceCharge[] getZFCharges() {
|
allItems[0] = new Item(new BigDecimal("160"), new BigDecimal("1"), designProduct);
|
||||||
return null;
|
allItems[1] = new Item(new BigDecimal("0.79"), new BigDecimal("400"), balloonProduct);
|
||||||
}
|
allItems[2] = new Item(new BigDecimal("0.10"), new BigDecimal("200"), airProduct);
|
||||||
|
return allItems;
|
||||||
@Override
|
}
|
||||||
public IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges() {
|
|
||||||
return null;
|
@Override
|
||||||
}
|
public String getPaymentTermDescription() {
|
||||||
|
SimpleDateFormat germanDateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||||
@Override
|
return "Zahlbar ohne Abzug bis zum " + germanDateFormat.format(getDueDate());
|
||||||
public String getReferenceNumber() {
|
}
|
||||||
return "AB321";
|
|
||||||
}
|
@Override
|
||||||
|
public IZUGFeRDAllowanceCharge[] getZFAllowances() {
|
||||||
/**
|
return null;
|
||||||
* Create the test case
|
}
|
||||||
*
|
|
||||||
* @param testName name of the test case
|
@Override
|
||||||
*/
|
public IZUGFeRDAllowanceCharge[] getZFCharges() {
|
||||||
public ZF2Test(String testName) {
|
return null;
|
||||||
super(testName);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
/**
|
public IZUGFeRDAllowanceCharge[] getZFLogisticsServiceCharges() {
|
||||||
* @return the suite of tests being tested
|
return null;
|
||||||
*/
|
}
|
||||||
public static Test suite() {
|
|
||||||
return new TestSuite(ZF2Test.class);
|
@Override
|
||||||
}
|
public String getReferenceNumber() {
|
||||||
|
return "AB321";
|
||||||
// //////// TESTS
|
}
|
||||||
// //////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
/**
|
||||||
/**
|
* Create the test case
|
||||||
* The exporter test bases on @{code
|
*
|
||||||
* ./src/test/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf}, adds
|
* @param testName name of the test case
|
||||||
* metadata, writes to @{code ./target/testout-*} and then imports to check the
|
*/
|
||||||
* values.
|
public ZF2Test(String testName) {
|
||||||
*/
|
super(testName);
|
||||||
public void testExport() {
|
}
|
||||||
|
|
||||||
// the writing part
|
/**
|
||||||
|
* @return the suite of tests being tested
|
||||||
try (InputStream SOURCE_PDF = this.getClass()
|
*/
|
||||||
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf");
|
public static Test suite() {
|
||||||
|
return new TestSuite(ZF2Test.class);
|
||||||
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA3Factory().setProducer("My Application")
|
}
|
||||||
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.EN16931).ignorePDFAErrors()
|
|
||||||
|
// //////// TESTS
|
||||||
|
// //////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exporter test bases on @{code
|
||||||
|
* ./src/test/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf}, adds
|
||||||
|
* metadata, writes to @{code ./target/testout-*} and then imports to check the
|
||||||
|
* values.
|
||||||
|
*/
|
||||||
|
public void testExport() {
|
||||||
|
|
||||||
|
// the writing part
|
||||||
|
|
||||||
|
try (InputStream SOURCE_PDF = this.getClass()
|
||||||
|
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf");
|
||||||
|
|
||||||
|
ZUGFeRDExporter ze = new ZUGFeRDExporterFromA3Factory().setProducer("My Application")
|
||||||
|
.setCreator(System.getProperty("user.name")).setZUGFeRDVersion(2).setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.EN16931).ignorePDFAErrors()
|
||||||
.load(SOURCE_PDF)) {
|
.load(SOURCE_PDF)) {
|
||||||
|
|
||||||
ze.PDFattachZugferdFile(this);
|
ze.PDFattachZugferdFile(this);
|
||||||
String theXML = new String(ze.getProvider().getXML());
|
String theXML = new String(ze.getProvider().getXML());
|
||||||
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
assertTrue(theXML.contains("<rsm:CrossIndustryInvoice"));
|
||||||
ze.export(TARGET_PDF);
|
ze.export(TARGET_PDF);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail("IOException should not be raised in testEdgeExport");
|
fail("IOException should not be raised in testEdgeExport");
|
||||||
}
|
}
|
||||||
|
|
||||||
// now check the contents (like MustangReaderTest)
|
// now check the contents (like MustangReaderTest)
|
||||||
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
|
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
|
||||||
|
|
||||||
assertTrue(zi.getUTF8().contains("<ram:DueDateDateTime>"));
|
assertTrue(zi.getUTF8().contains("<ram:DueDateDateTime>"));
|
||||||
|
|
||||||
// Reading ZUGFeRD
|
// Reading ZUGFeRD
|
||||||
assertEquals(zi.getAmount(), "571.04");
|
assertEquals(zi.getAmount(), "571.04");
|
||||||
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
||||||
|
|
||||||
assertEquals(zi.getAmount(), "571.04");
|
assertEquals(zi.getAmount(), "571.04");
|
||||||
assertEquals(zi.getBIC(), getTradeSettlementPayment()[0].getOwnBIC());
|
assertEquals(zi.getBIC(), getTradeSettlementPayment()[0].getOwnBIC());
|
||||||
assertEquals(zi.getIBAN(),getTradeSettlementPayment()[0].getOwnIBAN());
|
assertEquals(zi.getIBAN(),getTradeSettlementPayment()[0].getOwnIBAN());
|
||||||
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
assertEquals(zi.getHolder(), getOwnOrganisationName());
|
||||||
assertEquals(zi.getForeignReference(), getNumber());
|
assertEquals(zi.getForeignReference(), getNumber());
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getPostcodeCode(), "12345");
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getLineOne(), "Ecke 12");
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getLineTwo(), null);
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getLineThree(), null);
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getCountrySubDivisionName(), null);
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getCountryID(), "DE");
|
||||||
|
assertEquals(zi.getSellerTradePartyAddress().getCityName(), "Stadthausen");
|
||||||
|
|
||||||
|
try {
|
||||||
try {
|
assertEquals(zi.getVersion(), 2);
|
||||||
assertEquals(zi.getVersion(), 2);
|
} catch (Exception e) {
|
||||||
} catch (Exception e) {
|
// TODO Auto-generated catch block
|
||||||
// TODO Auto-generated catch block
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user