Skip to main content

Direct Debit Mandate per Document

For payment means 59 (SEPA direct debit) mseDoc365 reads the mandate (BT-89), the debtor IBAN (BT-91) and the creditor ID (BT-90) from BC — see Payment Means. A payment add-on that keeps its mandates in its own tables can supply these values through one integration event.

The event passes the source table of the posted document together with its number. A posted sales invoice and a posted sales credit memo can have the same number (for example when both use the same number series), so the number alone does not identify the document.

This event replaces OnBeforeResolveDirectDebitMandate and OnBeforeResolveDirectDebitMandateWithCreditorID. Both are obsolete because they pass the document number without the document type.

Event​

Table mseBC mseDoc365 S. Inv.Buffer (5563231):

[IntegrationEvent(false, false)]
local procedure OnBeforeResolveDirectDebitMandateForDocument(SourceTableNo: Integer; DocumentNo: Code[20]; BillToCustomerNo: Code[20]; SellToCustomerNo: Code[20]; DirectDebitMandateID: Code[35]; DueDate: Date; var ResolvedMandateID: Code[35]; var ResolvedDebtorIBAN: Code[50]; var BankAssignedCreditorID: Text[35]; var IsHandled: Boolean)
ParameterMeaning
SourceTableNoDatabase::"Sales Invoice Header" or Database::"Sales Cr.Memo Header"; 0 when a caller of SetPaymentMeansFlags does not pass it
DocumentNoNo. of the posted sales invoice or credit memo the xInvoice is built for
BillToCustomerNo, SellToCustomerNoCustomers of the document
DirectDebitMandateIDMandate ID on the document (the original invoice's mandate for a credit memo), may be empty
DueDateDue date of the document
ResolvedMandateIDReturn the mandate reference (BT-89)
ResolvedDebtorIBANReturn the debtor IBAN (BT-91); spaces are removed
BankAssignedCreditorIDReturn the creditor ID (BT-90). Leave empty to resolve it from the company bank account
IsHandledSet to true to use the returned values instead of the standard resolution

The event is raised only for payment means 59, for sales invoices and sales credit memos.

Rules for a handled mandate​

  • An empty ResolvedMandateID stops with the error No SEPA Direct Debit Mandate could be resolved ….
  • An empty ResolvedDebtorIBAN stops with the error The direct debit mandate … of customer … has no debtor IBAN.
  • An empty BankAssignedCreditorID falls back to the Creditor No. of the company bank account, including its errors when none can be found.

Leave IsHandled at false to keep the standard resolution from the BC mandate table.

Moving from the obsolete events​

The obsolete events are still raised, right before this one and with the same variables, until they are removed. Subscribe to this event only, and remove the subscriber to the obsolete event in the same release, otherwise both run.

Example​

[EventSubscriber(ObjectType::Table, Database::"mseBC mseDoc365 S. Inv.Buffer", 'OnBeforeResolveDirectDebitMandateForDocument', '', false, false)]
local procedure SupplyMandate(SourceTableNo: Integer; DocumentNo: Code[20]; BillToCustomerNo: Code[20]; SellToCustomerNo: Code[20]; DirectDebitMandateID: Code[35]; DueDate: Date; var ResolvedMandateID: Code[35]; var ResolvedDebtorIBAN: Code[50]; var BankAssignedCreditorID: Text[35]; var IsHandled: Boolean)
begin
case SourceTableNo of
Database::"Sales Invoice Header":
; // read the mandate of the posted invoice DocumentNo from the add-on's own tables
Database::"Sales Cr.Memo Header":
; // read the mandate of the posted credit memo DocumentNo
else
exit;
end;
ResolvedMandateID := 'MANDATE-001';
ResolvedDebtorIBAN := 'DE02120300000000202051';
BankAssignedCreditorID := 'DE98ZZZ09999999999';
IsHandled := true;
end;