Working with XRechnung

Events

We offer you the possibility to link into our programming logic with events, here we describe how this works.

To subscribe an event for sales invoices or service invoices, the XML port BEL365 S. Inv. XRechnung 2.0 must be specified in an EventSubscriber.

Example:

1
[EventSubscriber(ObjectType::XmlPort, XmlPort::"BEL365 S. Inv. XRechnung 2.0", 'OnAfterGetLineInvoicePeriodInfo', "", true, true)]

For sales credit notes or service credit notes, the following XML port must be entered: BEL365 S. Cr. M. XRechnung 2.0.

Example:

1
[EventSubscriber(ObjectType::XmlPort, XmlPort::"BEL365 S. Cr. M. XRechnung 2.0", 'OnAfterGetLineInvoicePeriodInfo', "", true, true)]

Some of the business terms listed below cannot be changed via the two XML ports mentioned above.
Connector 365 XRechnung makes partial use of functions from the Microsoft standard Codeunit: PEPPOL Management (1605).
The events concerned are provided with a note box in this documentation.



The XRechnung events offer the possibility to “fill” business terms after they are set by default and before they are further processed, i.e. inserted into the resulting XML file. The business terms are passed as text variables. Prepended to these variables is the keyword VAR, which indicates that the variables are references to the original variables.

After you have defined a function as a subscriber, you can fill the passed variables as you like and according to your own logic.

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[EventSubscriber(ObjectType::XmlPort, XmlPort::"BEL365 S. Inv. XRechnung 2.0", 'OnAfterGetLineInvoicePeriodInfo', "", true, true)]
local procedure SubAfterGetLineInvoicePeriodInfo (
    var Sender: XmlPort "BEL365 S. Inv. XRechnung 2.0"; 
    SalesLine: Record "Sales Line";
    var InvLineInvoicePeriodStartDate: Text;
    var InvLineInvoicePeriodEndDate: Text);
begin
    InvLineInvoicePeriodStartDate := format(SalesLine."Posting Date");
    InvLineInvoicePeriodEndDate := '2021-04-15';
end;

The function SubAfterGetLineInvoicePeriod is here a subscriber for the event OnAfterGetLineInvoicePeriodInfo.

Regardless of the default logic of filling the variables, InvLineInvoicePeriodEndDate after generating the XRechnung now contains the value “2021-04-15” and thus appears in the resulting XML file. The same procedure applies to all other events.

The following is a list of the available events and the variables to be changed with them.

At the beginning of the XML port, it is checked whether the document is a sales document or a service document. Then the associated record variables are transferred to the “Sales Header” and “Sales Line” variables, which are used from there on throughout the XML port. Sales Invoice Example:

“Sales Invoice Header” -> “Sales Header”,
“Sales Invoice Line” -> “Sales Line”.

This is the reason why all following events work with “Sales Header” or with “Sales Line”.

GetGeneralInfoBIS

This event originates from the Codeunit: PEPPOL Management (1605).
1
2
3
4
5
6
7
8
. SalesHeader: Record "Sales Header"
. var ID: Text                   (BT-1)
. var IssueDate: Text            (BT-2)
. var InvoiceTypeCode: Text      (BT-3)
. var Note: Text                 (BT-22)
. var TaxPointDate: Text         (BT-7)
. var DocumentCurrencyCode: Text (BT-5)
. var AccountingCost: Text       (BT-19)
Name Business Term Semantic Data Type
Invoice number BT-1 Identifier
A unique identifier for the invoice that identifies it in the seller's system.
Invoice issue date BT-2 Date
The date on which the invoice was issued.
Invoice type code BT-3 Code
A code that specifies the function type of the invoice. Note: The invoice type must be specified according to UNTDID 1001
Invoice currency code BT-5 Code
The currency in which all invoice amounts are stated, with the exception of the total VAT amount, which must be stated in the billing currency.
Value added tax point date BT-7 Date
The date on which the VAT becomes relevant for the seller and for the buyer. The application of BT-7 and 8 are mutually exclusive.
Buyer accounting reference BT-19 Text
A text value that indicates where the relevant data is to be posted in the financial costs of the acquirer.
Invoice note BT-22 Text
A text note containing unstructured information relevant to the invoice as a whole.

OnGetInvoicePeriod

1
2
3
. SalesHeader: Record "Sales Header"
. VAR InvoicePeriodStartDate : Text (BT-73)
. VAR InvoicePeriodEndDate : Text (BT-74)
Name Business Term Semantic Data Type
Invoicing period start date BT-73 Date
The date on which the billing period begins.
Invoicing period end date BT-74 Date
The date on which the billing period ends.

