Ledger Allocating Payments
Contents
Overview
One of the single most important functions of the system is how payments work and service providers need to have a good understanding of how Emersion's system operates in terms of payment handling. Specifically, there are rules around the critical task of the allocation of a payment to an invoice.
- An unallocated payment is a payment recorded against an account that has not yet been allocated to an invoice.
- An allocated payment is a payment that has been applied to an invoice to reduce the amount payable.
Users can enter payments and allocate them to specific invoices immediately, or allow the system to auto-allocate the payment to invoices using the default set of rules (see below). Payments can also be allocated to invoices at a later time. Regardless of the choice made by the user, and regardless of the method of payment (Credit card, BPAY, Cash, Bank Deposit, etc) the payment is recorded by the ledger journal in exactly the same way.
All payments in the system enter the system as unallocated.
How 'Auto-Allocate' Works
When users select to 'auto-allocate' the payment, the system will:
- Create an unallocated payment.
- Look for the oldest invoice with an amount still outstanding.
- Apply the payment to this invoice.
- If the payment was for an amount greater than the amount owing on the oldest invoice, the system will look for the next oldest invoice with an amount that is outstanding, and apply money from the payment to this invoice.
This cycle is repeated until all invoices are paid and none are outstanding. In the case of any surplus funds that are left, these will be stored as an unallocated payment.
The Ledger Journal and Payments
The sections from here down pertain to the
All payments in the system are initially entered as unallocated payments. When the payment is then allocated, the first step is to create an 'offsetUnallocatedPayment' transaction, which is the inverse of the payment amount. Then - the system will create an 'allocateUnallocatedPayment' transaction for any invoices that are outstanding, or invoices that are created in the initial payment's PAYMENT_DETAIL serialized array. Where there is an amount left over, the system will create another 'unallocatedPayment' for the remainder so it can be allocated when there is an outstanding invoice.
The various transactions that allocate the payment amount to an invoice are linked back to the original payment via a 'reference_key'.
Ledger Examples
Single Payment Allocation to single outstanding invoice
Account 123456 has 1 invoice for 100, and a $100 payment is made against that invoice.
Date |
Ledger Journal ID |
Transaction Type' |
Handler Type |
Handler ID |
Amount |
Reference Key |
Description of Transaction |