PHP code example of parcelado-lara / payment-plan-php
1. Go to this page and download the library: Download parcelado-lara/payment-plan-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
parcelado-lara / payment-plan-php example snippets
use ParceladoLara\PaymentPlan\PaymentPlan;
use ParceladoLara\PaymentPlan\Params\Params;
$params = new Params(
requestedAmount: 8800.0,
firstPaymentDate: new DateTime('2022-04-18'),
disbursementDate: new DateTime('2022-03-18'),
installments: 24,
debitServicePercentage: 0,
mdr: 0.05,
tacPercentage: 0.0,
iofOverall: 0.0038,
iofPercentage: 0.000082,
interestRate: 0.0235,
minInstallmentAmount: 0.0,
maxTotalAmount: PHP_FLOAT_MAX,
disbursementOnlyOnBusinessDays: false
);
$result = PaymentPlan::calculate($params);
use ParceladoLara\PaymentPlan\PaymentPlan;
use ParceladoLara\PaymentPlan\Params\Params;
use ParceladoLara\PaymentPlan\Params\DownPaymentParams;
$downPayment = 200.0;
$minInstallmentAmount = 100.0;
$installments = 4;
$params = new Params(
requestedAmount: 8800.0,
firstPaymentDate: new DateTime('2022-04-18'),
disbursementDate: new DateTime('2022-03-18'),
installments: 24,
debitServicePercentage: 0,
mdr: 0.05,
tacPercentage: 0.0,
iofOverall: 0.0038,
iofPercentage: 0.000082,
interestRate: 0.0235,
minInstallmentAmount: 0.0,
maxTotalAmount: PHP_FLOAT_MAX,
disbursementOnlyOnBusinessDays: false
);
$downPaymentParams = new DownPaymentParams(
requestedAmount: $downPayment,
minInstallmentAmount: $minInstallmentAmount,
firstPaymentDate: new DateTime('2022-06-20'),
installments: $installments,
params: $params
);
$result = PaymentPlan::calculateDownPayment($downPaymentParams);
use ParceladoLara\PaymentPlan\PaymentPlan;
$baseDate = new DateTime('2078-02-12');
$days = 5;
$result = PaymentPlan::disbursementDateRange($baseDate, $days);
var_dump($result); // Array of DateTime objects: [DateTime('2078-02-16'), DateTime('2078-02-22')]
/*
2078-02-12 = Saturday(invalid)
2078-02-13 = Sunday(invalid)
2078-02-14 = Bank holiday(invalid)
2078-02-15 = Bank holiday(invalid)
2078-02-16 = Wednesday(valid) 1
2078-02-17 = Thursday(valid) 2
2078-02-18 = Friday(valid) 3
2078-02-19 = Saturday(invalid)
2078-02-20 = Sunday(invalid)
2078-02-21 = Tuesday(valid) 4
2078-02-22 = Wednesday(valid) 5
So the disbursement period is from 2078-02-16 to 2078-02-22.
*/
use ParceladoLara\PaymentPlan\PaymentPlan;
$startDate = new DateTime('2078-11-12');
$endDate = new DateTime('2078-11-22');
$result = PaymentPlan::getNonBusinessDaysBetween($startDate, $endDate);
var_dump($result); // Array of DateTime objects for non-business days
/*
2078-11-12 = Saturday(non-business)
2078-11-13 = Sunday(non-business)
2078-11-14 = Monday(business)
2078-11-15 = Tuesday(non-business)
2078-11-16 = Wednesday(business)
2078-11-17 = Thursday(business)
2078-11-18 = Friday(business)
2078-11-19 = Saturday(non-business)
2078-11-20 = Sunday(non-business)
2078-11-21 = Monday(business)
2078-11-22 = Tuesday(business)
So the non-business days are 2078-11-12, 2078-11-13, 2078-11-15, 2078-11-19, and 2078-11-20.
*/
use ParceladoLara\PaymentPlan\PaymentPlan;
$baseDate = new DateTime('2078-02-12');
$result = PaymentPlan::nextDisbursementDate($baseDate);
var_dump($result); // DateTime object: 2078-02-16
/*
2078-02-12 = Saturday(invalid)
2078-02-13 = Sunday(invalid)
2078-02-14 = Bank holiday(invalid)
2078-02-15 = Bank holiday(invalid)
2078-02-16 = Wednesday(valid) 1
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.