loan-payment-schedule
Library to generate loan payment schedule based on configuration. Contains 3 main parts:
- PaymentScheduleConfig - holds configuration settings for payment schedule
- PaymentScheduleFactory - generates payment schedule based on configuration
- PaymentSchedule - holds collection of payment dates for payment schedule generated by factory
Basic usage
// We have a loan for 5 years with montly payments
// How many payments loan schedule has
$noOfPayment = 5*12;
// First day of the payment schedule (first day when loan principal is out)
$startDate = new \DateTime('2000-01-01');
// What is the pattern used to generate payment dates
$dateIntervalPattern = 'P1M';
$config = new PaymentScheduleConfig($noOfPayments, $startDate, $dateIntervalPattern);
$schedule = PaymentScheduleFactory::generate($config);
var_dump($schedule instanceof PaymentScheduleInterface); // true
// Get array of payment dates
$paymentDates = $schedule->getPaymentDates();