Package com.itextpdf.text.zugferd
Class InvoiceDOM
- java.lang.Object
-
- com.itextpdf.text.zugferd.InvoiceDOM
-
public class InvoiceDOM extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
InvoiceDOM.SafeEmptyEntityResolver
-
Field Summary
Fields Modifier and Type Field Description static CountryCode
COUNTRY_CODE
static CurrencyCode
CURR_CODE
static NumberChecker
DEC2
static NumberChecker
DEC4
static DateFormatCode
DF_CODE
protected org.w3c.dom.Document
doc
static GlobalIdentifierCode
GI_CODE
static MeasurementUnitCode
M_UNIT_CODE
static PaymentMeansCode
PM_CODE
static TaxCategoryCode
TC_CODE
static TaxIDTypeCode
TIDT_CODE
static TaxTypeCode
TT_CODE
-
Constructor Summary
Constructors Constructor Description InvoiceDOM(BasicProfile data)
Creates an object that will import data into an XML template.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
check(java.lang.String s, java.lang.String message)
Checks if a string is empty and throws a DataIncompleteException if so.protected void
importAppliedTradeAllowanceCharge(org.w3c.dom.Element parent, boolean indicator, java.lang.String actualAmount, java.lang.String currencyID, java.lang.String reason)
Imports applied trade allowance charge data (line items).protected void
importBuyerTradeParty(org.w3c.dom.Element parent, BasicProfile data)
Gets the buyer trade party data to import this data.protected void
importContent(org.w3c.dom.Element parent, java.lang.String tag, java.lang.String content, java.lang.String... attributes)
Helper method to set the content of a tag.private void
importData(org.w3c.dom.Document doc, BasicProfile data)
Imports the data into the XML template.protected void
importDateTime(org.w3c.dom.Element parent, java.lang.String tag, java.lang.String dateTimeFormat, java.util.Date dateTime)
Set the content of a date tag along with the attribute that defines the format.protected void
importHeaderExchangedDocument(org.w3c.dom.Element element, BasicProfile data)
Imports the data for the following tag: rsm:HeaderExchangedDocumentprotected void
importIncludedNotes(org.w3c.dom.Element parent, int level, java.lang.String[][] notes, java.lang.String[] notesCodes)
Includes notes and (in case of the COMFORT profile) the subject codes for those notes.protected void
importInvoiceeTradeParty(org.w3c.dom.Element parent, ComfortProfile data)
Gets the invoicee party data to import this data.protected void
importLineItemBasic(org.w3c.dom.Element parent, java.lang.String quantity, java.lang.String code, java.lang.String name)
Imports the data for a line item (basic profile)protected void
importLineItemComfort(org.w3c.dom.Element parent, java.lang.String lineID, java.lang.String[][] note, java.lang.String grossPriceChargeAmount, java.lang.String grossPriceChargeAmountCurrencyID, java.lang.String grossPriceBasisQuantity, java.lang.String grossPriceBasisQuantityCode, java.lang.Boolean[] grossPriceTradeAllowanceChargeIndicator, java.lang.String[] grossPriceTradeAllowanceChargeActualAmount, java.lang.String[] grossPriceTradeAllowanceChargeActualAmountCurrencyID, java.lang.String[] grossPriceTradeAllowanceChargeReason, java.lang.String netPriceChargeAmount, java.lang.String netPriceChargeAmountCurrencyID, java.lang.String netPriceBasisQuantity, java.lang.String netPriceBasisQuantityCode, java.lang.String billedQuantity, java.lang.String billedQuantityCode, java.lang.String[] settlementTaxTypeCode, java.lang.String[] settlementTaxExemptionReason, java.lang.String[] settlementTaxCategoryCode, java.lang.String[] settlementTaxApplicablePercent, java.lang.String totalAmount, java.lang.String totalAmountCurrencyID, java.lang.String specifiedTradeProductGlobalID, java.lang.String specifiedTradeProductSchemeID, java.lang.String specifiedTradeProductSellerAssignedID, java.lang.String specifiedTradeProductBuyerAssignedID, java.lang.String specifiedTradeProductName, java.lang.String specifiedTradeProductDescription)
Imports line item data (comfort profile).protected void
importLineItemsBasic(org.w3c.dom.Element parent, BasicProfile data)
Gets line data to import the this data (basic profile).protected void
importLineItemsComfort(org.w3c.dom.Element parent, ComfortProfile data)
Gets line item data to import the this data (comfort profile).protected void
importPaymentMeans(org.w3c.dom.Element parent, BasicProfile data)
Gets the payment means data to imports this data.protected void
importPaymentMeans(org.w3c.dom.Element parent, java.lang.String typeCode, java.lang.String[] information, java.lang.String id, java.lang.String scheme, java.lang.String payerIban, java.lang.String payerProprietaryID, java.lang.String iban, java.lang.String accName, java.lang.String accID, java.lang.String payerBic, java.lang.String payerBank, java.lang.String payerInst, java.lang.String bic, java.lang.String bank, java.lang.String inst)
Imports payment means data.protected void
importSellerTradeParty(org.w3c.dom.Element parent, BasicProfile data)
Gets the seller trade party data to import this data.protected void
importSpecifiedExchangedDocumentContext(org.w3c.dom.Element element, BasicProfile data)
Imports the data for the following tag: rsm:SpecifiedExchangedDocumentContextprotected void
importSpecifiedLogisticsServiceCharge(org.w3c.dom.Element parent, ComfortProfile data)
Gets specified logistics service charge data to import the this data.protected void
importSpecifiedLogisticsServiceCharge(org.w3c.dom.Element parent, java.lang.String[] description, java.lang.String appliedAmount, java.lang.String currencyID, java.lang.String[] typeCode, java.lang.String[] categoryCode, java.lang.String[] percent)
Imports specified logistics service charge data.protected void
importSpecifiedSupplyChainTradeTransaction(org.w3c.dom.Element element, BasicProfile data)
Imports the data for the following tag: rsm:SpecifiedSupplyChainTradeTransactionprotected void
importSpecifiedTradeAllowanceCharge(org.w3c.dom.Element parent, boolean indicator, java.lang.String actualAmount, java.lang.String actualAmountCurrency, java.lang.String reason, java.lang.String[] typeCode, java.lang.String[] categoryCode, java.lang.String[] percent)
Imports specified trade allowance charge.protected void
importSpecifiedTradeAllowanceCharge(org.w3c.dom.Element parent, ComfortProfile data)
Gets specified trade allowance charge data to import the this data.protected void
importSpecifiedTradePaymentTerms(org.w3c.dom.Element parent, ComfortProfile data)
Gets specified trade payment terms data to import the this data.protected void
importSpecifiedTradePaymentTerms(org.w3c.dom.Element parent, java.lang.String[] description, java.util.Date dateTime, java.lang.String dateTimeFormat)
Imports specified trade payment terms.protected void
importTax(org.w3c.dom.Element parent, BasicProfile data)
Gets tax data to import the this data.protected void
importTax(org.w3c.dom.Element parent, java.lang.String typeCode, java.lang.String exemptionReason, java.lang.String category, java.lang.String percent)
Imports tax data.protected void
importTax(org.w3c.dom.Element parent, java.lang.String calculatedAmount, java.lang.String currencyID, java.lang.String typeCode, java.lang.String exemptionReason, java.lang.String basisAmount, java.lang.String basisAmountCurr, java.lang.String category, java.lang.String percent)
Imports tax data.protected void
importTradeParty(org.w3c.dom.Element parent, java.lang.String id, java.lang.String[] globalID, java.lang.String[] globalIDScheme, java.lang.String name, java.lang.String postcode, java.lang.String lineOne, java.lang.String lineTwo, java.lang.String cityName, java.lang.String countryID, java.lang.String[] taxRegistrationID, java.lang.String[] taxRegistrationSchemeID)
Imports trade party information (could be seller, buyer or invoicee).protected static void
removeEmptyNodes(org.w3c.dom.Node node)
It is forbidden for a ZUGFeRD XML to contain empty tags, hence we use this method recursively to remove empty nodes.byte[]
toXML()
Exports the Document as an XML file.
-
-
-
Field Detail
-
COUNTRY_CODE
public static final CountryCode COUNTRY_CODE
-
CURR_CODE
public static final CurrencyCode CURR_CODE
-
DF_CODE
public static final DateFormatCode DF_CODE
-
GI_CODE
public static final GlobalIdentifierCode GI_CODE
-
M_UNIT_CODE
public static final MeasurementUnitCode M_UNIT_CODE
-
DEC2
public static final NumberChecker DEC2
-
DEC4
public static final NumberChecker DEC4
-
PM_CODE
public static final PaymentMeansCode PM_CODE
-
TC_CODE
public static final TaxCategoryCode TC_CODE
-
TIDT_CODE
public static final TaxIDTypeCode TIDT_CODE
-
TT_CODE
public static final TaxTypeCode TT_CODE
-
doc
protected final org.w3c.dom.Document doc
-
-
Constructor Detail
-
InvoiceDOM
public InvoiceDOM(BasicProfile data) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException, DataIncompleteException, InvalidCodeException
Creates an object that will import data into an XML template.- Parameters:
data
- If this is an instance of BASICInvoice, the BASIC profile will be used; If this is an instance of COMFORTInvoice, the COMFORT profile will be used.- Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
DataIncompleteException
InvalidCodeException
-
-
Method Detail
-
importData
private void importData(org.w3c.dom.Document doc, BasicProfile data) throws DataIncompleteException, InvalidCodeException
Imports the data into the XML template.- Parameters:
doc
- the Document object we are going to populatedata
- the interface that gives us access to the data- Throws:
InvalidCodeException
DataIncompleteException
-
importSpecifiedExchangedDocumentContext
protected void importSpecifiedExchangedDocumentContext(org.w3c.dom.Element element, BasicProfile data)
Imports the data for the following tag: rsm:SpecifiedExchangedDocumentContext- Parameters:
element
- the rsm:SpecifiedExchangedDocumentContext elementdata
- the invoice data
-
importHeaderExchangedDocument
protected void importHeaderExchangedDocument(org.w3c.dom.Element element, BasicProfile data) throws DataIncompleteException, InvalidCodeException
Imports the data for the following tag: rsm:HeaderExchangedDocument- Parameters:
element
- the rsm:HeaderExchangedDocument elementdata
- the invoice data- Throws:
DataIncompleteException
InvalidCodeException
-
importContent
protected void importContent(org.w3c.dom.Element parent, java.lang.String tag, java.lang.String content, java.lang.String... attributes)
Helper method to set the content of a tag.- Parameters:
parent
- the parent element of the tagtag
- the tag for which we want to set the contentcontent
- the new content for the tagattributes
- a sequence of attributes of which the odd elements are keys, the even elements the corresponding value.
-
importDateTime
protected void importDateTime(org.w3c.dom.Element parent, java.lang.String tag, java.lang.String dateTimeFormat, java.util.Date dateTime) throws InvalidCodeException
Set the content of a date tag along with the attribute that defines the format.- Parameters:
parent
- the parent element that holds the date tagtag
- the date tag we want to changedateTimeFormat
- the format that will be used as an attributedateTime
- the actual date- Throws:
InvalidCodeException
-
importIncludedNotes
protected void importIncludedNotes(org.w3c.dom.Element parent, int level, java.lang.String[][] notes, java.lang.String[] notesCodes) throws DataIncompleteException, InvalidCodeException
Includes notes and (in case of the COMFORT profile) the subject codes for those notes.- Parameters:
parent
- the parent element of the tag we want to changelevel
- the level where the notices are added (header or line)notes
- array of notesnotesCodes
- array of codes for the notes. If not null, notes and notesCodes need to have an equal number of elements.- Throws:
DataIncompleteException
InvalidCodeException
-
importSpecifiedSupplyChainTradeTransaction
protected void importSpecifiedSupplyChainTradeTransaction(org.w3c.dom.Element element, BasicProfile data) throws DataIncompleteException, InvalidCodeException
Imports the data for the following tag: rsm:SpecifiedSupplyChainTradeTransaction- Parameters:
element
-data
- the invoice data- Throws:
DataIncompleteException
InvalidCodeException
-
importSellerTradeParty
protected void importSellerTradeParty(org.w3c.dom.Element parent, BasicProfile data) throws DataIncompleteException, InvalidCodeException
Gets the seller trade party data to import this data.- Parameters:
parent
- the parent elementdata
- the data- Throws:
DataIncompleteException
InvalidCodeException
-
importBuyerTradeParty
protected void importBuyerTradeParty(org.w3c.dom.Element parent, BasicProfile data) throws DataIncompleteException, InvalidCodeException
Gets the buyer trade party data to import this data.- Parameters:
parent
- the parent elementdata
- the data- Throws:
DataIncompleteException
InvalidCodeException
-
importInvoiceeTradeParty
protected void importInvoiceeTradeParty(org.w3c.dom.Element parent, ComfortProfile data) throws DataIncompleteException, InvalidCodeException
Gets the invoicee party data to import this data.- Parameters:
parent
- the parent elementdata
- the data- Throws:
DataIncompleteException
InvalidCodeException
-
importTradeParty
protected void importTradeParty(org.w3c.dom.Element parent, java.lang.String id, java.lang.String[] globalID, java.lang.String[] globalIDScheme, java.lang.String name, java.lang.String postcode, java.lang.String lineOne, java.lang.String lineTwo, java.lang.String cityName, java.lang.String countryID, java.lang.String[] taxRegistrationID, java.lang.String[] taxRegistrationSchemeID) throws DataIncompleteException, InvalidCodeException
Imports trade party information (could be seller, buyer or invoicee).- Parameters:
parent
- the parent elementid
-globalID
-globalIDScheme
-name
-postcode
-lineOne
-lineTwo
-countryID
-cityName
-taxRegistrationID
-taxRegistrationSchemeID
-- Throws:
DataIncompleteException
InvalidCodeException
-
importPaymentMeans
protected void importPaymentMeans(org.w3c.dom.Element parent, BasicProfile data) throws InvalidCodeException
Gets the payment means data to imports this data.- Parameters:
parent
- the parent elementdata
- the data- Throws:
InvalidCodeException
-
importPaymentMeans
protected void importPaymentMeans(org.w3c.dom.Element parent, java.lang.String typeCode, java.lang.String[] information, java.lang.String id, java.lang.String scheme, java.lang.String payerIban, java.lang.String payerProprietaryID, java.lang.String iban, java.lang.String accName, java.lang.String accID, java.lang.String payerBic, java.lang.String payerBank, java.lang.String payerInst, java.lang.String bic, java.lang.String bank, java.lang.String inst) throws InvalidCodeException
Imports payment means data.- Parameters:
parent
- the parent elementtypeCode
-information
-id
-scheme
-payerIban
-payerProprietaryID
-iban
-accID
-accName
-payerBic
-payerBank
-inst
-bic
-bank
-payerInst
-- Throws:
InvalidCodeException
-
importTax
protected void importTax(org.w3c.dom.Element parent, BasicProfile data) throws InvalidCodeException, DataIncompleteException
Gets tax data to import the this data.- Parameters:
parent
- the parent elementdata
- the data- Throws:
DataIncompleteException
InvalidCodeException
-
importTax
protected void importTax(org.w3c.dom.Element parent, java.lang.String calculatedAmount, java.lang.String currencyID, java.lang.String typeCode, java.lang.String exemptionReason, java.lang.String basisAmount, java.lang.String basisAmountCurr, java.lang.String category, java.lang.String percent) throws InvalidCodeException, DataIncompleteException
Imports tax data.- Parameters:
parent
-calculatedAmount
-currencyID
-typeCode
-exemptionReason
-basisAmount
-basisAmountCurr
-category
-percent
-- Throws:
InvalidCodeException
DataIncompleteException
-
importSpecifiedTradeAllowanceCharge
protected void importSpecifiedTradeAllowanceCharge(org.w3c.dom.Element parent, ComfortProfile data) throws InvalidCodeException
Gets specified trade allowance charge data to import the this data.- Parameters:
parent
- the parent elementdata
- the data- Throws:
InvalidCodeException
-
importSpecifiedTradeAllowanceCharge
protected void importSpecifiedTradeAllowanceCharge(org.w3c.dom.Element parent, boolean indicator, java.lang.String actualAmount, java.lang.String actualAmountCurrency, java.lang.String reason, java.lang.String[] typeCode, java.lang.String[] categoryCode, java.lang.String[] percent) throws InvalidCodeException
Imports specified trade allowance charge.- Parameters:
parent
-indicator
-actualAmount
-actualAmountCurrency
-reason
-typeCode
-categoryCode
-percent
-- Throws:
InvalidCodeException
-
importSpecifiedLogisticsServiceCharge
protected void importSpecifiedLogisticsServiceCharge(org.w3c.dom.Element parent, ComfortProfile data) throws InvalidCodeException
Gets specified logistics service charge data to import the this data.- Parameters:
parent
- the parent elementdata
- the data- Throws:
InvalidCodeException
-
importSpecifiedLogisticsServiceCharge
protected void importSpecifiedLogisticsServiceCharge(org.w3c.dom.Element parent, java.lang.String[] description, java.lang.String appliedAmount, java.lang.String currencyID, java.lang.String[] typeCode, java.lang.String[] categoryCode, java.lang.String[] percent) throws InvalidCodeException
Imports specified logistics service charge data.- Parameters:
parent
- the parent elementdescription
-appliedAmount
-currencyID
-typeCode
-categoryCode
-percent
-- Throws:
InvalidCodeException
-
importSpecifiedTradePaymentTerms
protected void importSpecifiedTradePaymentTerms(org.w3c.dom.Element parent, ComfortProfile data) throws InvalidCodeException
Gets specified trade payment terms data to import the this data.- Parameters:
parent
- the parent elementdata
- the data- Throws:
InvalidCodeException
-
importSpecifiedTradePaymentTerms
protected void importSpecifiedTradePaymentTerms(org.w3c.dom.Element parent, java.lang.String[] description, java.util.Date dateTime, java.lang.String dateTimeFormat) throws InvalidCodeException
Imports specified trade payment terms.- Parameters:
parent
- the parent elementdescription
-dateTime
-dateTimeFormat
-- Throws:
InvalidCodeException
-
importLineItemsComfort
protected void importLineItemsComfort(org.w3c.dom.Element parent, ComfortProfile data) throws DataIncompleteException, InvalidCodeException
Gets line item data to import the this data (comfort profile).- Parameters:
parent
- the parent elementdata
- the data- Throws:
DataIncompleteException
InvalidCodeException
-
importLineItemComfort
protected void importLineItemComfort(org.w3c.dom.Element parent, java.lang.String lineID, java.lang.String[][] note, java.lang.String grossPriceChargeAmount, java.lang.String grossPriceChargeAmountCurrencyID, java.lang.String grossPriceBasisQuantity, java.lang.String grossPriceBasisQuantityCode, java.lang.Boolean[] grossPriceTradeAllowanceChargeIndicator, java.lang.String[] grossPriceTradeAllowanceChargeActualAmount, java.lang.String[] grossPriceTradeAllowanceChargeActualAmountCurrencyID, java.lang.String[] grossPriceTradeAllowanceChargeReason, java.lang.String netPriceChargeAmount, java.lang.String netPriceChargeAmountCurrencyID, java.lang.String netPriceBasisQuantity, java.lang.String netPriceBasisQuantityCode, java.lang.String billedQuantity, java.lang.String billedQuantityCode, java.lang.String[] settlementTaxTypeCode, java.lang.String[] settlementTaxExemptionReason, java.lang.String[] settlementTaxCategoryCode, java.lang.String[] settlementTaxApplicablePercent, java.lang.String totalAmount, java.lang.String totalAmountCurrencyID, java.lang.String specifiedTradeProductGlobalID, java.lang.String specifiedTradeProductSchemeID, java.lang.String specifiedTradeProductSellerAssignedID, java.lang.String specifiedTradeProductBuyerAssignedID, java.lang.String specifiedTradeProductName, java.lang.String specifiedTradeProductDescription) throws DataIncompleteException, InvalidCodeException
Imports line item data (comfort profile).- Parameters:
parent
- the parent elementlineID
-note
-grossPriceChargeAmount
-grossPriceChargeAmountCurrencyID
-grossPriceBasisQuantity
-grossPriceBasisQuantityCode
-grossPriceTradeAllowanceChargeIndicator
-grossPriceTradeAllowanceChargeActualAmount
-grossPriceTradeAllowanceChargeActualAmountCurrencyID
-grossPriceTradeAllowanceChargeReason
-netPriceChargeAmount
-netPriceChargeAmountCurrencyID
-netPriceBasisQuantity
-netPriceBasisQuantityCode
-billedQuantity
-billedQuantityCode
-settlementTaxTypeCode
-settlementTaxExemptionReason
-settlementTaxCategoryCode
-settlementTaxApplicablePercent
-totalAmount
-totalAmountCurrencyID
-specifiedTradeProductGlobalID
-specifiedTradeProductSchemeID
-specifiedTradeProductSellerAssignedID
-specifiedTradeProductBuyerAssignedID
-specifiedTradeProductName
-specifiedTradeProductDescription
-- Throws:
DataIncompleteException
InvalidCodeException
-
importAppliedTradeAllowanceCharge
protected void importAppliedTradeAllowanceCharge(org.w3c.dom.Element parent, boolean indicator, java.lang.String actualAmount, java.lang.String currencyID, java.lang.String reason) throws DataIncompleteException, InvalidCodeException
Imports applied trade allowance charge data (line items).- Parameters:
parent
- the parent elementindicator
-actualAmount
-currencyID
-reason
-- Throws:
DataIncompleteException
InvalidCodeException
-
importTax
protected void importTax(org.w3c.dom.Element parent, java.lang.String typeCode, java.lang.String exemptionReason, java.lang.String category, java.lang.String percent) throws InvalidCodeException, DataIncompleteException
Imports tax data.- Parameters:
parent
- the parent elementtypeCode
-exemptionReason
-category
-percent
-- Throws:
InvalidCodeException
DataIncompleteException
-
importLineItemsBasic
protected void importLineItemsBasic(org.w3c.dom.Element parent, BasicProfile data) throws DataIncompleteException, InvalidCodeException
Gets line data to import the this data (basic profile).- Parameters:
parent
-data
-- Throws:
DataIncompleteException
InvalidCodeException
-
importLineItemBasic
protected void importLineItemBasic(org.w3c.dom.Element parent, java.lang.String quantity, java.lang.String code, java.lang.String name) throws InvalidCodeException
Imports the data for a line item (basic profile)- Parameters:
parent
- the parent elementquantity
-code
-name
-- Throws:
InvalidCodeException
-
toXML
public byte[] toXML() throws javax.xml.transform.TransformerException
Exports the Document as an XML file.- Returns:
- a byte[] with the data in XML format
- Throws:
javax.xml.transform.TransformerException
-
removeEmptyNodes
protected static void removeEmptyNodes(org.w3c.dom.Node node)
It is forbidden for a ZUGFeRD XML to contain empty tags, hence we use this method recursively to remove empty nodes.- Parameters:
node
- the node from which we want to remove the empty nodes
-
check
protected void check(java.lang.String s, java.lang.String message) throws DataIncompleteException
Checks if a string is empty and throws a DataIncompleteException if so.- Parameters:
s
- the String to checkmessage
- the message if an exception is thrown- Throws:
DataIncompleteException
-
-