com.itextpdf.text.zugferd
Class InvoiceDOM

java.lang.Object
  extended by com.itextpdf.text.zugferd.InvoiceDOM

public class InvoiceDOM
extends Object

Author:
iText

Field Summary
static CountryCode COUNTRY_CODE
           
static CurrencyCode CURR_CODE
           
static NumberChecker DEC2
           
static NumberChecker DEC4
           
static DateFormatCode DF_CODE
           
protected  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
InvoiceDOM(BasicProfile data)
          Creates an object that will import data into an XML template.
 
Method Summary
protected  void check(String s, String message)
          Checks if a string is empty and throws a DataIncompleteException if so.
protected  void importAppliedTradeAllowanceCharge(Element parent, boolean indicator, String actualAmount, String currencyID, String reason)
          Imports applied trade allowance charge data (line items).
protected  void importBuyerTradeParty(Element parent, BasicProfile data)
          Gets the buyer trade party data to import this data.
protected  void importContent(Element parent, String tag, String content, String... attributes)
          Helper method to set the content of a tag.
protected  void importDateTime(Element parent, String tag, String dateTimeFormat, Date dateTime)
          Set the content of a date tag along with the attribute that defines the format.
protected  void importHeaderExchangedDocument(Element element, BasicProfile data)
          Imports the data for the following tag: rsm:HeaderExchangedDocument
protected  void importIncludedNotes(Element parent, int level, String[][] notes, String[] notesCodes)
          Includes notes and (in case of the COMFORT profile) the subject codes for those notes.
protected  void importInvoiceeTradeParty(Element parent, ComfortProfile data)
          Gets the invoicee party data to import this data.
protected  void importLineItemBasic(Element parent, String quantity, String code, String name)
          Imports the data for a line item (basic profile)
protected  void importLineItemComfort(Element parent, String lineID, String[][] note, String grossPriceChargeAmount, String grossPriceChargeAmountCurrencyID, String grossPriceBasisQuantity, String grossPriceBasisQuantityCode, Boolean[] grossPriceTradeAllowanceChargeIndicator, String[] grossPriceTradeAllowanceChargeActualAmount, String[] grossPriceTradeAllowanceChargeActualAmountCurrencyID, String[] grossPriceTradeAllowanceChargeReason, String netPriceChargeAmount, String netPriceChargeAmountCurrencyID, String netPriceBasisQuantity, String netPriceBasisQuantityCode, String billedQuantity, String billedQuantityCode, String[] settlementTaxTypeCode, String[] settlementTaxExemptionReason, String[] settlementTaxCategoryCode, String[] settlementTaxApplicablePercent, String totalAmount, String totalAmountCurrencyID, String specifiedTradeProductGlobalID, String specifiedTradeProductSchemeID, String specifiedTradeProductSellerAssignedID, String specifiedTradeProductBuyerAssignedID, String specifiedTradeProductName, String specifiedTradeProductDescription)
          Imports line item data (comfort profile).
protected  void importLineItemsBasic(Element parent, BasicProfile data)
          Gets line data to import the this data (basic profile).
protected  void importLineItemsComfort(Element parent, ComfortProfile data)
          Gets line item data to import the this data (comfort profile).
protected  void importPaymentMeans(Element parent, BasicProfile data)
          Gets the payment means data to imports this data.
protected  void importPaymentMeans(Element parent, String typeCode, String[] information, String id, String scheme, String payerIban, String payerProprietaryID, String iban, String accName, String accID, String payerBic, String payerBank, String payerInst, String bic, String bank, String inst)
          Imports payment means data.
protected  void importSellerTradeParty(Element parent, BasicProfile data)
          Gets the seller trade party data to import this data.
protected  void importSpecifiedExchangedDocumentContext(Element element, BasicProfile data)
          Imports the data for the following tag: rsm:SpecifiedExchangedDocumentContext
protected  void importSpecifiedLogisticsServiceCharge(Element parent, ComfortProfile data)
          Gets specified logistics service charge data to import the this data.
protected  void importSpecifiedLogisticsServiceCharge(Element parent, String[] description, String appliedAmount, String currencyID, String[] typeCode, String[] categoryCode, String[] percent)
          Imports specified logistics service charge data.
