[freeside] Bill late fee based on percentage

ivan at 420.am ivan at 420.am
Sun Nov 9 14:47:04 PST 2003


On Sat, Nov 08, 2003 at 12:23:08PM -0800, Joseph Tanner wrote:
> Ok, think I figured it out.  Probably not the best way
> to do it, but it works.

You probably didn't notice any problems in the simplest case, but, no,
this actually doesn't doesn't work very well at all.

>  When you add an invoice event
> to charge a late fee, instead of putting a number
> there put this:
> 
> $cust_main->balance_date(time-10 * 86400) * 0.05

For starters I'd say you probably want to start with $cust_bill->owed
rather than $cust_main->balance_date().  You'll be charging a lot of
duplicate late fees for a lot of old balances doing it like that.

Secondly (though this is a moot point if you use $cust_bill->owed),
"time-10" is not a number of days.  "time" returns the current time in
seconds since the epoch.  See "perldoc -f time".  Subtracting ten backs
up 10 seconds, and multiplying by 86400 (the number of seconds in a day)
results in an absurdly large number.  When considered as a date, this
means some far-off future date, and thus ->balance_date() with this huge
number only considers invoices before the far-off future date,
and so behaves just like ->balance().

Try

  $cust_bill->owed * 0.05

-- 
_ivan



More information about the freeside-users mailing list