springy-framework/installment-calc

带利率的PHP分期计算器

v1.0.0 2020-12-24 15:44 UTC

This package is auto-updated.

Last update: 2024-09-23 04:17:13 UTC


README

此类可以计算贷款的分期金额。

它可以将贷款金额、利率和用于计算分期的方法的标识作为参数。

该类可以返回与分期付款相关的值,如总金额或给定月份后应退还的利息金额。

Latest Stable Version tests Build Status PHPStan StyleCI Total Downloads License

要求

  • PHP 7.3+

安装

要获取此组件的最新稳定版本,请在您的 composer.json 文件中使用以下命令:

"require": {
    "springy-framework/installment-calc": "*"
}

使用方法

我假设以下示例就是您需要的全部内容

<?php

require 'vendor/autoload.php'; // If you're using Composer (recommended)

// Creates the object. Only the principal value is requered in constructor.
$installment = new Springy\InstallmentCalc(
    1000,
    0.5,
    Springy\InstallmentCalc::FORMULA_COMPOUND
);

/*
    Interst formula constants explained

    Springy\InstallmentCalc::FORMULA_SIMPLE - Simple interest
    Springy\InstallmentCalc::FORMULA_COMPOUND - Compound interest
    Springy\InstallmentCalc::FORMULA_BCB - Brazilian Central Bank interset formula
*/


// Gets future amount for 12 months
echo $installment->getFutureAmount(12);

// Gets total interest for 12 months
echo $installment->getInterest(12);

// Gets monthly installment for 12 months
echo $installment->getMonthlyInstallment(12);

// Gets current principal amount
echo $installment->getPrincipalAmount();

// Gets current interest formula method
echo $installment->getFormulaMethod();

// Gets current interes rate
echo $installment->getInterestRate();

// Changes the principal amount value
$installment->setPrincipalAmount(1999.99);

// Changes the interest formula value
$installment->setFormulaMethod(Springy\InstallmentCalc::FORMULA_SIMPLE);

// Changes the interest rate value
$installment->setInteresRate(1.99);

贡献

请阅读我们的 贡献文档,并感谢您的贡献。

行为准则

为了确保我们的社区对所有成员都友好,请查阅并遵守 行为准则

许可

本项目采用 MIT 许可证 (MIT) 许可。