承接 apxcde/loan-amortization 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

apxcde/loan-amortization

最新稳定版本:v1.1.0

Composer 安装命令:

composer require apxcde/loan-amortization

包简介

PHP composer package for loan amortization

README 文档

README

Latest Version on Packagist Tests Total Downloads

Installation

You can install the package via composer:

composer require apxcde/loan-amortization

Usage

use Apxcde\LoanAmortization\LoanAmortization;

$loanAmount = 200000;
$termMonths = 60;
$annualInterestRate = 12;

$loanData = [
    'loan_amount' => $loanAmount,
    'interest' => $annualInterestRate,
    'term_months' => $termMonths,
    'starting_date' => new \DateTime('2024-01-01'),
    'remaining_months' => $termMonths, // Set to $termMonths for new loan, or less if partially paid
];

$loan = new LoanAmortization($loanData);

// Get all results (summary and schedule)
$results = $loan->getResults();

// Access summary
echo "Monthly Payment: $" . number_format($results['summary']['monthly_repayment'], 2) . "\n";
echo "Total Interest: $" . number_format($results['summary']['total_interest'], 2) . "\n";
echo "Total Payment: $" . number_format($results['summary']['total_pay'], 2) . "\n";

// Access payment schedule
foreach ($results['schedule'] as $payment) {
    [$status, $details] = $payment;
    echo sprintf(
        "%s - Date: %s, Payment: $%.2f, Principal: $%.2f, Interest: $%.2f, Balance: $%.2f\n",
        strtoupper($status),
        $details['date'],
        $details['payment'],
        $details['principal'],
        $details['interest'],
        $details['balance']
    );
}

Example with Partial Payment

If a loan has already been partially paid:

$loanData = [
    'loan_amount' => 200000,
    'interest' => 12,
    'term_months' => 60,
    'starting_date' => new \DateTime('2024-01-01'),
    'remaining_months' => 36, // 24 months already paid, 36 remaining
];

$loan = new LoanAmortization($loanData);
$results = $loan->getResults();

// The schedule will show 24 months as 'paid' and 36 as 'not_paid'

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 59
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-29