Perl expressions work for billing
Jason Spence
thalakan at frys.com
Mon Nov 27 21:57:29 PST 2000
Hi all -
We've been figuring out prorated charges for our customers manually
for a while, until I read that you could use perl expressions in
package setup. After some head-scratching, I came up with the
following one-liner (split into lines for readability):
@t = localtime;
$eom = ( 31,30,31,30,31,30,31,31,30,31,30,31 )[$t[4]];
((($eom - $t[3] + 1) / $eom) * 69.95);
If you stick it into the setup charge field of a package, it
automatically prorates the package based on the current date (for
example, it would charge me $5.33 based on a $69.95 monthly charge and
four days of service including today, the 27th). It seems to work
fine when I bill the customers. Change the "69.95" to the monthly
charge to prorate.
I'm thinking that I'll have to rewrite the code around line 526 in
cust_main ("$cpt->share(qw( $cust_pkg ));") so that it shares other
objects with the Safe compartment for doing things like taxing certain
packages the customer has, but not others. Maybe even define
something like a billing_stuff object with all the packages the
customers has along with setup/cancellation dates. I can imagine that
there are plenty of people who could use the cancellation date in
particular to do things like cancellation charges if
($bill_stuff->pkg[$pkgnum]->get_cancel_date() -
$bill_stuff->pkg[$pkgnum]->get_setup_date()) > $some_number_of_seconds
and stuff like that.
It's a little hard for me to get my head around the idea that I'm
using perl one-liners for business logic :)
- Jason
More information about the freeside-users
mailing list