Method EinvFactory():createInvoice() Professional

Creates an invoice with automatic scenario selection.

Syntax
:createInvoice( <oSeller>, <oBuyer>, <cNumber>, [<xIssueDate>] ) --> oInvoice
Parameters
<oSeller>
The seller (BG-4), specified either as an EinvoiceParty() object or as a DataObject with the corresponding members. The address of the seller must contain a country code.
<oBuyer>
The buyer (BG-7), specified either as an EinvoiceParty() object or as a DataObject with the corresponding members. The address of the buyer must contain a country code.
<cNumber>
The invoice number (BT-1).
<xIssueDate>
The issue date of the invoice (BT-2). The date can be specified as a date value or as a character string in the format "YYYY-MM-DD" or "YYYYMMDD". This defaults to the current date.
Return

A new DomesticEinvoice(), IntraEuEinvoice(), ExportEinvoice() or ManualEinvoice() object with the seller and the buyer assigned.

Description

Creates a new invoice object whose scenario is selected automatically from the countries of the seller and the buyer. The scenario is selected as follows:

ManualEinvoice() - The seller is located outside the EU. The automatic EU scenarios do not apply in this case.

DomesticEinvoice() - The buyer is located in the same country as the seller.

IntraEuEinvoice() - The buyer is located in another EU member state.

ExportEinvoice() - The buyer is located outside the EU.

Both parties are converted via EinvoiceParty():from() and assigned to the new invoice via :setSeller() and :addRecipient(). The type code and the currency keep the default values of AbstractEinvoice():init(). If other values are required, they can be assigned afterwards via :setTypeCode() and :setCurrency().

A runtime error is raised if the address of the seller or of the buyer has no country code. In this case, EinvFactory():createManualInvoice() can be used instead.

Feedback

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.