I have a web developer creating a credit card calculator in Javascript and need a formula to use for calculating the time to clear debt based on inputs of balance, APR, minimum repayment per month (%) and minimum repayment per month (£).
I currently have the below formula but need to adjust it to account for the check to see which minimum repayment to use (£ or %) to occur every month rather than just at the start of the calculation.
We are trying to replicate the minimum repayment calculators seen on MSE and Which.
Please help!
$a$ = credit card balance
$b$ = repayment amount per month
$c$ = credit card APR
$e$ = current credit card monthly rate
$h$ = total interest paid
$k$ = minimum % required per month
$m$ = minimum amount required per month
$p$ = amount payable based on %
$q$ = time to clear debt
$e$ = $(\text{POWER}(((\frac{c}{100}+1),0.08333)-1) \times 100)\%$
$p = k \times a$
Formula for time to clear debt (q):
IF
$p > m, q = \frac{\log (\frac{-p}{ea-p})}{\log(1+e)}, q = \frac{log (\frac{-m}{ea-m})}{log(1+e)}$