The OnGetInvoicePeriod event can be used to specify the service date or a service period for an invoice. A period is defined by a start and an end time, each of which should have the following format: “YYYY-MM-DD”. Example: 2017-10-01

OnAfterGetLineInvoicePeriodInfo

1
2
3
. SalesLine : Record „Sales Line“
. VAR InvLineInvoicePeriodStartDate : Text 
. VAR InvLineInvoicePeriodEndDate : Text

This event sets the service date similar to OnGetInvoicePeriod, but at the row level.

OnAfterGetAccountingSupplierPartyContact (BG-6)

1
2
3
4
5
. SalesHeader : Record “Sales Header”
. VAR ContactName : Text  (BT-41)
. VAR Telephone : Text  (BT-42)
. VAR Telefax : Text
. VAR ElectronicMail : Text  (BT-43)
Name Business Term Semantic Data Type
Seller Contact Point BT-41 Text
Details of contact person or contact point (e.g. name of a person, department or office name)
Seller contact telephone number BT-42 Text
Telephone number of the contact person or contact point
Seller contact email address BT-43 Text
E-mail address of the contact person or contact point

Business Rules:

BR-DE-2: The group „SELLER CONTACT“ (BG-6) has to be transmitted.

BR-DE-5: The element „SELLER CONTACT POINT“ (BT-41) has to be transmitted.

BR-DE-6: The element „SELLER CONTACT TELEPHONE NUMBER“ (BT-42) has to be transmitted.

BR-DE-7: The element „SELLER CONTACT EMAIL ADDRESS“ (BT-43) has to be transmitted.

OnAfterGetPaymentTermsInfo

1
2
. SalesHeader : Record „Sales Header“
. VAR PaymentTermsNote : Text (BT-20)

A text description of the payment terms that apply to the payment amount due (including a description of any discount and late payment terms.) This information element may contain multiple lines and multiple payment term specifications, and may contain both unstructured and structured text. The unstructured text must not contain #.

Specification XRechnung default and extension
Version XRechnung 2.0.0 | Version from 16.12.2020

OnGetOrderLineReference

1
2
. SalesLine : Record „Sales Line“
. VAR OrderLineReferenceLineID : Text (BT-132)

Referenced purchase or line reference

An identifier issued by the acquirer for a referenced line item of a purchase order/order.

Note: The order is referred to at invoice level.

Specification XRechnung default and extension
Version XRechnung 2.0.0 | Version from 16.12.2020

OnAfterGetPaymentMeansInfo (BG-16)

1
2
3
4
5
6
. Sales Header : Record „Sales Header“
. VAR PaymentMeansCode : Text  (BT-81)
. VAR PaymentChannelCode : Text  (BT-82)
. VAR PaymentID : Text  (BT-83)
. VAR PrimaryAccountNumberID : Text  (BT-87)
. VAR NetworkID : Text
Name Business Term Semantic Data Type
Payment means type code BT-81 Code
The means of payment expected or used, expressed as a code. Reference is made to the code list UN/ECE 4461
Payment means text BT-82 Text
The means of payment expected or used, expressed in text form
Remittance information BT-83 Text
A text value used to link the payment to the invoice issued by the seller
Payment card primary account number BT-87 Text
The number of the credit card used for the payment

Business Rules:

BR-DE-1: An invoice (INVOICE) must contain information on “PAYMENT INSTRUCTIONS” (BG-16).

BR-DE-13: The invoice must include information on one of the three groups “CREDIT TRANSFER” (BG-17), “PAYMENT CARD INFORMATION” (BG-18) or “DIRECT DEBIT” (BG-19).

OnAfterGetContractDocRefInfo

1
2
3
4
5
. SalesHeader : Record „Sales Header“
. VAR ContractDocumentReferenceID : Text (BT-12)
. VAR DocumentTypeCode : Text
. VAR ContractRefDocTypeCodeListID : Text
. VAR DocumentType : Text
Name Business Term Semantic data type
Contract reference BT-12 Document Reference
A clear description of the contract (e.g. contract number).

OnAfterGetAccountingCustomerPartyInfoBIS

1
2
3
4
5
6
. SalesHeader: Record "Sales Header"
. VAR CustomerEndpointID: Text (BT-49)
. VAR CustomerSchemeID: Text (BT-49-1)
. VAR CustomerPartyIdentificationID: Text (BT-46)
. VAR CustomerPartyIDSchemeID: Text (BT-46-1)
. VAR CustomerName: Text (BT-45)
Name Business Term Semantic Data Type
Buyer electronic address BT-49 Identifier
Specifies an electronic address of the purchaser to which an invoice should be sent.
Buyer electronic address/Scheme identifier
The formation pattern for Buyer electronic address.

