PHP贷款等额本息、等额本金计算月供还款计划公式
用PHP信贷业务中使用的 等额本息、等额本金信贷计算,PHP代码代码如下:
/** * 等额本息还款法 * @param int $loanPeriod * @param int $loanTotal * @param float $loanRate */ public function fixedInstallment() { $loanPeriod = 240; //贷款月数,20年就是240个月 $loanTotal = 100000; //贷款总额 $loanRate = 0.049; //贷款年利率 $monthlyPayment = $loanTotal * $loanRate / 12 * pow(1 + $loanRate / 12, $loanPeriod) / (pow(1 + $loanRate / 12, $loanPeriod) - 1); //每月还款金额 $interestTotal = 0; //总利息 for ($i = 0; $i < $loanPeriod; $i++) { $interest = $loanTotal * $loanRate / 12; //每月还款利息 $monthlyRepaymentPrincipal = $monthlyPayment - $interest; //每月还款本金 $loanTotal = $loanTotal - $monthlyRepaymentPrincipal; echo "第" . ($i + 1) . "期", " 本金:", $monthlyRepaymentPrincipal, " 利息:" . $interest, " 总额:" . $monthlyPayment , " 剩余本金:" . ($loanTotal),"<br />"; $interestTotal = $interestTotal + $interest; } echo "总利息:" . $interestTotal; } /** * (Reducing Balance) 等额本金还款法(利随本清) * @param int $loanPeriod * @param int $loanTotal * @param float $loanRate */ public function fixedPrincipal() { $loanPeriod = 240; //贷款月数,20年就是240个月 $loanTotal = 100000; //贷款总额 $loanRate = 0.049; //贷款年利率 $monthlyRepaymentPrincipal = round($loanTotal / $loanPeriod, 2); //每个月还款本金 $interestTotal = 0; //总利息 for ($i = 0; $i < $loanPeriod; $i++) { $interest = round($loanTotal * $loanRate / 12, 2); //每月还款利息 $loanTotal -= $monthlyRepaymentPrincipal ; echo "第" . ($i + 1) . "期", " 本金:", $monthlyRepaymentPrincipal , " 利息:" . $interest, " 月供:" . ($monthlyRepaymentPrincipal + $interest), " 剩余本金:" . ($loanTotal), "<br />"; $interestTotal = $interestTotal + $interest; } echo "总利息:" . $interestTotal; }
文章英文自我查找翻译,本文仅供参考。
本文链接二维码可以保存在本地:保存
http://shixiangcun.cc/index.php?c=index&id=100&m=articleDetailInfo
分类 Laravel | 浏览 (4849) | 赞 (0) | 踩 (0) | | 2017-11-30 00:06:06 |
相关文章
- Mac安装Swoole扩展phpize 时 Cannot find autoconf 解决方法
- mac下安装swoole扩展报错PHP Startup Unable to load dynamic library
- Laravel 数据库事务
- Laravel 关闭过滤排除部分路由VerifyCsrfToken 验证
- Laravel Horizon监控Redis队列queue
- Laravel 的任务调度计划任务的测试