Package org.mustangproject.ZUGFeRD
Class ZUGFeRDInvoiceImporter
- java.lang.Object
-
- org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter
-
- Direct Known Subclasses:
ZUGFeRDImporter
public class ZUGFeRDInvoiceImporter extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<java.lang.String,byte[]>additionalXMLsmap filenames of additional XML files to their contentsprotected booleancontainsAXMLFileAttachmentprotected booleancontainsMetaif metadata has been foundprotected org.w3c.dom.Documentdocumentparsed Documentprotected booleanignoreCalculationErrorsprotected CalculatedInvoiceimportedInvoiceprotected booleanparseAutomaticallyautomatically parse into importedInvoiceprotected java.util.ArrayList<FileAttachment>PDFAttachmentsmap filenames of all embedded files in the respective PDFprotected byte[]rawXMLRaw XML form of the extracted data - may be directly obtained.protected booleanrecalcPriceprotected java.lang.Integerversionprotected java.lang.StringxmpStringXMP metadata
-
Constructor Summary
Constructors Constructor Description ZUGFeRDInvoiceImporter()ZUGFeRDInvoiceImporter(java.io.InputStream pdfStream)ZUGFeRDInvoiceImporter(java.lang.String pdfFilename)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voiddoIgnoreCalculationErrors()do not raise ParseExceptions even if the reproduced invoice total does not match the given valuevoiddoRecalculateItemPricesFromLineTotals()have the item prices be determined from the line total.InvoiceextractInto(Invoice zpp)This will parse a XML into the given invoice objectInvoiceextractInvoice()This will parse a XML into a invoice objectprotected java.lang.StringextractString(java.lang.String xpathStr)voidfromXML(java.lang.String XML)sets the XML for the importer to parseprotected org.w3c.dom.DocumentgetDocument()java.util.List<FileAttachment>getFileAttachmentsPDF()return the file names of all files embedded into the PDFjava.util.List<FileAttachment>getFileAttachmentsXML()Deprecated.use invoice.getAdditionalReferencedDocumentsEStandardgetStandard()java.lang.StringgetUTF8()booleanhasXMLFileAttachment()if the file attachment is not in the list of allowed file names we can't import the XML, but the validator needs to know if maybe some other .xml-File is embedded because it would raise an additional notice that the filename is probably wrongvoidsetID(java.lang.String id)voidsetInputStream(java.io.InputStream pdfStream)voidsetPDFFilename(java.lang.String pdfFilename)voidsetRawXML(byte[] rawXML)set the xml of a CII invoice, simple versionvoidsetRawXML(byte[] rawXML, boolean doParse)set the xml of a CII invoice
-
-
-
Field Detail
-
additionalXMLs
protected final java.util.HashMap<java.lang.String,byte[]> additionalXMLs
map filenames of additional XML files to their contents
-
PDFAttachments
protected final java.util.ArrayList<FileAttachment> PDFAttachments
map filenames of all embedded files in the respective PDF
-
containsMeta
protected boolean containsMeta
if metadata has been found
-
rawXML
protected byte[] rawXML
Raw XML form of the extracted data - may be directly obtained.
-
xmpString
protected java.lang.String xmpString
XMP metadata
-
document
protected org.w3c.dom.Document document
parsed Document
-
parseAutomatically
protected boolean parseAutomatically
automatically parse into importedInvoice
-
version
protected java.lang.Integer version
-
importedInvoice
protected CalculatedInvoice importedInvoice
-
recalcPrice
protected boolean recalcPrice
-
ignoreCalculationErrors
protected boolean ignoreCalculationErrors
-
containsAXMLFileAttachment
protected boolean containsAXMLFileAttachment
-
-
Method Detail
-
setPDFFilename
public void setPDFFilename(java.lang.String pdfFilename)
-
setInputStream
public void setInputStream(java.io.InputStream pdfStream)
-
getFileAttachmentsPDF
public java.util.List<FileAttachment> getFileAttachmentsPDF()
return the file names of all files embedded into the PDF- Returns:
- a ArrayList of FileAttachments, empty if none
- See Also:
for XML embedded files please use ZUGFeRDInvoiceImporter.getFileAttachmentsXML
-
doRecalculateItemPricesFromLineTotals
public void doRecalculateItemPricesFromLineTotals()
have the item prices be determined from the line total. That's a workaround for some invoices which just put 0 as item price
-
doIgnoreCalculationErrors
public void doIgnoreCalculationErrors()
do not raise ParseExceptions even if the reproduced invoice total does not match the given value
-
hasXMLFileAttachment
public boolean hasXMLFileAttachment()
if the file attachment is not in the list of allowed file names we can't import the XML, but the validator needs to know if maybe some other .xml-File is embedded because it would raise an additional notice that the filename is probably wrong- Returns:
-
setRawXML
public void setRawXML(byte[] rawXML, boolean doParse) throws java.io.IOException, java.text.ParseExceptionset the xml of a CII invoice- Parameters:
rawXML- the xml stringdoParse- automatically parse input for zugferdImporter (not ZUGFeRDInvoiceImporter)- Throws:
java.io.IOException- if parsing xml throws it (unlikely its string based)java.text.ParseException
-
setRawXML
public void setRawXML(byte[] rawXML) throws java.io.IOException, java.text.ParseExceptionset the xml of a CII invoice, simple version- Parameters:
rawXML- the cii(?) as a string- Throws:
java.io.IOException- if parsing xml throws it (unlikely its string based)java.text.ParseException
-
setID
public void setID(java.lang.String id)
-
extractInto
public Invoice extractInto(Invoice zpp) throws javax.xml.xpath.XPathExpressionException, java.text.ParseException
This will parse a XML into the given invoice object- Parameters:
zpp- the invoice to be altered- Returns:
- the parsed invoice object
- Throws:
javax.xml.xpath.XPathExpressionException- if xpath could not be evaluatedjava.text.ParseException- if the grand total of the parsed invoice could not be replicated with the new invoice
-
getDocument
protected org.w3c.dom.Document getDocument()
-
extractString
protected java.lang.String extractString(java.lang.String xpathStr)
-
getStandard
public EStandard getStandard() throws java.lang.Exception
- Throws:
java.lang.Exception
-
getUTF8
public java.lang.String getUTF8()
- Returns:
- return UTF8 XML (without BOM) of the invoice
-
getFileAttachmentsXML
@Deprecated public java.util.List<FileAttachment> getFileAttachmentsXML()
Deprecated.use invoice.getAdditionalReferencedDocuments- Returns:
- the file attachments embedded in XML (using base64) decoded as byte array, for PDF embedded files in FX use getFileAttachmentsPDF() may return empty array
-
extractInvoice
public Invoice extractInvoice() throws javax.xml.xpath.XPathExpressionException, java.text.ParseException
This will parse a XML into a invoice object- Returns:
- the parsed invoice object
- Throws:
javax.xml.xpath.XPathExpressionException- if internal xpath expressions were wrongjava.text.ParseException- if the grand total of the parsed invoice could not be replicated with the new invoice
-
fromXML
public void fromXML(java.lang.String XML) throws java.text.ParseExceptionsets the XML for the importer to parse- Parameters:
XML- the UBL or CII- Throws:
java.text.ParseException
-
-