GenerateInvoiceXML
PDF/A and compliance
Description
Generates a compliant Factur-X / ZUGFeRD EN 16931 CrossIndustryInvoice (CII D16B) or OASIS UBL 2.1 electronic invoice XML payload with automatic VAT category grouping and monetary summation
Syntax
Delphi
Function GenerateInvoiceXML(Format: Integer; Const InvoiceID, IssueDate, CurrencyCode, SellerName, SellerVATID, BuyerName, BuyerVATID, LineItemsSpec: WideString): WideString;ActiveX
Function PDFlib::GenerateInvoiceXML(Format As Long, InvoiceID As String, IssueDate As String, CurrencyCode As String, SellerName As String, SellerVATID As String, BuyerName As String, BuyerVATID As String, LineItemsSpec As String) As StringDLL
const wchar_t* DLGenerateInvoiceXML(int InstanceID, int Format, const wchar_t* InvoiceID, const wchar_t* IssueDate, const wchar_t* CurrencyCode, const wchar_t* SellerName, const wchar_t* SellerVATID, const wchar_t* BuyerName, const wchar_t* BuyerVATID, const wchar_t* LineItemsSpec);
const char* DLGenerateInvoiceXMLA(int InstanceID, int Format, const char* InvoiceID, const char* IssueDate, const char* CurrencyCode, const char* SellerName, const char* SellerVATID, const char* BuyerName, const char* BuyerVATID, const char* LineItemsSpec);Parameters
| Format | 0 for Factur-X / ZUGFeRD EN 16931 CII XML, or 1 for OASIS UBL 2.1 Invoice XML |
|---|---|
| InvoiceID | Invoice document identifier (BT-1) |
| IssueDate | Invoice issue date in YYYY-MM-DD or YYYYMMDD format (BT-2) |
| CurrencyCode | ISO 4217 3-letter currency code such as EUR or USD (BT-5) |
| SellerName | Seller trading name (BT-27) |
| SellerVATID | Seller VAT identifier prefixed with country code (BT-31) |
| BuyerName | Buyer trading name (BT-44) |
| BuyerVATID | Buyer VAT identifier prefixed with country code (BT-48) |
| LineItemsSpec | Semicolon-separated line items formatted as Name|Quantity|NetUnitPrice|TaxRatePercent|UnitCode|TaxCategoryCode |
Return values
Unicode XML text containing the generated CII or UBL 2.1 invoice document; encode it as UTF-8 when writing a file, or inspect LastErrorCode when the result is empty
Remarks
Quantities, unit prices, and tax rates retain the precision needed to round-trip their numeric values; decimal output has no exponents and at least two fractional digits
VAT groups use the category and exact numeric rate, keeping distinct rates separate even when their difference is below 0.001
Invalid, non-finite, or out-of-range numeric operands return an empty string and set LastErrorCode to 125 (PDFLIB_ERROR_INVOICE_INVALID); a subsequent successful call clears that error
The same happens for an empty invoice identifier, an issue date that is not a calendar date in one of the two formats, a currency code that is not three letters, and an empty line item list. No default is substituted for any of them
See also
ValidateInvoiceBusinessRulesBuiltIn, ValidateInvoiceBusinessRulesWithTools