excel or php formula add fees when invoice delay every 5 month
one text
Solution:
For PHP:
//difference in dates
$interval = $date1->diff($date2);
if($interval > 5)
{
if($interval>0 && $interval<3)
{
$amountNew = (($oldAmount * 0.15)+$oldAmount) + ($oldAmount *0 * 0.005);
}elseif($interval>3 && $interval<6) //repeat these steps for all the intervals
{
$amountNew = (($oldAmount * 0.15)+$oldAmount) + ($oldAmount *3 * 0.005);
}
}
The above should do the trick for getting the date difference and adding the 15% to the amount. If you are storing the values in a DB, loop through it with a for loop or foreach.
for Excel:
use the following formula: Datedif(cellofdate1; cellofdate2; "m")
this will give you the difference in months
the you can wrap it in an if
IF(DATEDIF(DATE1;DATE2;"M")>5;IF(DATEDIF(DATE1;DATE2;"M")=3;((AMOUNT*0,15)+AMOUNT) + (AMOUNT*3*0,005);E1)
Source