artyom-e / credit-calculator
A simple PHP-based Credit Calculator that supports multiple types of loan payment calculations
v1.0.0
2024-09-30 08:13 UTC
Requires
- php: >=8.2
- spatie/data-transfer-object: ^3.9
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- pestphp/pest: ^3.2
- phpstan/phpstan: ^1.12
This package is auto-updated.
Last update: 2024-10-30 08:34:10 UTC
README
A simple PHP-based Credit Calculator that supports three types of loan payment calculations:
- Annuity Payments
- Differentiated Payments
- Bullet Payments
Features
- Annuity Calculation: Fixed monthly payments throughout the loan period.
- Differentiated Calculation: Payments decrease over time, starting with higher amounts.
- Bullet Calculation: Payment method where the borrower only pays interest throughout the loan term, and the entire principal is paid in lump sum at the end of loan period.
Requirements
- PHP 8.2 or higher
Installation
composer require artyom-e/credit-calculator
Usage
use ArtyomE\CreditCalculator\ResolverFactory; use ArtyomE\CreditCalculator\Enums\CalculationType; $resolver = ResolverFactory::createResolver(CalculationType::annuity); $paymentSchedule = $resolver->resolve(6, 5000, 45);
Result
{ "total_amount_with_interest":5676, "total_amount_without_interest":5000, "schedule":[ { "month":1, "principal_payment":759, "interest_payment":188, "total_payment":946, "remaining_principal":4241 }, { "month":2, "principal_payment":787, "interest_payment":159, "total_payment":946, "remaining_principal":3454 }, { "month":3, "principal_payment":817, "interest_payment":130, "total_payment":946, "remaining_principal":2638 }, { "month":4, "principal_payment":847, "interest_payment":99, "total_payment":946, "remaining_principal":1791 }, { "month":5, "principal_payment":879, "interest_payment":67, "total_payment":946, "remaining_principal":912 }, { "month":6, "principal_payment":912, "interest_payment":34, "total_payment":946, "remaining_principal":0 } ] }