Jump to content

Fiscal Year Calculations ! Please help


etdsbastar

Recommended Posts

Hello there,

 

I stuck in a silly logic ... I will really appreciate if someone helps me...

 

My Fiscal year starts from 01st April of current year through 31st March of next year, for ex. (01 Apr 2011 to 31st March 2012). I want to put a latefee of 6.25% on total amount, if the payment date is not done on the current fiscal year. Everything depends on the payment date.

 

For example,

 

A bill of $8000 was generated on 01st Apr. 2009 then its 6.25% will be $500 and the customer is paying the same on 30th August 2011, then total years passed is 3. So, the late fee will be 500 * 2 = $1000.

 

i.e. Any bill generated and paid in the current fiscal year (stated above) is free of late fee and after that the above calculation is applicable.

 

Please help, how to do the calculation. A function is really appreciated.

Link to comment
https://forums.phpfreaks.com/topic/246000-fiscal-year-calculations-please-help/
Share on other sites

With a little effort I got this successfully:

 

<?php function dateDiff($start, $end) {
	  $start_ts = strtotime($start);
	  $end_ts = strtotime($end);
	  $diff = $end_ts - $start_ts;
	  return round($diff / 86400);
}

function calculateLateFees($entyear, $grosstax)
{
	extract($GLOBALS);

	$FiscalStartYear = Date('Y');
	$FiscalStartMonth = 4;
	$FiscalStartDay = 1;

	$FiscalStartDate = Date($FiscalStartYear."-".$FiscalStartMonth."-".$FiscalStartDay);

	$iYearDiff = Date('Y') - $entyear;

	$date  = Date($entyear."-04-01");

	$TotalDays = dateDiff($date, $FiscalStartDate);

	$TotalYears = intval($TotalDays/365);

	if ($TotalYears > 0)
	{
		$latefees = (floatval($grosstax) * ($LateFeePercentage/100)) * $TotalYears;
	}
	else
	{
		$latefees = 0;
	}

	return number_format($latefees,2);
} ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.