etdsbastar Posted August 30, 2011 Share Posted August 30, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/246000-fiscal-year-calculations-please-help/ Share on other sites More sharing options...
etdsbastar Posted August 30, 2011 Author Share Posted August 30, 2011 please help .... Quote Link to comment https://forums.phpfreaks.com/topic/246000-fiscal-year-calculations-please-help/#findComment-1263488 Share on other sites More sharing options...
etdsbastar Posted August 30, 2011 Author Share Posted August 30, 2011 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); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/246000-fiscal-year-calculations-please-help/#findComment-1263514 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.