protected  void importSpecifiedSupplyChainTradeTransaction(Element element, BasicProfile data)
          Imports the data for the following tag: rsm:SpecifiedSupplyChainTradeTransaction
protected  void importSpecifiedTradeAllowanceCharge(Element parent, boolean indicator, String actualAmount, String actualAmountCurrency, String reason, String[] typeCode, String[] categoryCode, String[] percent)
          Imports specified trade allowance charge.
protected  void importSpecifiedTradeAllowanceCharge(Element parent, ComfortProfile data)
          Gets specified trade allowance charge data to import the this data.
protected  void importSpecifiedTradePaymentTerms(Element parent, ComfortProfile data)
          Gets specified trade payment terms data to import the this data.
protected  void importSpecifiedTradePaymentTerms(Element parent, String[] description, Date dateTime, String dateTimeFormat)
          Imports specified trade payment terms.
protected  void importTax(Element parent, BasicProfile data)
          Gets tax data to import the this data.
protected  void importTax(Element parent, String typeCode, String exemptionReason, String category, String percent)
          Imports tax data.
protected  void importTax(Element parent, String calculatedAmount, String currencyID, String typeCode, String exemptionReason, String basisAmount, String basisAmountCurr, String category, String percent)
          Imports tax data.
protected  void importTradeParty(Element parent, String id, String[] globalID, String[] globalIDScheme, String name, String postcode, String lineOne, String lineTwo, String cityName, String countryID, String[] taxRegistrationID, String[] taxRegistrationSchemeID)
          Imports trade party information (could be seller, buyer or invoicee).
