Skip to content

Instantly share code, notes, and snippets.

@ramneekhanda
Last active February 3, 2019 14:52
Show Gist options
  • Save ramneekhanda/2ffa8644d8a9217eca8f5be77711e021 to your computer and use it in GitHub Desktop.
Save ramneekhanda/2ffa8644d8a9217eca8f5be77711e021 to your computer and use it in GitHub Desktop.
Lets say a person takes a loan of x amount for n months at y% interest per month
Lets assume CapMarket keeps f% fee per month where f < y.
A Payment schedule table should be produced in admin page with following fields after the loan has been accepted
1. Payment Month
2. Amount Payable
3. Principle Payable
4. Interest Payable
5. Fee Collected by CapMarket
6. Paid/Partial/Unpaid
Each of the row in the table will be actionable:
1. Payment made
a. Turn the lastfield from unpaid to paid
2. Partial Payment made
a. Allow admin to enter exactly amount of payment made
b. Create a new row as a subrow of the current row
c. Calculate values as mentioned in last section and mark the subrow as paid and parent row as partial
d. If the months payment is not completed then allow admin to create more subrows that month
e. If payment is left for this month then allow admin to add more subpayment
f. Sum of all subpayments should be equal to total payment per month
Calculation of values once the payment comes:
We need to calculate following once any amount of payment comes in
1. Total amount payable t = (1 + (n * y)/100) * x
2. Amount payable per month, mP = t/n
3. Fee collected by CM per month, fee = f/100 * x
4. Payments to investors per month, investorsPerMonth = mP - fee
5. If borrower pays partial payment, partialPay, then
a. Partial Fee out of that for CM, pFee = fee * partialPay/mP
b. Partial Payments to investors that month will be, pInvestorsPerMonth = investorsPerMonth * partialPay/mP
6. For trying above calc use https://jscalc.io/calc/WJnCliu2h4335jym, code available at https://jscalc.io/source/WJnCliu2h4335jym
Use ramneekhanda@gmail.com and password ramneek123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment