Class ZUGFeRDInvoiceImporter

  • Direct Known Subclasses:
    ZUGFeRDImporter

    public class ZUGFeRDInvoiceImporter
    extends java.lang.Object
    • 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
      • recalcPrice

        protected boolean recalcPrice
      • ignoreCalculationErrors

        protected boolean ignoreCalculationErrors
      • containsAXMLFileAttachment

        protected boolean containsAXMLFileAttachment
    • Constructor Detail

      • ZUGFeRDInvoiceImporter

        public ZUGFeRDInvoiceImporter()
      • ZUGFeRDInvoiceImporter

        public ZUGFeRDInvoiceImporter​(java.lang.String pdfFilename)
      • ZUGFeRDInvoiceImporter

        public ZUGFeRDInvoiceImporter​(java.io.InputStream pdfStream)
    • Method Detail

      • setPDFFilename

        public void setPDFFilename​(java.lang.String pdfFilename)
      • setInputStream

        public void setInputStream​(java.io.InputStream pdfStream)
      • 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.ParseException
        set the xml of a CII invoice
        Parameters:
        rawXML - the xml string
        doParse - 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.ParseException
        set 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 evaluated
        java.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 wrong
        java.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.ParseException
        sets the XML for the importer to parse
        Parameters:
        XML - the UBL or CII
        Throws:
        java.text.ParseException