/**
* 每月还息到期还本
* @param {*贷款总额} total
* @param {*还款月数} months
* @param {*月利率} monthRate
*/
const equalPrincipall = (total, months, monthRate) => {
// 每月月供额 = 每月应还利息
// 每月应还本金 = 0
// 每月应还利息 = 贷款总额 × 月利率
let interest = total * monthRate; //本期利息
//let principal =interest/monthRate; //本期本金
let monthlyPayment=interest;
return monthlyPayment;
}
let tempTotalPaid = 0;
/**
* //本期本金
* @param {*待还本金} surplus
* @param {*没有偿还本息} monthlyPayment
* @param {*月利率} monthRate
*/
const equalPrincipalll = (surplus, monthlyPayment, monthRate) => {
let interest = surplus * monthRate; //本期利息
let principal =0; //本期本金
surplus = surplus ; //剩余本金
return {
monthlyPayment: monthlyPayment,
principal: principal,
interest: interest,
surplus: surplus
}
}
题主,这个文章中有JS版本的计算方法,可以参考下。红色的字是关键的计算公式。