PHP code example of crmleaf / epfo-penalty-calculator

1. Go to this page and download the library: Download crmleaf/epfo-penalty-calculator 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/ */

    

crmleaf / epfo-penalty-calculator example snippets


use Crmleaf\Payroll\Calculators\EpfoPenaltyCalculator;
use Crmleaf\Payroll\Money;

$result = (new EpfoPenaltyCalculator())->calculate(
    contributionAmount: Money::fromRupees(250_000),
    wageMonth: new \DateTimeImmutable('2025-01-01'),
    actualPaymentDate: new \DateTimeImmutable('2025-05-20'),
);

echo $result->explain();      // the formula with the real operands in it
echo $result->workings();     // every step, one per line, with its citation
print_r($result->toArray());  // snake_case, ready for JSON

use Crmleaf\Payroll\Calculators\EpfoPenaltyCalculator;

public function show(EpfoPenaltyCalculator $calculator)
{
    return $calculator->calculate(
        contributionAmount: Money::fromRupees(250_000),
        wageMonth: new \DateTimeImmutable('2025-01-01'),
        actualPaymentDate: new \DateTimeImmutable('2025-05-20'),
    )->toArray();
}

// config/epfo-penalty-calculator.php
'route' => ['enabled' => true, 'prefix' => 'tools'],
bash
php artisan vendor:publish --tag=epfo-penalty-calculator-config
bash
curl -X POST https://example.test/tools/epfo-penalty-calculator \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{"contribution_amount":250000,"wage_month":"2025-01-01","actual_payment_date":"2025-05-20"}'
bash
php artisan vendor:publish --tag=epfo-penalty-calculator-assets