Sales Invoice/Cr. Memo Payment Date
By default, iDynamics Commissions checks the customer ledger entries generated by an invoice to get the date when the customer paid its corresponding amount.
Customizing the Payment Date
Each time that the app checks whether a sales document has been paid, and when, the following event is raised by the codeunit IDPCOS Doc. Collection Helper:
local procedure OnBeforeGetSalesDocPaymentDateAndStatus(PostedSalesDocType: Enum "IDPCOS Posted Sales Doc. Type"; DocNo: Code[20]; DelayPaymentMargin: DateFormula; var PaymentDate: Date; var Status: Enum "IDPCOS Payment Status"; var Handled: Boolean)
The event has the following parameters:
- PostedSalesDocType. This tells us whether we are checking the payment date of an invoice or a credit memo.
- DocNo. The identification number of the invoice or credit memo.
- DelayPaymentMargin. The document status can be collected, pending, or unpaid. By default, it changes from pending to unpaid when the current date is later than the expected date with this formula applied.
- PaymentDate. Set a value to this variable to return a customized date.
- Status. If the payment date has been updated, the document status must also be returned.
- Handled. If set to true, the app will use the values specified in the PaymentDate and Status variables.
If needed, the app also rises, in the same codeunit, an event when obtaining the document due date:
local procedure OnBeforeGetSalesDocDueDate(PostedSalesDocType: Enum "IDPCOS Posted Sales Doc. Type"; DocNo: Code[20]; var DueDate: Date; var Handled: Boolean)
This time the event receives the two variables that identify the source document, and DueDate and Handled can be used to override the default value obtained by the app.