The Electronic Address Scheme code list (EAS) is to be used. The code list is maintained and published by the Connecting Europe Facility.
Buyer identifier BT-46 Identifier
An identifier (usually assigned by the seller) of the purchaser, such as the customer number for accounting or the customer number for order management.

Note: No standardized scheme is required for the creation of the Buyer Identifier
The identifier of the formation scheme for the “Buyer identifier”.

Note: If the element is used, the entry must be selected from the list published by the ISO/IEC 6523 maintenance agency.
Buyer trading name BT-45 Text
A name by which the acquirer is known, if different from the acquirer's name.

OnAfterGetPaymentMeansPayeeFinancialAccBIS (BG-17)

1
2
3
. VAR PayeeFinancialAccountID : Text (BT-84)
. VAR FinancialInstitutionBranchID : Text (BT-86)
. VAR PayeeFinancialAccountName : Text (BT-85)
Name Business Term Semantic Data Type
Payment account identifier BT-84 Identifier
The identifier of the account to which the payment is to be made: IBAN for payments in the SEPA area, account number or IBAN in the case of foreign payments
Payment account name BT-85 Text
Name of the account with a payment service provider to which the payment is to be made. (e.g. account holder)

OnAfterGetLineGeneralInfo

1
2
3
4
5
6
7
8
. SalesLine : Record „Sales Line“
. SalesHeader : Record „Sales Header“
. VAR InvoiceLineID : Text
. VAR InvoiceLineNote : Text
. VAR InvoicedQuantity : Text
. VAR InvoiceLineExtensionAmount : Text
. VAR LineExtensionAmountCurrencyID : Text
. VAR InvoiceLineAccountingCost : Text

OnAfterGetLineItemInfo

1
2
3
4
5
6
7
8
 . SalesLine: Record "Sales Line"
 . VAR Description: Text
 . VAR Name: Text
 . VAR SellersItemIdentificationID: Text
 . VAR StandardItemIdentificationID: Text
 . VAR StdItemIdIDSchemeID: Text
 . VAR OriginCountryIdCode: Text
 . VAR OriginCountryIdCodeListID: Text

OnAfterGetAccountingSupplierPartyLegalEntityBIS

1
2
3
4
5
6
7
 . SalesHeader: record "Sales Header"
 . var PartyLegalEntityRegName: Text
 . var PartyLegalEntityCompanyID: Text
 . var PartyLegalEntitySchemeID: Text
 . var SupplierRegAddrCityName: Text
 . var SupplierRegAddrCountryIdCode: Text
 . var SupplRegAddrCountryIdListId: Text

OnAfterGetAccountingSupplierPartyTaxSchemeBIS

1
2
3
4
5
 . SalesHeader: record "Sales Header"
 . var TempVATAmountLine: record "VAT Amount Line"
 . var CompanyID: text
 . var CompanyIDSchemeID: text
 . var TaxSchemeID: text

OnAfterGetAccountingSupplierPartyPostalAddr

1
2
3
4
5
6
7
 . SalesHeader: record "Sales Header"
 . var StreetName: text
 . var SupplierAdditionalStreetName: text
 . var CityName: text
 . var PostalZone: text
 . var CountrySubentity: text
 . var IdentificationCoder: text

OnAfterGetAccountingSupplierPartyInfoBIS

1
2
3
 . SalesHeader: record "Sales Header"
 . var SupplierEndpointID: text (BT-34)
 . var SupplierName: text (BT-28)
Name Business Term Semantic Data Type
Seller electronic address BT-34 Identifier
Specifies the electronic address of the vendor to which the application level response to an invoice can be sent.
Seller trading name BT-28 Text
A name by which the seller is known, if different from the seller's name.

OnAfterGetAccountingCustomerPartyPostalAddr

1
2
3
4
5
6
7
 . SalesHeader: record "Sales Header"
 . var CustomerStreetName: text (BT-35)
 . var CustomerAdditionalStreetName: text (BT-36)
 . var CustomerCityName: text (BT-37)
 . var CustomerPostalZone: text (BT-38)
 . var CustomerCountrySubentity: text (BT-39)
 . var CustomerIdentificationCode: text (BT-40)

OnAfterGetAccountingCustomerPartyTaxSchemeBIS

1
2
3
4
 . SalesHeader: record "Sales Header"
 . var CustPartyTaxSchemeCompanyID: text
 . var CustPartyTaxSchemeCompIDSchID: text
 . var CustTaxSchemeID: text

