Patches courtesy by Ivan Vaklinov (with one little modification), direct
XML access
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>org.mustangproject.ZUGFeRD</groupId>
|
<groupId>org.mustangproject.ZUGFeRD</groupId>
|
||||||
<artifactId>mustang</artifactId>
|
<artifactId>mustang</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.1alpha</version>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,358 +1,390 @@
|
|||||||
package org.mustangproject.ZUGFeRD;
|
package org.mustangproject.ZUGFeRD;
|
||||||
/**
|
/**
|
||||||
* Mustangproject's ZUGFeRD implementation
|
* Mustangproject's ZUGFeRD implementation
|
||||||
* ZUGFeRD importer
|
* ZUGFeRD importer
|
||||||
* Licensed under the APLv2
|
* Licensed under the APLv2
|
||||||
* @date 2014-07-07
|
* @date 2014-07-07
|
||||||
* @version 1.1.0
|
* @version 1.1.0
|
||||||
* @author jstaerk
|
* @author jstaerk
|
||||||
* */
|
* */
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import java.util.Map;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary;
|
|
||||||
import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import org.apache.pdfbox.pdmodel.common.COSObjectable;
|
import org.apache.pdfbox.pdmodel.PDDocumentNameDictionary;
|
||||||
import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification;
|
import org.apache.pdfbox.pdmodel.PDEmbeddedFilesNameTreeNode;
|
||||||
import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile;
|
import org.apache.pdfbox.pdmodel.common.COSObjectable;
|
||||||
import org.w3c.dom.Document;
|
import org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification;
|
||||||
import org.w3c.dom.Node;
|
import org.apache.pdfbox.pdmodel.common.filespecification.PDEmbeddedFile;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.Document;
|
||||||
import org.xml.sax.SAXException;
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
//root.setNamespace(Namespace.getNamespace("http://www.energystar.gov/manageBldgs/req"));
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
public class ZUGFeRDImporter {
|
//root.setNamespace(Namespace.getNamespace("http://www.energystar.gov/manageBldgs/req"));
|
||||||
/*
|
|
||||||
call extract(importFilename).
|
public class ZUGFeRDImporter {
|
||||||
containsMeta() will return if ZUGFeRD data has been found,
|
/*
|
||||||
afterwards you can call getBIC(), getIBAN() etc.
|
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 */
|
*/
|
||||||
private boolean containsMeta=false;
|
|
||||||
/**@var the reference (i.e. invoice number) of the sender */
|
/**@var if metadata has been found */
|
||||||
private String foreignReference;
|
private boolean containsMeta=false;
|
||||||
private String BIC;
|
/**@var the reference (i.e. invoice number) of the sender */
|
||||||
private String IBAN;
|
private String foreignReference;
|
||||||
private String holder;
|
private String BIC;
|
||||||
private String amount;
|
private String IBAN;
|
||||||
private String meta;
|
private String holder;
|
||||||
private String bankName;
|
private String amount;
|
||||||
private boolean amountFound;
|
/** Raw XML form of the extracted data - may be directly obtained. */
|
||||||
|
private byte[] rawXML=null;
|
||||||
|
private String bankName;
|
||||||
|
private boolean amountFound;
|
||||||
|
|
||||||
public void extract(String pdfFilename) {
|
/**
|
||||||
PDDocument doc = null;
|
* Extracts a ZUGFeRD invoice from a PDF document represented by a file name.
|
||||||
try {
|
* Errors are just logged to STDOUT.
|
||||||
doc = PDDocument.load(pdfFilename);
|
*/
|
||||||
// PDDocumentInformation info = doc.getDocumentInformation();
|
public void extract(String pdfFilename)
|
||||||
PDDocumentNameDictionary names = new PDDocumentNameDictionary(
|
{
|
||||||
doc.getDocumentCatalog());
|
try
|
||||||
PDEmbeddedFilesNameTreeNode etn;
|
{
|
||||||
etn = names.getEmbeddedFiles();
|
extractLowLevel(new BufferedInputStream(new FileInputStream(pdfFilename)));
|
||||||
if (etn==null) {
|
} catch (IOException ioe)
|
||||||
doc.close();
|
{
|
||||||
return;
|
ioe.printStackTrace();
|
||||||
}
|
}
|
||||||
Map<String, COSObjectable> efMap = etn.getNames();
|
}
|
||||||
// String filePath = "/tmp/";
|
|
||||||
for (String filename : efMap.keySet()) {
|
/**
|
||||||
/**
|
* Extracts a ZUGFeRD invoice from a PDF document represented by an input stream.
|
||||||
* currently (in the release candidate of version 1) only one
|
* Errors are reported via exception handling.
|
||||||
* attached file with the name ZUGFeRD-invoice.xml is allowed
|
*/
|
||||||
* */
|
public void extractLowLevel(InputStream pdfStream) throws IOException {
|
||||||
if (filename.equals("ZUGFeRD-invoice.xml")) { //$NON-NLS-1$
|
PDDocument doc = null;
|
||||||
containsMeta = true;
|
try {
|
||||||
|
doc = PDDocument.load(pdfStream);
|
||||||
PDComplexFileSpecification fileSpec = (PDComplexFileSpecification) efMap
|
// PDDocumentInformation info = doc.getDocumentInformation();
|
||||||
.get(filename);
|
PDDocumentNameDictionary names = new PDDocumentNameDictionary(
|
||||||
PDEmbeddedFile embeddedFile = fileSpec.getEmbeddedFile();
|
doc.getDocumentCatalog());
|
||||||
// String embeddedFilename = filePath + filename;
|
PDEmbeddedFilesNameTreeNode etn;
|
||||||
// File file = new File(filePath + filename);
|
etn = names.getEmbeddedFiles();
|
||||||
// System.out.println("Writing " + embeddedFilename);
|
if (etn==null) {
|
||||||
// ByteArrayOutputStream fileBytes=new
|
doc.close();
|
||||||
// ByteArrayOutputStream();
|
return;
|
||||||
// FileOutputStream fos = new FileOutputStream(file);
|
}
|
||||||
|
Map<String, COSObjectable> efMap = etn.getNames();
|
||||||
setMeta(new String(embeddedFile.getByteArray()));
|
// String filePath = "/tmp/";
|
||||||
// fos.write(embeddedFile.getByteArray());
|
for (String filename : efMap.keySet()) {
|
||||||
// fos.close();
|
/**
|
||||||
}
|
* currently (in the release candidate of version 1) only one
|
||||||
}
|
* attached file with the name ZUGFeRD-invoice.xml is allowed
|
||||||
|
* */
|
||||||
} catch (IOException e1) {
|
if (filename.equals("ZUGFeRD-invoice.xml")) { //$NON-NLS-1$
|
||||||
// TODO Auto-generated catch block
|
containsMeta = true;
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
PDComplexFileSpecification fileSpec = (PDComplexFileSpecification) efMap
|
||||||
finally {
|
.get(filename);
|
||||||
try {
|
PDEmbeddedFile embeddedFile = fileSpec.getEmbeddedFile();
|
||||||
if(doc!=null) {
|
// String embeddedFilename = filePath + filename;
|
||||||
doc.close();
|
// File file = new File(filePath + filename);
|
||||||
}
|
// System.out.println("Writing " + embeddedFilename);
|
||||||
} catch (IOException e) {}
|
// ByteArrayOutputStream fileBytes=new
|
||||||
}
|
// ByteArrayOutputStream();
|
||||||
|
// FileOutputStream fos = new FileOutputStream(file);
|
||||||
}
|
rawXML = embeddedFile.getByteArray();
|
||||||
|
setMeta(new String(rawXML));
|
||||||
public void parse() {
|
// fos.write(embeddedFile.getByteArray());
|
||||||
DocumentBuilderFactory factory = null;
|
// fos.close();
|
||||||
DocumentBuilder builder = null;
|
}
|
||||||
Document document = null;
|
}
|
||||||
|
|
||||||
factory = DocumentBuilderFactory.newInstance();
|
} catch (IOException e1) {
|
||||||
factory.setNamespaceAware(true); //otherwise we can not act namespace independend, i.e. use document.getElementsByTagNameNS("*",...
|
throw e1;
|
||||||
try {
|
}
|
||||||
builder = factory.newDocumentBuilder();
|
finally {
|
||||||
} catch (ParserConfigurationException ex3) {
|
try {
|
||||||
// TODO Auto-generated catch block
|
if(doc!=null) {
|
||||||
ex3.printStackTrace();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {}
|
||||||
try {
|
}
|
||||||
InputStream bais = new ByteArrayInputStream(meta.getBytes());
|
|
||||||
document = builder.parse(bais);
|
}
|
||||||
} catch (SAXException ex1) {
|
|
||||||
ex1.printStackTrace();
|
public void parse() {
|
||||||
} catch (IOException ex2) {
|
DocumentBuilderFactory factory = null;
|
||||||
ex2.printStackTrace();
|
DocumentBuilder builder = null;
|
||||||
}
|
Document document = null;
|
||||||
NodeList ndList ;
|
|
||||||
|
factory = DocumentBuilderFactory.newInstance();
|
||||||
// rootNode = document.getDocumentElement();
|
factory.setNamespaceAware(true); //otherwise we can not act namespace independend, i.e. use document.getElementsByTagNameNS("*",...
|
||||||
// ApplicableSupplyChainTradeSettlement
|
try {
|
||||||
ndList = document.getDocumentElement()
|
builder = factory.newDocumentBuilder();
|
||||||
.getElementsByTagNameNS("*","PaymentReference"); //$NON-NLS-1$
|
} catch (ParserConfigurationException ex3) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
ex3.printStackTrace();
|
||||||
.getLength(); bookingIndex++) {
|
}
|
||||||
Node booking = ndList.item(bookingIndex);
|
|
||||||
// if there is a attribute in the tag number:value
|
try {
|
||||||
|
InputStream bais = new ByteArrayInputStream(rawXML);
|
||||||
setForeignReference(booking.getTextContent());
|
document = builder.parse(bais);
|
||||||
|
} catch (SAXException ex1) {
|
||||||
}
|
ex1.printStackTrace();
|
||||||
/*
|
} catch (IOException ex2) {
|
||||||
ndList = document
|
ex2.printStackTrace();
|
||||||
.getElementsByTagName("GermanBankleitzahlID"); //$NON-NLS-1$
|
}
|
||||||
|
NodeList ndList ;
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
|
||||||
.getLength(); bookingIndex++) {
|
// rootNode = document.getDocumentElement();
|
||||||
Node booking = ndList.item(bookingIndex);
|
// ApplicableSupplyChainTradeSettlement
|
||||||
// if there is a attribute in the tag number:value
|
ndList = document.getDocumentElement()
|
||||||
setBIC(booking.getTextContent());
|
.getElementsByTagNameNS("*","PaymentReference"); //$NON-NLS-1$
|
||||||
|
|
||||||
}
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
|
.getLength(); bookingIndex++) {
|
||||||
ndList = document.getElementsByTagName("ProprietaryID"); //$NON-NLS-1$
|
Node booking = ndList.item(bookingIndex);
|
||||||
|
// if there is a attribute in the tag number:value
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
|
||||||
.getLength(); bookingIndex++) {
|
setForeignReference(booking.getTextContent());
|
||||||
Node booking = ndList.item(bookingIndex);
|
|
||||||
// if there is a attribute in the tag number:value
|
}
|
||||||
setIBAN(booking.getTextContent());
|
/*
|
||||||
|
ndList = document
|
||||||
}
|
.getElementsByTagName("GermanBankleitzahlID"); //$NON-NLS-1$
|
||||||
<ram:PayeePartyCreditorFinancialAccount>
|
|
||||||
<ram:IBANID>DE1234</ram:IBANID>
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
</ram:PayeePartyCreditorFinancialAccount>
|
.getLength(); bookingIndex++) {
|
||||||
<ram:PayeeSpecifiedCreditorFinancialInstitution>
|
Node booking = ndList.item(bookingIndex);
|
||||||
<ram:BICID>DE5656565</ram:BICID>
|
// if there is a attribute in the tag number:value
|
||||||
<ram:Name>Commerzbank</ram:Name>
|
setBIC(booking.getTextContent());
|
||||||
</ram:PayeeSpecifiedCreditorFinancialInstitution>
|
|
||||||
|
}
|
||||||
*/
|
|
||||||
ndList = document.getElementsByTagNameNS("*","PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$
|
ndList = document.getElementsByTagName("ProprietaryID"); //$NON-NLS-1$
|
||||||
|
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.getLength(); bookingIndex++) {
|
||||||
|
Node booking = ndList.item(bookingIndex);
|
||||||
Node booking = ndList.item(bookingIndex);
|
// if there is a attribute in the tag number:value
|
||||||
// there are many "name" elements, so get the one below
|
setIBAN(booking.getTextContent());
|
||||||
// SellerTradeParty
|
|
||||||
NodeList bookingDetails = booking.getChildNodes();
|
}
|
||||||
|
<ram:PayeePartyCreditorFinancialAccount>
|
||||||
|
<ram:IBANID>DE1234</ram:IBANID>
|
||||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
</ram:PayeePartyCreditorFinancialAccount>
|
||||||
.getLength(); detailIndex++) {
|
<ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||||
Node detail = bookingDetails.item(detailIndex);
|
<ram:BICID>DE5656565</ram:BICID>
|
||||||
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("IBANID"))) { //$NON-NLS-1$
|
<ram:Name>Commerzbank</ram:Name>
|
||||||
setIBAN(detail.getTextContent());
|
</ram:PayeeSpecifiedCreditorFinancialInstitution>
|
||||||
|
|
||||||
}
|
*/
|
||||||
}
|
ndList = document.getElementsByTagNameNS("*","PayeePartyCreditorFinancialAccount"); //$NON-NLS-1$
|
||||||
|
|
||||||
}
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
|
.getLength(); bookingIndex++) {
|
||||||
ndList = document.getElementsByTagNameNS("*","PayeeSpecifiedCreditorFinancialInstitution"); //$NON-NLS-1$
|
|
||||||
|
Node booking = ndList.item(bookingIndex);
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
// there are many "name" elements, so get the one below
|
||||||
.getLength(); bookingIndex++) {
|
// SellerTradeParty
|
||||||
Node booking = ndList.item(bookingIndex);
|
NodeList bookingDetails = booking.getChildNodes();
|
||||||
// there are many "name" elements, so get the one below
|
|
||||||
// SellerTradeParty
|
|
||||||
NodeList bookingDetails = booking.getChildNodes();
|
for (int detailIndex = 0; detailIndex < bookingDetails
|
||||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
.getLength(); detailIndex++) {
|
||||||
.getLength(); detailIndex++) {
|
Node detail = bookingDetails.item(detailIndex);
|
||||||
Node detail = bookingDetails.item(detailIndex);
|
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("IBANID"))) { //$NON-NLS-1$
|
||||||
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("BICID"))) { //$NON-NLS-1$
|
setIBAN(detail.getTextContent());
|
||||||
setBIC(detail.getTextContent());
|
|
||||||
}
|
}
|
||||||
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
}
|
||||||
setBankName(detail.getTextContent());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
ndList = document.getElementsByTagNameNS("*","PayeeSpecifiedCreditorFinancialInstitution"); //$NON-NLS-1$
|
||||||
}
|
|
||||||
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
//
|
.getLength(); bookingIndex++) {
|
||||||
ndList = document.getElementsByTagNameNS("*","SellerTradeParty"); //$NON-NLS-1$
|
Node booking = ndList.item(bookingIndex);
|
||||||
|
// there are many "name" elements, so get the one below
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
// SellerTradeParty
|
||||||
.getLength(); bookingIndex++) {
|
NodeList bookingDetails = booking.getChildNodes();
|
||||||
Node booking = ndList.item(bookingIndex);
|
for (int detailIndex = 0; detailIndex < bookingDetails
|
||||||
// there are many "name" elements, so get the one below
|
.getLength(); detailIndex++) {
|
||||||
// SellerTradeParty
|
Node detail = bookingDetails.item(detailIndex);
|
||||||
NodeList bookingDetails = booking.getChildNodes();
|
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("BICID"))) { //$NON-NLS-1$
|
||||||
for (int detailIndex = 0; detailIndex < bookingDetails
|
setBIC(detail.getTextContent());
|
||||||
.getLength(); detailIndex++) {
|
}
|
||||||
Node detail = bookingDetails.item(detailIndex);
|
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
||||||
if ((detail.getLocalName()!=null)&&(detail.getLocalName().equals("Name"))) { //$NON-NLS-1$
|
setBankName(detail.getTextContent());
|
||||||
setHolder(detail.getTextContent());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
//
|
||||||
ndList = document.getElementsByTagNameNS("*","DuePayableAmount"); //$NON-NLS-1$
|
ndList = document.getElementsByTagNameNS("*","SellerTradeParty"); //$NON-NLS-1$
|
||||||
|
|
||||||
for (int bookingIndex = 0; bookingIndex < ndList
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
.getLength(); bookingIndex++) {
|
.getLength(); bookingIndex++) {
|
||||||
Node booking = ndList.item(bookingIndex);
|
Node booking = ndList.item(bookingIndex);
|
||||||
// if there is a attribute in the tag number:value
|
// there are many "name" elements, so get the one below
|
||||||
amountFound=true;
|
// SellerTradeParty
|
||||||
setAmount(booking.getTextContent());
|
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$
|
||||||
if (!amountFound) {
|
setHolder(detail.getTextContent());
|
||||||
/* 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++) {
|
ndList = document.getElementsByTagNameNS("*","DuePayableAmount"); //$NON-NLS-1$
|
||||||
Node booking = ndList.item(bookingIndex);
|
|
||||||
// if there is a attribute in the tag number:value
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
amountFound=true;
|
.getLength(); bookingIndex++) {
|
||||||
setAmount(booking.getTextContent());
|
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,,
|
||||||
public boolean containsMeta() {
|
* if it's not there, check for GrandTotalAmount
|
||||||
return containsMeta;
|
*/
|
||||||
}
|
ndList = document.getElementsByTagNameNS("*","GrandTotalAmount"); //$NON-NLS-1$
|
||||||
|
for (int bookingIndex = 0; bookingIndex < ndList
|
||||||
public String getForeignReference() {
|
.getLength(); bookingIndex++) {
|
||||||
return foreignReference;
|
Node booking = ndList.item(bookingIndex);
|
||||||
}
|
// if there is a attribute in the tag number:value
|
||||||
|
amountFound=true;
|
||||||
|
setAmount(booking.getTextContent());
|
||||||
|
|
||||||
public void setForeignReference(String foreignReference) {
|
}
|
||||||
this.foreignReference = foreignReference;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
public String getBIC() {
|
|
||||||
return BIC;
|
|
||||||
}
|
public boolean containsMeta() {
|
||||||
|
return containsMeta;
|
||||||
|
}
|
||||||
|
|
||||||
private void setBIC(String bic) {
|
public String getForeignReference() {
|
||||||
this.BIC = bic;
|
return foreignReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setBankName(String bankname) {
|
|
||||||
this.bankName = bankname;
|
public void setForeignReference(String foreignReference) {
|
||||||
}
|
this.foreignReference = foreignReference;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getIBAN() {
|
|
||||||
return IBAN;
|
public String getBIC() {
|
||||||
}
|
return BIC;
|
||||||
|
}
|
||||||
|
|
||||||
public String getBankName() {
|
|
||||||
return bankName;
|
|
||||||
}
|
private void setBIC(String bic) {
|
||||||
|
this.BIC = bic;
|
||||||
|
}
|
||||||
|
|
||||||
public void setIBAN(String IBAN) {
|
|
||||||
this.IBAN = IBAN;
|
private void setBankName(String bankname) {
|
||||||
}
|
this.bankName = bankname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getHolder() {
|
|
||||||
return holder;
|
public String getIBAN() {
|
||||||
}
|
return IBAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setHolder(String holder) {
|
public String getBankName() {
|
||||||
this.holder = holder;
|
return bankName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getAmount() {
|
public void setIBAN(String IBAN) {
|
||||||
return amount;
|
this.IBAN = IBAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setAmount(String amount) {
|
|
||||||
this.amount = amount;
|
public String getHolder() {
|
||||||
}
|
return holder;
|
||||||
|
}
|
||||||
public void setMeta(String meta) {
|
|
||||||
this.meta=meta;
|
|
||||||
}
|
|
||||||
|
private void setHolder(String holder) {
|
||||||
public String getMeta() {
|
this.holder = holder;
|
||||||
return meta;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* will return true if the metadata (just extract-ed or set with setMeta) contains ZUGFeRD XML
|
public String getAmount() {
|
||||||
* */
|
return amount;
|
||||||
public boolean canParse() {
|
}
|
||||||
|
|
||||||
|
|
||||||
//SpecifiedExchangedDocumentContext is in the schema, so a relatively good indication if zugferd is present - better than just invoice
|
private void setAmount(String amount) {
|
||||||
return (meta!=null)&&( meta.length()>0)&&( meta.contains("SpecifiedExchangedDocumentContext")); //$NON-NLS-1$
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void setMeta(String meta) {
|
||||||
|
this.rawXML=meta.getBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMeta() {
|
||||||
|
if (rawXML==null){
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return new String(rawXML);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw XML data as extracted from the ZUGFeRD PDF file.
|
||||||
|
*/
|
||||||
|
public byte[] getRawXML()
|
||||||
|
{
|
||||||
|
return rawXML;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* will return true if the metadata (just extract-ed or set with setMeta) contains ZUGFeRD XML
|
||||||
|
* */
|
||||||
|
public boolean canParse() {
|
||||||
|
|
||||||
|
|
||||||
|
//SpecifiedExchangedDocumentContext is in the schema, so a relatively good indication if zugferd is present - better than just invoice
|
||||||
|
String meta=getMeta();
|
||||||
|
return (meta!=null)&&( meta.length()>0)&&( meta.contains("SpecifiedExchangedDocumentContext")); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
#Generated by Maven
|
#Generated by Maven
|
||||||
#Sat Jun 28 19:58:49 CEST 2014
|
#Fri Aug 08 19:33:01 CEST 2014
|
||||||
version=1.1.0.alpha
|
version=1.1.1alpha
|
||||||
groupId=org.mustangproject.ZUGFeRD
|
groupId=org.mustangproject.ZUGFeRD
|
||||||
artifactId=mustang
|
artifactId=mustang
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,60 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<testsuite failures="0" time="0.224" errors="0" skipped="0" tests="1" name="org.mustangproject.ZUGFeRD.AppTest">
|
|
||||||
<properties>
|
|
||||||
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
|
|
||||||
<property name="sun.boot.library.path" value="/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64"/>
|
|
||||||
<property name="java.vm.version" value="23.25-b01"/>
|
|
||||||
<property name="java.vm.vendor" value="Sun Microsystems Inc."/>
|
|
||||||
<property name="java.vendor.url" value="http://java.sun.com/"/>
|
|
||||||
<property name="path.separator" value=":"/>
|
|
||||||
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
|
|
||||||
<property name="file.encoding.pkg" value="sun.io"/>
|
|
||||||
<property name="user.country" value="DE"/>
|
|
||||||
<property name="sun.java.launcher" value="SUN_STANDARD"/>
|
|
||||||
<property name="sun.os.patch.level" value="unknown"/>
|
|
||||||
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
|
|
||||||
<property name="user.dir" value="/home/jstaerk/workspace/PDFA3/mustang"/>
|
|
||||||
<property name="java.runtime.version" value="1.6.0_31-b31"/>
|
|
||||||
<property name="java.awt.graphicsenv" value="sun.awt.X11GraphicsEnvironment"/>
|
|
||||||
<property name="java.endorsed.dirs" value="/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/endorsed"/>
|
|
||||||
<property name="os.arch" value="amd64"/>
|
|
||||||
<property name="java.io.tmpdir" value="/tmp"/>
|
|
||||||
<property name="line.separator" value="
|
|
||||||
"/>
|
|
||||||
<property name="java.vm.specification.vendor" value="Sun Microsystems Inc."/>
|
|
||||||
<property name="os.name" value="Linux"/>
|
|
||||||
<property name="classworlds.conf" value="/usr/share/maven2/bin/m2.conf"/>
|
|
||||||
<property name="sun.jnu.encoding" value="UTF-8"/>
|
|
||||||
<property name="java.library.path" value="/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk-amd64/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib"/>
|
|
||||||
<property name="java.specification.name" value="Java Platform API Specification"/>
|
|
||||||
<property name="java.class.version" value="50.0"/>
|
|
||||||
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
|
|
||||||
<property name="os.version" value="3.5.0-52-generic"/>
|
|
||||||
<property name="user.home" value="/home/jstaerk"/>
|
|
||||||
<property name="user.timezone" value="Europe/Berlin"/>
|
|
||||||
<property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/>
|
|
||||||
<property name="file.encoding" value="UTF-8"/>
|
|
||||||
<property name="java.specification.version" value="1.6"/>
|
|
||||||
<property name="user.name" value="jstaerk"/>
|
|
||||||
<property name="java.class.path" value="/usr/share/maven2/boot/classworlds.jar"/>
|
|
||||||
<property name="java.vm.specification.version" value="1.0"/>
|
|
||||||
<property name="sun.arch.data.model" value="64"/>
|
|
||||||
<property name="java.home" value="/usr/lib/jvm/java-6-openjdk-amd64/jre"/>
|
|
||||||
<property name="sun.java.command" value="org.codehaus.classworlds.Launcher "test""/>
|
|
||||||
<property name="java.specification.vendor" value="Sun Microsystems Inc."/>
|
|
||||||
<property name="user.language" value="de"/>
|
|
||||||
<property name="java.vm.info" value="mixed mode"/>
|
|
||||||
<property name="java.version" value="1.6.0_31"/>
|
|
||||||
<property name="java.ext.dirs" value="/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/ext:/usr/java/packages/lib/ext"/>
|
|
||||||
<property name="securerandom.source" value="file:/dev/./urandom"/>
|
|
||||||
<property name="sun.boot.class.path" value="/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/jfr.jar:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/netx.jar:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/plugin.jar:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/rhino.jar:/usr/lib/jvm/java-6-openjdk-amd64/jre/classes"/>
|
|
||||||
<property name="java.vendor" value="Sun Microsystems Inc."/>
|
|
||||||
<property name="maven.home" value="/usr/share/maven2"/>
|
|
||||||
<property name="file.separator" value="/"/>
|
|
||||||
<property name="java.vendor.url.bug" value="http://java.sun.com/cgi-bin/bugreport.cgi"/>
|
|
||||||
<property name="sun.cpu.endian" value="little"/>
|
|
||||||
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
|
|
||||||
<property name="sun.cpu.isalist" value=""/>
|
|
||||||
</properties>
|
|
||||||
<testcase time="0.213" classname="org.mustangproject.ZUGFeRD.AppTest" name="testImport"/>
|
|
||||||
</testsuite>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
-------------------------------------------------------------------------------
|
|
||||||
Test set: org.mustangproject.ZUGFeRD.AppTest
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.223 sec
|
|
||||||
Reference in New Issue
Block a user