vb_book/app/Helpers/financial_year_helper.php
2024-10-29 15:37:48 +05:30

25 lines
803 B
PHP
Executable File

<?php
if (!function_exists('get_financial_year')) {
function get_financial_year($date = null)
{
// If no date is provided, use the current date
$date = $date ?: date('Y-m-d');
// Extract the year from the date
$year = date('Y', strtotime($date));
// Determine the financial year based on your business logic
// Adjust this logic according to your organization's financial year cycle
if (date('n', strtotime($date)) < 4) {
// If the month is before April, use the previous year
$financialYear = ($year - 1) . '-' . $year;
} else {
// If the month is April or later, use the current year
$financialYear = $year . '-' . ($year + 1);
}
return $financialYear;
}
}