[freeside] Evaluating Freeside
ivan
ivan at 420.am
Tue Jan 22 05:40:54 PST 2002
On Mon, Jan 21, 2002 at 08:59:25AM -0600, Dave Burgess wrote:
> ivan wrote:
> > On Fri, Dec 07, 2001 at 11:41:29AM -0700, Todd Miller wrote:
> > > * There has been some talk about usage billing on the mailing list. Is
> > > anyone working to add this as additional functionality?
> >
> > Similar answer to above. Billing expressions can be based on usage and
> > I've written and deployed such things - but there isn't a simple web
> > interface to write the expressions.
> >
>
> Ivan,
>
> Could you provide a sample? I (for one) don't need a simple web interface, and
> I'd love to see how you access usage information for billing purposes.
It depends on where you have your usage information. For example, an
expression to bill $4.20 an hour, based on the usage data collected by the
session monitor, might have cust_pkg.recur set to something not unlike:
use FS::session;
my $seconds = 0;
my @svcnum = map { $_->svcnum }
grep { ($_->label)[2] eq 'svc_acct' }
( $cust_pkg->cust_svc );
my $sth = $dbh->prepare(' SELECT SUM(logout-login) FROM session
WHERE svcnum = ?
AND login >= ?
AND logout IS NOT NULL'
) or die $dbh->errstr;
foreach my $svcnum ( @svcnum ) {
$sth->execute($svcnum, $cust_pkg->bill || 0);
$seconds += $sth->fetchrow_arrayref->[0]
$sth->finish;
}
sprintf('%.2f', 4.20 * $seconds/3600 );
--
_ivan
More information about the freeside-users
mailing list