CRM0113 Create Payment Orders

Basic Information

Module Crm.Sales
Code CRM0113
Parent Document Sales Order
Sub-document Payment Order
Full Name Create Payment orders
Status NEW
Deterministic YES
Supports Transitional Documents YES
Replaces GeneratePaymentOrdersByPlanV2
Orphan Rows Ignore
Split Function SalesOrderPaymentPlan.InstallmentNumber
Introduced In Version
Date of Suspension -

Business Logic

This Generation Procedure is used to create Payment Orders by the Sales Oder Payment Plan of the current Sales Order. For each instalment of the payment plan could be created one or more Payment Orders (depending on whether the amount of the instalment is broken down by invoice or not). Currently, for the Generation there are three available settings (set in "SalesOrderPaymentOrdersTemplate" of the line of the particular Route):

  • "Is Amount With VAT" - this setting specifies whether or not the field "IsAmountWithVAT" in the created Payment Orders will be check-marked;
  • "Create For Not Invoiced Amounts" - this setting specifies whether Payment Orders for the payment plan Amounts that have not yet been invoiced will be created;
  • "Create For Invoiced Amounts" - this setting specifies whether Payment Orders for payment plan Amounts that have already been invoiced will be created.
Note

The "Update For Invoices" setting is no longer in use.

Fulfillments

Name AmountToPaymentOrder
Parent Entity Amount
Child Entity PaymentOrder
Parent / Child Relationship PaymentOrder.ParentDocument = SalesOrder; PaymentOrder.RefDocument = Amount.RefDocument; PaymentOrder.RefInvoiceDocument = Amount.RefInvoiceDocument; PaymentOrder.InstallmentNumber = Amount.InstallmentNumber

Metrics

Fulfillment Name Metric Name Measurement Unit Parent Value Child Value New Record
AmountToPaymentOrder MTotalAmount Amount.TotalAmountCurrency Amount.TotalAmount (for every Amount) PaymentOrder.TotalAmount YES
AmountToPaymentOrder MInvoiceAmount Amount.TotalAmountCurrency Amount.InvoiceAmount (for every Amount) PaymentOrder.InvoiceAmount YES

The creation of the Payment Orders begins with the calculation of the Amounts of instalments of the current Sales Order. These amounts are then being broken down by the Invoices that have been created for Sales Order. Calculation of amounts depends on the "Create For Not Invoiced Amounts" and "Create For Invoiced Amounts" settings. This is detailed in the topic Sales Order Payment Plan. Thus, for the current Sales Order is determined a list of Amounts. Then for each Amount are calculated the amounts of the metrics that are not yet fulfilled by other Payment Orders that have already been created (for more information, see topic Discrepancy System and Metrics). If for an Amount any of the Metrics with "New Record = YES" is different from 0, then for this Amount is created a new Payment Order.

The new Payment Order is created as follows (the determination of the Amount's attributes' values is described in the topic Sales Order Payment Plan):

PaymentOder.Notes = Amount.DocumentNotes
PaymentOder.Party = Amount.Party
PaymentOder.Direction = Income
PaymentOder.InstallmentNumber = Amount.InstallmentNumber
PaymentOder.DueDate = Amount.DueDate
PaymentOder.DueStartDate = Amount.DueStartDate
PaymentOder.TotalAmountCurrency = Amount.TotalAmountCurrency
PaymentOder.TotalAmount = Amount.REMAINING(MTotalAmount)
PaymentOder.PaymentAccount = Amount.PaymentAccount
PaymentOder.PaymentType = Amount.PaymentType
PaymentOder.RefDocument = Amount.RefDocument
PaymentOder.RefInvoiceDocument = Amount.RefInvoiceDocument
PaymentOder.InvoiceAmountCurrency = Amount.InvoiceAmountCurrency
PaymentOder.InvoiceAmount = Amount.REMAINING(MInvoiceAmount)
PaymentOder.LocationParty = Amount.LocationPartyPaymentOder.IsAmountWithVATPaymentOder.IsAmountWithVAT = if(Route.SalesOrderPaymentOrdersTemplate.IsAmountWithVAT == true, true, false)