js房贷等额本金与等额本息计算公式及函数
我们在买房的时候经常会被售楼处的小姐问道,要办等额本金还是等额本息呢,我们一般选择等额本息,因为总利息变少了,那么怎么进行计算的呢,今天我们来说一下在html中怎么通过js来实现等额本金及等额本息的计算。
一、等额本金js版
//等额本金计算 var benjin=function (type, num, year, lilv) { var mouth = parseInt(year) * 12, mouthlilv = parseFloat(lilv) / 12, dknum = parseFloat(num) * 10000, yhbenjin = 0; //首月还款已还本金金额是0 //每月应还本金=贷款本金÷还款月数 var everymonthyh = dknum / mouth //每月月供额=(贷款本金÷还款月数)+(贷款本金-已归还本金累计额)×月利率 var yuegong = everymonthyh + (dknum - yhbenjin) * mouthlilv; //每月月供递减额=每月应还本金×月利率=贷款本金÷还款月数×月利率 var yuegongdijian = everymonthyh * mouthlilv; //总利息=〔(总贷款额÷还款月数+总贷款额×月利率)+总贷款额÷还款月数×(1+月利率)〕÷2×还款月数-总贷款额 var totalLixi = ((everymonthyh + dknum * mouthlilv) + dknum / mouth * (1 + mouthlilv)) / 2 * mouth - dknum; //还款总额 总利息+贷款本金 var totalPrice = totalLixi + dknum, leftFund = totalLixi + dknum; //循环月份 var mouthdataArray = [], nowmouth = new Date().getMonth(), realmonth = 0; for (var i = 1; i <= mouth; i++) { realmonth = nowmouth + i; var yearlist = Math.floor(i / 12); realmonth = realmonth - 12 * yearlist; if (realmonth > 12) { realmonth = realmonth - 12 } yhbenjin = everymonthyh * (i - 1); var yuebenjin = everymonthyh + (dknum - yhbenjin) * mouthlilv; ...
点击查看剩余70%
网友评论0