Class EinvFactory() Professional
Class for creating invoices of the appropriate scenario.
The EinvFactory class is the usual entry point into the e-invoice framework. Based on the countries of the seller and the buyer, it selects the appropriate scenario subclass of AbstractEinvoice() and creates a DomesticEinvoice(), IntraEuEinvoice(), ExportEinvoice() or ManualEinvoice() object. The seller and the buyer are assigned to the new invoice via :setSeller() and :addRecipient().
The class provides the following class methods:
EinvFactory():createInvoice() - Selects the scenario automatically. If the seller is located outside the EU, a ManualEinvoice/( object is created.
EinvFactory():createManualInvoice() - Always creates a ManualEinvoice() object. This method can be used if the automatic scenarios do not apply, for example for a seller located outside the EU, for a special VAT scheme or if the country of the buyer is not known.
The returned invoice object is completed via its builder methods, for example :addLineItem(), like any other invoice. The XML document is then produced via :toXRechnung() or :toZugferd().
LOCAL oInvoice, cXml
oInvoice := EinvFactory():createInvoice( oSeller, oBuyer, "INV-2024-00011", Date() )
oInvoice:setCurrency( "EUR" )
oInvoice:addLineItem( EinvoiceLineItem():new():setName( "Widget" ):setQuantity(2):setPrice(9.5) )
IF oInvoice:validate():Valid
cXml := oInvoice:toXRechnung()
ENDIF
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.