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
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);
} ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.