For development purposes, the loan-tool can be used to go through the live cycle of the loan. It is available in the git repository in the tools folder in the loan-manager source code.
Create a new loan
The new loan can be created using the loan-manager API. The following request is needed.
Please note the loan has to be accepted by the risk and the parameters have to match the particular row in the product recommendation table.
Request
POST https://loan-manager.apps.brave.safibank.online/v3/loan/account Content-Type: application/json X-Idempotency-Key: {{$uuid}} { "stakeholderId": "732dce88-986e-466d-9352-5925b9b56817", "principalAmount": 1000, "firstInstallmentDate": "2022-12-12", "numberOfInstallments": 12, "interestRate": 0.02400, "initialFee": 0.0, "initialFeePercentage": 0.0 }
Response
{ "loanId": "71ef28c5-43b2-4aaa-844f-2bec648378f8" }
Show installment plan
There are two installment plans available. The first can be accessed using the loan-tool from the TM and the second one can be accessed using API from the service.
Show TM installment plan
./loan-tool.py loan-list-accounts [customer_id]
Result
gorig-notebook :: services/loan-manager/tools ‹main*› » ./loan-tool.py loan-installments 71ef28c5-43b2-4aaa-844f-2bec648378f8 Installments for loan account 71ef28c5-43b2-4aaa-844f-2bec648378f8 - planned: 1: 2022-11-18: P: 200.00 + I: 0.00 = 200, prepaid: 0.00, paid: P: 200.0 + I: 0 = 200.0 * - planned: 2: 2022-12-12: P: 66.28 + I: 1.26 = 67.54, prepaid: 67.54, paid: P: 0.0 + I: 0 = 0.0 - planned: 3: 2023-01-12: P: 66.04 + I: 1.50 = 67.54, prepaid: 32.46, paid: P: 0.0 + I: 0 = 0.0 - planned: 4: 2023-02-12: P: 66.18 + I: 1.36 = 67.54, prepaid: 0.00, paid: P: 0.0 + I: 0 = 0.0 - planned: 5: 2023-03-12: P: 66.43 + I: 1.11 = 67.54, prepaid: 0.00, paid: P: 0.0 + I: 0 = 0.0 - planned: 6: 2023-04-12: P: 66.45 + I: 1.09 = 67.54, prepaid: 0.00, paid: P: 0.0 + I: 0 = 0.0 - planned: 7: 2023-05-12: P: 66.62 + I: 0.92 = 67.54, prepaid: 0.00, paid: P: 0.0 + I: 0 = 0.0 - planned: 8: 2023-06-12: P: 66.72 + I: 0.82 = 67.54, prepaid: 0.00, paid: P: 0.0 + I: 0 = 0.0 - planned: 9: 2023-07-12: P: 66.88 + I: 0.66 = 67.54, prepaid: 0.00, paid: P: 0.0 + I: 0 = 0.0 - planned: 10: 2023-08-12: P: 66.99 + I: 0.55 = 67.54, prepaid: 0.00, paid: P: 0.0 + I: 0 = 0.0 - planned: 11: 2023-09-12: P: 67.13 + I: 0.41 = 67.54, prepaid: 0.00, paid: P: 0.0 + I: 0 = 0.0 - planned: 12: 2023-10-12: P: 67.28 + I: 0.26 = 67.54, prepaid: 0.00, paid: P: 0.0 + I: 0 = 0.0 - planned: 13: 2023-11-12: P: 67.00 + I: 0.14 = 67.14, prepaid: 0.00, paid: P: 0.0 + I: 0 = 0.0
Show service installment plan
https://loan-manager.apps.brave.safibank.online/?id=71ef28c5-43b2-4aaa-844f-2bec648378f8
Partially repay the loan
The loan can be partially repaid using three methods. If the source account is not specified, the loan is repaid from the main account.
./loan-tool.py loan-early-repayment [loan_account_id] [method] [amount] [source_account]
Decreasing EMI
method: amount
The installment plan is updated. The early repayment creates a new installment with total amount of repayment amount. The new installment is due today and immediately repaid. The EMI is recalculated and the next installments are lowered.
Decreasing number of installments
method: count
The installment plan is updated. The early repayment creates a new installment with total amount of repayment amount. The new installment is due today and immediately repaid. The EMI is not recalculated and the number of installment is decreased if needed.
Prepaying loan
method: prepay
The installment plan is not updated. The amount is stored as a prepayment and it will be used on the next due date. The prepayment is not used in future early repayments. It is redistributed to the new installments when early repayment occurs.
Fully repay the loan
The command repays the whole loan and closes it.
./loan-tool.py loan-fully-early-repayment [loan_account_id]
Make loan due
Increases the accrued interest to match the current installment and reschedule the due schedule to happen in next seconds. This effectively simulates the loan being due on the next installment day.
If there is enough money on the stakeholder main account, the due amount is immediately paid from the main account using auto deduction.
Note: In the current implementation the repayment cannot be done after the loan is made due using this command!
./loan-tool.py loan-make-due [loan_account_id]
Make loan overdue
Reschedule the loan overdue check schedule to happen in next seconds. If there is any due amount on the loan account, it is made overdue.
./loan-tool.py loan-make-overdue [loan_account_id]
Do payment
Transfer money from default address of the first account to the second one.
./loan-tool.py do-payment [account_from] [account_to] [amount]
For the debugging purposes the TEST_ASSET_INTERNAL_ACCOUNT
can be used as a source or destination of the transfers.