refactoring Importer

This commit is contained in:
Andre Kemper
2019-04-09 23:25:43 +02:00
parent e60105f8b7
commit e2e957a450
4 changed files with 139 additions and 492 deletions

View File

@@ -33,30 +33,22 @@ 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;
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.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.*; import java.io.*;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.logging.Logger;
//root.setNamespace(Namespace.getNamespace("http://www.energystar.gov/manageBldgs/req"));
public class ZUGFeRDImporter { public class ZUGFeRDImporter {
/*
* call extract(importFilename). containsMeta() will return if ZUGFeRD data has
* been found, afterwards you can call getBIC(), getIBAN() etc.
*
*/
/** /**
* @var if metadata has been found * @var if metadata has been found
*/ */
@@ -64,24 +56,12 @@ public class ZUGFeRDImporter {
/** /**
* @var the reference (i.e. invoice number) of the sender * @var the reference (i.e. invoice number) of the sender
*/ */
private String foreignReference; private HashMap<String, byte[]> additionalXMLs = new HashMap<>();
private String BLZ;
private String BIC;
private String IBAN;
private String KTO;
private String holder;
private String amount;
private String dueDate;
private HashMap<String, byte[]> additionalXMLs = new HashMap<String, byte[]>();
/** /**
* Raw XML form of the extracted data - may be directly obtained. * Raw XML form of the extracted data - may be directly obtained.
*/ */
private byte[] rawXML = null; private byte[] rawXML = null;
private String bankName;
private boolean amountFound;
private boolean parsed = false;
private String xmpString = null; // XMP metadata private String xmpString = null; // XMP metadata
private static final Logger LOG = Logger.getLogger(ZUGFeRDImporter.class.getName());
public ZUGFeRDImporter(String pdfFilename) { public ZUGFeRDImporter(String pdfFilename) {
try { try {
@@ -175,189 +155,112 @@ public class ZUGFeRDImporter {
} }
} }
public HashMap<String, byte[]> getAdditionalData() { private void prettyPrint(Document document) throws TransformerException {
return additionalXMLs; TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = null;
try {
transformer = tf.newTransformer();
} catch (TransformerConfigurationException e) {
e.printStackTrace();
}
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
StringWriter writer = new StringWriter();
transformer.transform(new DOMSource(document), new StreamResult(writer));
String output = writer.getBuffer().toString();//.replaceAll("\n|\r", "");
System.err.println(output);
}
private Document getDocument() throws ParserConfigurationException, IOException, SAXException, TransformerException {
DocumentBuilderFactory xmlFact = DocumentBuilderFactory.newInstance();
xmlFact.setNamespaceAware(false);
DocumentBuilder builder = xmlFact.newDocumentBuilder();
Document doc = builder.parse(new ByteArrayInputStream(rawXML));
//prettyPrint(doc);
return doc;
}
private String extractString(String xpathStr) {
if (!containsMeta) {
throw new ZUGFeRDExportException("No suitable data/ZUGFeRD file could be found.");
}
String result;
try {
Document document = getDocument();
XPathFactory xpathFact = XPathFactory.newInstance();
XPath xpath = xpathFact.newXPath();
result = xpath.evaluate(xpathStr, document);
} catch (ParserConfigurationException e) {
e.printStackTrace();
throw new ZUGFeRDExportException(e);
} catch (IOException | SAXException | TransformerException | XPathExpressionException e) {
e.printStackTrace();
throw new ZUGFeRDExportException(e);
}
return result;
} }
/** /**
* needs to be called to be able to call the getters * @return the reference (purpose) the sender specified for this invoice
*/ */
protected void parse() { public String getForeignReference() {
DocumentBuilderFactory factory = null; String result = extractString("//ApplicableHeaderTradeSettlement/PaymentReference");
DocumentBuilder builder = null; if(result == null || result.isEmpty())
Document document = null; result = extractString("//ApplicableSupplyChainTradeSettlement/PaymentReference");
return result;
}
if (!containsMeta) { /**
throw new RuntimeException("No suitable data/ZUGFeRD file could be found."); * @return the sender's bank's BLZ code
} */
public String getBLZ() {
return extractString("//PayeeSpecifiedCreditorFinancialInstitution/GermanBankleitzahlID");
}
factory = DocumentBuilderFactory.newInstance(); /**
factory.setNamespaceAware(true); // otherwise we can not act namespace independently, i.e. use * @return the sender's bank's BIC code
// document.getElementsByTagNameNS("*",... */
try { public String getBIC() {
builder = factory.newDocumentBuilder(); return extractString("//PayeeSpecifiedCreditorFinancialInstitution/BICID");
} catch (ParserConfigurationException ex3) { }
// TODO Auto-generated catch block
ex3.printStackTrace();
}
try { /**
InputStream bais = new ByteArrayInputStream(rawXML); * @return the sender's bankname
document = builder.parse(bais); */
} catch (SAXException ex1) { public String getBankName() {
ex1.printStackTrace(); return extractString("/CrossIndustryInvoice/SupplyChainTradeTransaction/ApplicableHeaderTradeSettlement/SpecifiedTradeSettlementPaymentMeans/PayeeSpecifiedCreditorFinancialInstitution/Name");
} catch (IOException ex2) { }
ex2.printStackTrace();
}
NodeList ndList;
// rootNode = document.getDocumentElement(); public String getIBAN() {
// ApplicableSupplyChainTradeSettlement return extractString("//PayeePartyCreditorFinancialAccount/IBANID");
ndList = document.getDocumentElement().getElementsByTagNameNS("*", "PaymentReference"); //$NON-NLS-1$ }
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) { public String getKTO() {
Node booking = ndList.item(bookingIndex); return extractString("//PayeePartyCreditorFinancialAccount/ProprietaryID");
// if there is a attribute in the tag number:value }
setForeignReference(booking.getTextContent()); public String getHolder() {
return extractString("//SellerTradeParty/Name");
}
} /**
/* * @return the total payable amount
* ndList = document .getElementsByTagName("GermanBankleitzahlID"); */
* //$NON-NLS-1$ public String getAmount() {
* String result = extractString("//SpecifiedTradeSettlementHeaderMonetarySummation/DuePayableAmount");
* for (int bookingIndex = 0; bookingIndex < ndList .getLength(); if(result == null || result.isEmpty())
* bookingIndex++) { Node booking = ndList.item(bookingIndex); // if there is a result = extractString("//SpecifiedTradeSettlementMonetarySummation/GrandTotalAmount");
* attribute in the tag number:value setBIC(booking.getTextContent()); return result;
* }
* }
*
* ndList = document.getElementsByTagName("ProprietaryID"); //$NON-NLS-1$
*
* for (int bookingIndex = 0; bookingIndex < ndList .getLength();
* bookingIndex++) { Node booking = ndList.item(bookingIndex); // if there is a
* attribute in the tag number:value setIBAN(booking.getTextContent());
*
* } <ram:PayeePartyCreditorFinancialAccount> <ram:IBANID>DE1234</ram:IBANID>
* </ram:PayeePartyCreditorFinancialAccount>
* <ram:PayeeSpecifiedCreditorFinancialInstitution>
* <ram:BICID>DE5656565</ram:BICID> <ram:Name>Commerzbank</ram:Name>
* </ram:PayeeSpecifiedCreditorFinancialInstitution>
*
*/
/*** /**
* we should switch to xpath like this // Create XPathFactory object * @return when the payment is due
* XPathFactory xpathFactory = XPathFactory.newInstance(); */
* public String getDueDate() {
* // Create XPath object XPath xpath = xpathFactory.newXPath(); XPathExpression return extractString("//SpecifiedTradePaymentTerms/DueDateDateTime/DateTimeString");
* expr = }
* xpath.compile("//*[local-name()=\"GuidelineSpecifiedDocumentContextParameter\"]/[local-name()=\"ID\"]");
* //evaluate expression result on XML document ndList = (NodeList)
* expr.evaluate(doc, XPathConstants.NODESET);
*
*/
ndList = document.getElementsByTagNameNS("*", "PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$ public HashMap<String, byte[]> getAdditionalData() {
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) { return additionalXMLs;
Node booking = ndList.item(bookingIndex);
// there are many "name" elements, so get the one below
// SellerTradeParty
NodeList bookingDetails = booking.getChildNodes();
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
Node detail = bookingDetails.item(detailIndex);
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("IBANID"))) { //$NON-NLS-1$
setIBAN(detail.getTextContent());
}
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("ProprietaryID"))) { //$NON-NLS-1$
setKTO(detail.getTextContent());
}
}
}
ndList = document.getElementsByTagNameNS("*", "PayeeSpecifiedCreditorFinancialInstitution");// ZF1 //$NON-NLS-1$
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
Node booking = ndList.item(bookingIndex);
// there are many "name" elements, so get the one below
// SellerTradeParty
NodeList bookingDetails = booking.getChildNodes();
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
Node detail = bookingDetails.item(detailIndex);
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("BICID"))) { //$NON-NLS-1$
setBIC(detail.getTextContent());
}
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("GermanBankleitzahlID"))) { //$NON-NLS-1$
setBLZ(detail.getTextContent());
}
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
setBankName(detail.getTextContent());
}
}
}
ndList = document.getElementsByTagNameNS("*", "SellerTradeParty"); //$NON-NLS-1$
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
Node booking = ndList.item(bookingIndex);
// there are many "name" elements, so get the one below
// SellerTradeParty
NodeList bookingDetails = booking.getChildNodes();
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
Node detail = bookingDetails.item(detailIndex);
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
setHolder(detail.getTextContent());
}
}
}
ndList = document.getElementsByTagNameNS("*", "DuePayableAmount"); //$NON-NLS-1$
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
Node booking = ndList.item(bookingIndex);
// if there is a attribute in the tag number:value
amountFound = true;
setAmount(booking.getTextContent());
}
if (!amountFound) {
/*
* there is apparently no requirement to mention DuePayableAmount,, if it's not
* there, check for GrandTotalAmount
*/
ndList = document.getElementsByTagNameNS("*", "GrandTotalAmount"); //$NON-NLS-1$
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
Node booking = ndList.item(bookingIndex);
// if there is a attribute in the tag number:value
amountFound = true;
setAmount(booking.getTextContent());
}
}
ndList = document.getElementsByTagNameNS("*", "SpecifiedTradePaymentTerms"); //$NON-NLS-1$
for (int bookingIndex = 0; bookingIndex < ndList.getLength(); bookingIndex++) {
Node booking = ndList.item(bookingIndex);
// there are many "name" elements, so get the one below
// SellerTradeParty
NodeList bookingDetails = booking.getChildNodes();
for (int detailIndex = 0; detailIndex < bookingDetails.getLength(); detailIndex++) {
Node detail = bookingDetails.item(detailIndex);
if ((detail.getLocalName() != null) && (detail.getLocalName().equals("DueDateDateTime"))) { //$NON-NLS-1$
setDueDate(detail.getTextContent().trim());
}
}
}
parsed = true;
} }
/** /**
@@ -377,159 +280,6 @@ public class ZUGFeRDImporter {
return containsMeta; return containsMeta;
} }
/**
* @return the reference (purpose) the sender specified for this invoice
*/
public String getForeignReference() {
if (!parsed) {
throw new RuntimeException("use extract() before requesting a value");
}
if (foreignReference == null) {
parse();
}
return foreignReference;
}
private void setForeignReference(String foreignReference) {
this.foreignReference = foreignReference;
}
/**
* @return the sender's bank's BLZ code
*/
public String getBLZ() {
if (!parsed) {
throw new RuntimeException("use extract() before requesting a value");
}
if (BLZ == null) {
parse();
}
return BLZ;
}
private void setBLZ(String blz) {
this.BLZ = blz;
}
/**
* @return the sender's bank's BIC code
*/
public String getBIC() {
if (!parsed) {
throw new RuntimeException("use extract() before requesting a value");
}
if (BIC == null) {
parse();
}
return BIC;
}
private void setBIC(String bic) {
this.BIC = bic;
}
private void setDueDate(String dueDate) {
this.dueDate = dueDate;
}
private void setBankName(String bankname) {
this.bankName = bankname;
}
/**
* @return the sender's IBAN
*/
public String getIBAN() {
if (!parsed) {
throw new RuntimeException("use extract() before requesting a value");
}
if (IBAN == null) {
parse();
}
return IBAN;
}
/**
* @return the sender's KTO
*/
public String getKTO() {
if (!parsed) {
throw new RuntimeException("use extract() before requesting a value");
}
if (KTO == null) {
parse();
}
return KTO;
}
/**
* @return the sender's bank name
*/
public String getBankName() {
if (!parsed) {
throw new RuntimeException("use extract() before requesting a value");
}
if (bankName == null) {
parse();
}
return bankName;
}
private void setIBAN(String IBAN) {
this.IBAN = IBAN;
}
private void setKTO(String KTO) {
this.KTO = KTO;
}
/**
* @return the name of the owner of the sender's bank account
*/
public String getHolder() {
if (rawXML == null) {
throw new RuntimeException("use extract() before requesting a value");
}
if (holder == null) {
parse();
}
return holder;
}
private void setHolder(String holder) {
this.holder = holder;
}
/**
* @return the total payable amount
*/
public String getAmount() {
if (rawXML == null) {
throw new RuntimeException("use extract() before requesting a value");
}
if (amount == null) {
parse();
}
return amount;
}
/**
* @return when the payment is due
*/
public String getDueDate() {
if (rawXML == null) {
throw new RuntimeException("use extract() before requesting a value");
}
if (dueDate == null) {
parse();
}
return dueDate;
}
private void setAmount(String amount) {
this.amount = amount;
}
/** /**
* @param meta raw XML to be set * @param meta raw XML to be set
*/ */