protected static void removeEmptyNodes(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 Document doc
Constructor Detail

InvoiceDOM

public InvoiceDOM(BasicProfile data)
           throws ParserConfigurationException,
                  SAXException,
                  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:
ParserConfigurationException
SAXException
IOException
DataIncompleteException
InvalidCodeException
Method Detail

importSpecifiedExchangedDocumentContext

protected void importSpecifiedExchangedDocumentContext(Element element,
                                                       BasicProfile data)
Imports the data for the following tag: rsm:SpecifiedExchangedDocumentContext

Parameters:
element - the rsm:SpecifiedExchangedDocumentContext element
data - the invoice data

importHeaderExchangedDocument

protected void importHeaderExchangedDocument(Element element,
                                             BasicProfile data)
                                      throws DataIncompleteException,
                                             InvalidCodeException
Imports the data for the following tag: rsm:HeaderExchangedDocument

Parameters:
element - the rsm:HeaderExchangedDocument element
data - the invoice data
Throws:
DataIncompleteException
InvalidCodeException

importContent

protected void importContent(Element parent,
                             String tag,
                             String content,
                             String... attributes)
Helper method to set the content of a tag.

Parameters:
parent - the parent element of the tag
tag - the tag for which we want to set the content
content - the new content for the tag
attributes - a sequence of attributes of which the odd elements are keys, the even elements the corresponding value.

importDateTime

protected void importDateTime(Element parent,
                              String tag,
                              String dateTimeFormat,
                              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 tag
tag - the date tag we want to change
dateTimeFormat - the format that will be used as an attribute
dateTime - the actual date
Throws:
InvalidCodeException

importIncludedNotes

protected void importIncludedNotes(Element parent,
                                   int level,
                                   String[][] notes,
                                   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 change
level - the level where the notices are added (header or line)
notes - array of notes
notesCodes - 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(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(Element parent,
                                      BasicProfile data)
                               throws DataIncompleteException,
                                      InvalidCodeException
Gets the seller trade party data to import this data.

Parameters:
parent - the parent element
data - the data
Throws:
DataIncompleteException
InvalidCodeException

importBuyerTradeParty

protected void importBuyerTradeParty(Element parent,
                                     BasicProfile data)
                              throws DataIncompleteException,
                                     InvalidCodeException
Gets the buyer trade party data to import this data.

Parameters:
parent - the parent element
data - the data
Throws:
DataIncompleteException
InvalidCodeException

importInvoiceeTradeParty

protected void importInvoiceeTradeParty(Element parent,
                                        ComfortProfile data)
                                 throws DataIncompleteException,
                                        InvalidCodeException
Gets the invoicee party data to import this data.

Parameters:
parent - the parent element
data - the data
Throws:
DataIncompleteException
InvalidCodeException

importTradeParty

protected void importTradeParty(Element parent,
                                String id,
                                String[] globalID,
                                String[] globalIDScheme,
                                String name,
                                String postcode,
                                String lineOne,
                                String lineTwo,
                                String cityName,
                                String countryID,
                                String[] taxRegistrationID,
                                String[] taxRegistrationSchemeID)
                         throws DataIncompleteException,
                                InvalidCodeException
Imports trade party information (could be seller, buyer or invoicee).

Parameters:
parent - the parent element
id -
globalID -
globalIDScheme -
name -
postcode -
lineOne -
lineTwo -
countryID -
cityName -
taxRegistrationID -
taxRegistrationSchemeID -
Throws:
DataIncompleteException
InvalidCodeException

importPaymentMeans

protected void importPaymentMeans(Element parent,
                                  BasicProfile data)
                           throws InvalidCodeException
Gets the payment means data to imports this data.

Parameters:
parent - the parent element
data - the data
Throws:
InvalidCodeException

importPaymentMeans

protected void importPaymentMeans(Element parent,
                                  String typeCode,
                                  String[] information,
                                  String id,
                                  String scheme,
                                  String payerIban,
                                  String payerProprietaryID,
                                  String iban,
                                  String accName,
                                  String accID,
                                  String payerBic,
                                  String payerBank,
                                  String payerInst,
                                  String bic,
                                  String bank,
                                  String inst)
                           throws InvalidCodeException
Imports payment means data.

Parameters:
parent - the parent element
typeCode -
information -
id -
scheme -
payerIban -
payerProprietaryID -
iban -
accID -
accName -
payerBic -
payerBank -
inst -
bic -
bank -
payerInst -
Throws:
InvalidCodeException

importTax

protected void importTax(Element parent,
                         BasicProfile data)
                  throws InvalidCodeException,
                         DataIncompleteException
Gets tax data to import the this data.

Parameters:
parent - the parent element
data - the data
Throws:
DataIncompleteException
InvalidCodeException

importTax

protected void importTax(Element parent,
                         String calculatedAmount,
                         String currencyID,
                         String typeCode,
                         String exemptionReason,
                         String basisAmount,
                         String basisAmountCurr,
                         String category,
                         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(Element parent,
                                                   ComfortProfile data)
                                            throws InvalidCodeException
Gets specified trade allowance charge data to import the this data.

Parameters:
parent - the parent element
data - the data
Throws:
InvalidCodeException

importSpecifiedTradeAllowanceCharge

protected void importSpecifiedTradeAllowanceCharge(Element parent,
                                                   boolean indicator,
                                                   String actualAmount,
                                                   String actualAmountCurrency,
                                                   String reason,
                                                   String[] typeCode,
                                                   String[] categoryCode,
                                                   String[] percent)
                                            throws InvalidCodeException
Imports specified trade allowance charge.

Parameters:
parent -
indicator -
actualAmount -
actualAmountCurrency -
reason -
typeCode -
categoryCode -
percent -
Throws:
InvalidCodeException

importSpecifiedLogisticsServiceCharge

protected void importSpecifiedLogisticsServiceCharge(Element parent,
                                                     ComfortProfile data)
                                              throws InvalidCodeException
Gets specified logistics service charge data to import the this data.

Parameters:
parent - the parent element
data - the data
Throws:
InvalidCodeException

importSpecifiedLogisticsServiceCharge

protected void importSpecifiedLogisticsServiceCharge(Element parent,
                                                     String[] description,
                                                     String appliedAmount,
                                                     String currencyID,
                                                     String[] typeCode,
                                                     String[] categoryCode,
                                                     String[] percent)
                                              throws InvalidCodeException
Imports specified logistics service charge data.

Parameters:
parent - the parent element
description -
appliedAmount -
currencyID -
typeCode -
categoryCode -
percent -
Throws:
InvalidCodeException

importSpecifiedTradePaymentTerms

protected void importSpecifiedTradePaymentTerms(Element parent,
                                                ComfortProfile data)
                                         throws InvalidCodeException
Gets specified trade payment terms data to import the this data.

Parameters:
parent - the parent element
data - the data
Throws:
InvalidCodeException

importSpecifiedTradePaymentTerms

protected void importSpecifiedTradePaymentTerms(Element parent,
                                                String[] description,
                                                Date dateTime,
                                                String dateTimeFormat)
                                         throws InvalidCodeException
Imports specified trade payment terms.

Parameters:
parent - the parent element
description -
dateTime -
dateTimeFormat -
Throws:
InvalidCodeException

importLineItemsComfort

protected void importLineItemsComfort(Element parent,
                                      ComfortProfile data)
                               throws DataIncompleteException,
                                      InvalidCodeException
Gets line item data to import the this data (comfort profile).

Parameters:
parent - the parent element
data - the data
Throws:
DataIncompleteException
InvalidCodeException

importLineItemComfort

protected void importLineItemComfort(Element parent,
                                     String lineID,
                                     String[][] note,
                                     String grossPriceChargeAmount,
                                     String grossPriceChargeAmountCurrencyID,
                                     String grossPriceBasisQuantity,
                                     String grossPriceBasisQuantityCode,
                                     Boolean[] grossPriceTradeAllowanceChargeIndicator,
                                     String[] grossPriceTradeAllowanceChargeActualAmount,
                                     String[] grossPriceTradeAllowanceChargeActualAmountCurrencyID,
                                     String[] grossPriceTradeAllowanceChargeReason,
                                     String netPriceChargeAmount,
                                     String netPriceChargeAmountCurrencyID,
                                     String netPriceBasisQuantity,
                                     String netPriceBasisQuantityCode,
                                     String billedQuantity,
                                     String billedQuantityCode,
                                     String[] settlementTaxTypeCode,
                                     String[] settlementTaxExemptionReason,
                                     String[] settlementTaxCategoryCode,
                                     String[] settlementTaxApplicablePercent,
                                     String totalAmount,
                                     String totalAmountCurrencyID,
                                     String specifiedTradeProductGlobalID,
                                     String specifiedTradeProductSchemeID,
                                     String specifiedTradeProductSellerAssignedID,
                                     String specifiedTradeProductBuyerAssignedID,
                                     String specifiedTradeProductName,
                                     String specifiedTradeProductDescription)
                              throws DataIncompleteException,
                                     InvalidCodeException
Imports line item data (comfort profile).

Parameters:
parent - the parent element
lineID -
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(Element parent,
                                                 boolean indicator,
                                                 String actualAmount,
                                                 String currencyID,
                                                 String reason)
                                          throws DataIncompleteException,
                                                 InvalidCodeException
Imports applied trade allowance charge data (line items).

Parameters:
parent - the parent element
indicator -
actualAmount -
currencyID -
reason -
Throws:
DataIncompleteException
InvalidCodeException

importTax

protected void importTax(Element parent,
                         String typeCode,
                         String exemptionReason,
                         String category,
                         String percent)
                  throws InvalidCodeException,
                         DataIncompleteException
Imports tax data.

Parameters:
parent - the parent element
typeCode -
exemptionReason -
category -
percent -
Throws:
InvalidCodeException
DataIncompleteException

importLineItemsBasic

protected void importLineItemsBasic(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(Element parent,
                                   String quantity,
                                   String code,
                                   String name)
                            throws InvalidCodeException
Imports the data for a line item (basic profile)

Parameters:
parent - the parent element
quantity -
code -
name -
Throws:
InvalidCodeException

toXML

public byte[] toXML()
             throws TransformerException
Exports the Document as an XML file.

Returns:
a byte[] with the data in XML format
Throws:
TransformerException

removeEmptyNodes

protected static void removeEmptyNodes(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(String s,
                     String message)
              throws DataIncompleteException
Checks if a string is empty and throws a DataIncompleteException if so.

Parameters:
s - the String to check
message - the message if an exception is thrown
Throws:
DataIncompleteException


Copyright © 2015. All Rights Reserved.