In billwerk's data processing the most fundamental feature is the assignment to payments. As a part of constant improvement we transitioned from ledger-based thinking to the new one - various types of payments are assigned to the proper invoice.
Within typical subscription contracts, we could assume that an incoming payment always belongs to the oldest open invoice. What if that is not the case? Customer could not pay the January invoice, but paid the February one? Last payment is not assigned to the oldest open invoice, that would be incorrect.
To make all operations more transparent we needed to assign the right amount of money to the correct operation. So the payments must be assigned to the correct invoices that have been issued as German tax law requires to determine exactly what is to be settled with a payment.
Note: The assignments procedure recognizes types of operations on a contract's account. It defines positive and negative ledger entries to make relations between them by following a set of rules. Each positive ledger entry can be assigned to any negative ledger entry. Reasons to proceed with assignments could be interpreted as the way of building relations between ledger entries.
There are several types of ledger entries in billwerk and they have their assignments preferences as listed below:
|Payment||Receivable||Payment was triggered after an invoice was created|
|Chargeback||Payment||Chargeback was done to a payment|
|Refund||Payment||Refund was done on a payment|
|Liability (negative receivable)||Receivable||One invoice reverses another one|
|Write-off||Receivable||Invoice was written-off|
|Prepaid card||Receivable||A credit from a prepaid card was applied to an invoice|
Note: Payment gets assigned to the invoice by making the invoice the target for the source - the payment. Assignments make billwerk define those ledger entries as primary side (target) and the secondary side (source).
In summary, an assignment is a connection between ledger entries that links source to its target.
Each assignment has its reason. billwerk manages many complex relations at once, but we needed to create sequence to prioritize operations. We have implemented an algorithm to find the fitting pairs of ledger entries and ordering them by priority number. Reasons with their conditions are listed below.
- SamePaymentTransaction - new ledger entry is created within a payment transaction with opposite sign, then it is assigned to the existing entry for that transaction. Here, the algorithm uses older transactions than the current ledger entry
- PrepaidCard - prepaid card assigned to its document
- PaymentPurpose - Selection of the target, when the payment is triggered. It orders the preferences from the Payment Transaction's preference list.
- OpenBalance - whatever is unpaid at the time the assignment happens. It chooses a ledger entry that was already assigned to this source, otherwise it selects the oldest open ledger entry.
This contract has four ledger entries (from the bottom):
- Invoice R-0001
- Transaction Payment
- Credit Note G-0001
- Invoice R-0002
Usage of assignments to payments let us follow each operation. Due to its transparency we have better overview about all processes.
In the example above we showed you the scenario how assignments works when one invoice R-0001 is overpaid. First, we create the Invoice R-0001 and afterwards, we add the transaction of payment to settle the R-0001 invoice. The third ledger entity is the Credit Note G-0001 (Reversal Invoice) that is linked to the R-0001 invoice.
Note: Triggered payment with preferred assignment to the R-0001 is reflected as a part of the payment posting.
Then, the invoice correction G-0001 of the R-0001 invoice impacts the assignment of the payment by reassigning it to the next open invoice R-0002.
billwerk creates an assignment within a 'debtor account', which always has the balance of 0, and it cancels out the payment for R-0001, only to assign it to the R-0002 invoice. Every item is closed and the contract's total is balanced .