This paper does not go deep into financial terms, but simply considers the design of enterprise clearing and settlement from the perspective of the software and the problems that should be paid attention to. Each enterprise has a different understanding of payment, finance, clearing, and settlement in the technical team, but the overall external users tend to be unified.
concept
- Financial entity refers to the objects of financial relationship, such as users, merchants, platforms, suppliers, etc., which will generate creditor's rights/debts in the operation process。
- Clearing: Aggregate, transfer, and hedge the complex creditor/debt relationship of financial entities to achieve the only clear creditor/debt relationship between financial entities. In the actual business process, financial entity A - >B not only has a creditor's rights but also may have debt relationship. Then, according to the relationship between A and B, the only clear process that A owes B $1, B owes A $1, or AB does not have creditor's rights.
- Settlement:After clearing, the relationship between the financial entities will be simplified as the only relationship between the creditor's rights and debts, which is called settlement when the creditor's rights and debts are paid off, and the completion of settlement represents that the creditor's rights and debts between the financial entities have been dissolved through the actual capital transaction within a certain period of time. After settlement, A owes $1 to B, and A transfers $1 to B's account on January 1, 2020, which means the settlement is completed, and A no longer owes B $1.
Design
For a financial system, it’s always right to record the original input data as a voucher which can help problem traced and sorted it out.
The purpose of netting is to reduce the risk of payment between enterprises, also netting can simplify the structure of debt relationships among enterprises. For a merchant, they do care about when and how much money they receive.
So the process of settlement and clearing can be simplified to the following steps
Step 1, the voucher is persisted and the order is idempotent. The idempotent ID is transmitted in each module
Step 2, according to various accounting subjects to obtain net creditor’s rights to merchants
Step 3, attributing the net debt of the order to a certain account period.
Step 4, aggregate the net debt of a merchant’s orders in a particular account period.
Step 5, call transfer method to transfer money, If this step succeeds, the process is completed.