OnAfterGetAccountingCustomerPartyLegalEntityBIS

1
2
3
4
 . SalesHeader: record "Sales Header"
 . var CustPartyLegalEntityRegName: text
 . var CustPartyLegalEntityCompanyID: text
 . var CustPartyLegalEntityIDSchemeID: text

OnAfterGetAccountingCustomerPartyContact

1
2
3
4
5
 . var SalesHeader: record "Sales Header"
 . var CustContactName: text
 . var CustContactTelephone: text
 . var CustContactTelefax: text
 . var CustContactElectronicMail: text

OnAfterGetGLNDeliveryInfo

1
2
3
4
 . SalesHeader: record "Sales Header"
 . var ActualDeliveryDate: text
 . var DeliveryID: text
 . var DeliveryIDSchemeID: text

OnAfterGetDeliveryAddress

1
2
3
4
5
6
7
 . SalesHeader: record "Sales Header"
 . var DeliveryStreetName: text
 . var DeliveryAdditionalStreetName: text
 . var DeliveryCityName: text
 . var DeliveryPostalZone: text
 . var DeliveryCountrySubentity: text
 . var DeliveryCountryIdCode: text

OnAfterGetLineItemClassfiedTaxCategoryBIS

1
2
3
4
5
 . SalesLine: record "Sales Line"
 . var ClassifiedTaxCategoryID: text
 . var ItemSchemeID: text
 . var InvoiceLineTaxPercent: Text
 . var ClassifiedTaxCategorySchemeID: text

OnAfterGetLineAllowanceChargeInfo

1
2
3
4
5
6
 . SalesLine: record "Sales Line"
 . SalesHeader: record "Sales Header"
 . var InvLnAllowanceChargeIndicator: text
 . var InvLnAllowanceChargeReason: text
 . var InvLnAllowanceChargeAmount: text
 . var InvLnAllowanceChargeAmtCurrID: text

OnAterGetLineDeliveryInfo

1
2
3
4
5
 . SalesLine: record "Sales Line"
 . SalesHeader: record "Sales Header"
 . var InvoiceLineActualDeliveryDate: text
 . var InvoiceLineDeliveryID: text
 . var InvoiceLineDeliveryIDSchemeID: text

OnAfterGetLineDeliveryPostalAddr

1
2
3
4
5
6
7
8
9
 . SalesLine: record "Sales Line"
 . SalesHeader: record "Sales Header"
 . var InvoiceLineDeliveryStreetName: text
 . var InvLineDeliveryAddStreetName: text
 . var InvoiceLineDeliveryCityName: text
 . var InvoiceLineDeliveryPostalZone: text
 . var InvLnDeliveryCountrySubentity: text
 . var InvLnDeliveryCountryIdCode: text
 . var InvLineDeliveryCountryListID: text

OnAfterGetTaxRepresentativePartyInfo

1
2
3
4
5
 . SalesHeader: record "Sales Header"
 . var TaxRepPartyNameName: text
 . var PayeePartyTaxSchemeCompanyID: text
 . var PayeePartyTaxSchCompIDSchemeID: text
 . var PayeePartyTaxSchemeTaxSchemeID: text

OnAfterGetAllowanceChargeInfo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 . TempVATAmountLine: record "VAT Amount Line"
 . SalesHeader: record "Sales Header"
 . var ChargeIndicator: text
 . var AllowanceChargeReasonCode: text
 . var AllowanceChargeReason: text
 . var Amount: text
 . var AllowanceChargeCurrencyID: text
 . var TaxCategoryID: text
 . var TaxCategorySchemeID: text
 . var Percent: text
 . var AllowanceChargeTaxSchemeID: text

OnAfterGetTaxExemptionReason

1
2
3
4
 . SalesHeader: record "Sales Header"
 . TempVATProductPostingGroup: record "VAT Product Posting Group"
 . var TaxExemptionReason: text
 . var TaxTotalTaxCategoryID: text

OnAfterGetLineAdditionalItemPropertyInfo

1
2
3
4
 . SalesLine: record "Sales Line"
 . SalesHeader: record "Sales Header"
 . var AdditionalItemPropertyName: Text
 . var AdditionalItemPropertyValue: Text

OnAfterGetLinePriceAllowanceChargeInfo

1
2
3
4
5
6
 . SalesHeader: record "Sales Header"
 . var PriceChargeIndicator: text
 . var PriceAllowanceChargeAmount: text
 . var PriceAllowanceAmountCurrencyID: text
 . var PriceAllowanceChargeBaseAmount: text
 . var PriceAllowChargeBaseAmtCurrID: text