View File

@@ -55,14 +55,12 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
// the writing part // the writing part
try { try {
InputStream SOURCE_PDF = this.getClass() InputStream SOURCE_PDF = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
ZUGFeRDExporter zea1 = new ZUGFeRDExporterFromA1Factory().setProducer("My Application").setCreator("Test").setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.EN16931) ZUGFeRDExporter zea1 = new ZUGFeRDExporterFromA1Factory().setProducer("My Application").setCreator("Test").setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.EN16931)
.load(SOURCE_PDF); .load(SOURCE_PDF);
final byte[] UTF8ByteOrderMark = new byte[]{(byte) 0xef, (byte) 0xbb, final byte[] UTF8ByteOrderMark = new byte[]{(byte) 0xef, (byte) 0xbb, (byte) 0xbf};
(byte) 0xbf};
/* we have much more information than just in the basic profile (comfort or extended) but it's perfectly valid to provide more information, just not less. */ /* we have much more information than just in the basic profile (comfort or extended) but it's perfectly valid to provide more information, just not less. */
String ownZUGFeRDXML = new String(UTF8ByteOrderMark) + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + String ownZUGFeRDXML = new String(UTF8ByteOrderMark) + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\" xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100\" xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100\">\n" + "<rsm:CrossIndustryInvoice xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:rsm=\"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100\" xmlns:ram=\"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100\" xmlns:udt=\"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100\">\n" +
@@ -267,7 +265,6 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>EN 16931</zf:ConformanceLevel>") == -1); assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>EN 16931</zf:ConformanceLevel>") == -1);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
@@ -275,32 +272,13 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF); ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
// Reading ZUGFeRD // Reading ZUGFeRD
String amount = null; assertEquals(zi.getAmount(), "571.04");
String bic = null; assertEquals(zi.getBLZ(), "41441604");
String blz = null; assertEquals(zi.getBIC(), "COBADEFFXXX");
String iban = null; assertEquals(zi.getIBAN(), "DE88 2008 0000 0970 3757 00");
String kto = null; assertEquals(zi.getKTO(), "44421800");
String holder = null; assertEquals(zi.getHolder(), "Bei Spiel GmbH");
String ref = null; assertEquals(zi.getForeignReference(), "RE-20171118/506");
if (zi.canParse()) {
zi.parse();
amount = zi.getAmount();
blz = zi.getBLZ();
bic = zi.getBIC();
iban = zi.getIBAN();
kto = zi.getKTO();
holder = zi.getHolder();
ref = zi.getForeignReference();
}
assertEquals(amount, "571.04");
assertEquals(blz, "41441604");
assertEquals(bic, "COBADEFFXXX");
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
assertEquals(kto, "44421800");
assertEquals(holder, "Bei Spiel GmbH");
assertEquals(ref, "RE-20171118/506");
} }
/** /**
@@ -317,8 +295,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
// the writing part // the writing part
try { try {
InputStream SOURCE_PDF = this.getClass() InputStream SOURCE_PDF = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
.getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505blanko.pdf");
ZUGFeRDExporter zea1 = new ZUGFeRDExporterFromA1Factory().setProducer("My Application").setCreator("Test").setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.BASIC) ZUGFeRDExporter zea1 = new ZUGFeRDExporterFromA1Factory().setProducer("My Application").setCreator("Test").setZUGFeRDConformanceLevel(ZUGFeRDConformanceLevel.BASIC)
.load(SOURCE_PDF); .load(SOURCE_PDF);
@@ -468,7 +445,6 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>BASIC</zf:ConformanceLevel>") == -1); assertFalse(pdfContent.indexOf("<zf:ConformanceLevel>BASIC</zf:ConformanceLevel>") == -1);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
@@ -476,32 +452,13 @@ public class MustangReaderWriterCustomXMLTest extends TestCase {
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF); ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
// Reading ZUGFeRD // Reading ZUGFeRD
String amount = null; assertEquals(zi.getAmount(), "571.04");
String bic = null; assertEquals(zi.getBIC(), "COBADEFFXXX");
String blz = null; assertEquals(zi.getBLZ(), "41441604");
String iban = null; assertEquals(zi.getIBAN(), "DE88 2008 0000 0970 3757 00");
String kto = null; assertEquals(zi.getKTO(), "44421800");
String holder = null; assertEquals(zi.getHolder(), "Bei Spiel GmbH");
String ref = null; assertEquals(zi.getForeignReference(), "RE-20170509/505");
if (zi.canParse()) {
zi.parse();
amount = zi.getAmount();
bic = zi.getBIC();
blz = zi.getBLZ();
iban = zi.getIBAN();
kto = zi.getKTO();
holder = zi.getHolder();
ref = zi.getForeignReference();
}
assertEquals(amount, "571.04");
assertEquals(bic, "COBADEFFXXX");
assertEquals(blz, "41441604");
assertEquals(iban, "DE88 2008 0000 0970 3757 00");
assertEquals(kto, "44421800");
assertEquals(holder, "Bei Spiel GmbH");
assertEquals(ref, "RE-20170509/505");
} }
} }

View File

@@ -340,36 +340,14 @@ public class MustangReaderWriterEdgeTest extends TestCase implements IZUGFeRDExp
ZUGFeRDImporter zi = new ZUGFeRDImporter(inputStream); ZUGFeRDImporter zi = new ZUGFeRDImporter(inputStream);
// Reading ZUGFeRD // Reading ZUGFeRD
String amount = null; assertEquals(zi.getAmount(), "571.04");
String bic = null; assertEquals(zi.getBIC(), getOwnBIC());
String blz = null; assertEquals(zi.getBLZ(), getOwnBLZ());
String iban = null; assertEquals(zi.getIBAN(), getOwnIBAN());
String kto = null; assertEquals(zi.getKTO(), getOwnKto());
String holder = null; assertEquals(zi.getHolder(), getOwnOrganisationName());
String ref = null; assertEquals(zi.getDueDate(), "20170530");
String dueDate = null; assertEquals(zi.getForeignReference(), getNumber());
if (zi.canParse()) {
zi.parse();
amount = zi.getAmount();
bic = zi.getBIC();
blz = zi.getBLZ();
iban = zi.getIBAN();
kto = zi.getKTO();
holder = zi.getHolder();
dueDate = zi.getDueDate();
ref = zi.getForeignReference();
}
assertEquals(amount, "571.04");
assertEquals(bic, getOwnBIC());
assertEquals(blz, getOwnBLZ());
assertEquals(iban, getOwnIBAN());
assertEquals(kto, getOwnKto());
assertEquals(holder, getOwnOrganisationName());
assertEquals(dueDate, "20170530");
assertEquals(ref, getNumber());
} }
@@ -404,33 +382,13 @@ public class MustangReaderWriterEdgeTest extends TestCase implements IZUGFeRDExp
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF); ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
// Reading ZUGFeRD // Reading ZUGFeRD
String amount = null; assertEquals(zi.getAmount(), "571.04");
String bic = null; assertEquals(zi.getBIC(), getOwnBIC());
String blz = null; assertEquals(zi.getBLZ(), getOwnBLZ());
String iban = null; assertEquals(zi.getIBAN(), getOwnIBAN());
String kto = null; assertEquals(zi.getKTO(), getOwnKto());
String holder = null; assertEquals(zi.getHolder(), getOwnOrganisationName());
String ref = null; assertEquals(zi.getForeignReference(), getNumber());
if (zi.canParse()) {
zi.parse();
amount = zi.getAmount();
bic = zi.getBIC();
blz = zi.getBLZ();
iban = zi.getIBAN();
kto = zi.getKTO();
holder = zi.getHolder();
ref = zi.getForeignReference();
}
assertEquals(amount, "571.04");
assertEquals(bic, getOwnBIC());
assertEquals(blz, getOwnBLZ());
assertEquals(iban, getOwnIBAN());
assertEquals(kto, getOwnKto());
assertEquals(holder, getOwnOrganisationName());
assertEquals(ref, getNumber());
} }
} }

View File

@@ -359,7 +359,6 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
String ref = null; String ref = null;
if (zi.canParse()) { if (zi.canParse()) {
zi.parse();
amount = zi.getAmount(); amount = zi.getAmount();
blz = zi.getBLZ(); blz = zi.getBLZ();
bic = zi.getBIC(); bic = zi.getBIC();
@@ -517,29 +516,12 @@ public class MustangReaderWriterTest extends TestCase implements IZUGFeRDExporta
ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF); ZUGFeRDImporter zi = new ZUGFeRDImporter(TARGET_PDF);
// Reading ZUGFeRD // Reading ZUGFeRD
String amount = null; assertEquals(zi.getAmount(), "571.04");
String bic = null; assertEquals(zi.getBIC(), getOwnBIC());
String iban = null; assertEquals(zi.getIBAN(), getOwnIBAN());
String kto = null; assertEquals(zi.getKTO(), getOwnKto());
String holder = null; assertEquals(zi.getHolder(), getOwnOrganisationName());
String ref = null; assertEquals(zi.getForeignReference(), getNumber());
if (zi.canParse()) {
zi.parse();
amount = zi.getAmount();
bic = zi.getBIC();
iban = zi.getIBAN();
kto = zi.getKTO();
holder = zi.getHolder();
ref = zi.getForeignReference();
}
assertEquals(amount, "571.04");
assertEquals(bic, getOwnBIC());
assertEquals(iban, getOwnIBAN());
assertEquals(kto, getOwnKto());
assertEquals(holder, getOwnOrganisationName());
assertEquals(ref, getNumber());
} }
/** /**