summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2002-10-14 06:17:16 +0000
committerivan <ivan>2002-10-14 06:17:16 +0000
commit2164ab67b22c5762389d84e356def0a6e9cfb1fd (patch)
treebeaa3d7a2c82d484412aed5901e51250e7792ee7
parenta60236063190e34d918210c40e0815bc551a4a70 (diff)
fix sql radacct billing
-rw-r--r--FS/FS/cust_pkg.pm17
-rwxr-xr-xhttemplate/edit/part_pkg.cgi2
2 files changed, 17 insertions, 2 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 0978ac18f..4373f5bcc 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -9,6 +9,7 @@ use FS::part_pkg;
use FS::cust_main;
use FS::type_pkgs;
use FS::pkg_svc;
+use FS::cust_bill_pkg;
# need to 'use' these instead of 'require' in sub { cancel, suspend, unsuspend,
# setup }
@@ -419,6 +420,20 @@ sub unsuspend {
''; #no errors
}
+=item last_bill
+
+Returns the last bill date, or if there is no last bill date, the setup date.
+Useful for billing metered services.
+
+=cut
+
+sub last_bill {
+ my $self = shift;
+ my $cust_bill_pkg = qsearchs('cust_bill_pkg', { 'pkgnum' => $self->pkgnum,
+ 'edate' => $self->bill, } );
+ $cust_bill_pkg ? $cust_bill_pkg->sdate : $self->setup || 0;
+}
+
=item part_pkg
Returns the definition for this billing item, as an FS::part_pkg object (see
@@ -716,7 +731,7 @@ sub order {
=head1 VERSION
-$Id: cust_pkg.pm,v 1.23.4.1 2002-10-12 13:26:43 ivan Exp $
+$Id: cust_pkg.pm,v 1.23.4.2 2002-10-14 06:17:16 ivan Exp $
=head1 BUGS
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index ddd86765a..5fbcd0bd1 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -382,7 +382,7 @@ tie my %plans, 'Tie::IxHash',
},
'fieldorder' => [ 'setup_fee', 'recur_flat', 'recur_included_hours', 'recur_hourly_charge' ],
'setup' => 'what.setup_fee.value',
- 'recur' => '\'my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($sdate))[0,1,2,3,4,5]; $mon+=$part_pkg->freq; until ($mon<12) { $mon-=12; $year++ }; $edate = timelocal($sec,$min,$hour,$mday,$mon,$year); my $hours = $cust_pkg->seconds_since_sqlradacct($sdate, $edate, \' + what.sql_datasrc + \', \' + what.sql_username + \', \' + what.sql_password + \' ) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_flat.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'',
+ 'recur' => '\'my $hours = $cust_pkg->seconds_since_sqlradacct($cust_pkg->last_bill, $sdate, \' + what.sql_datasrc + \', \' + what.sql_username + \', \' + what.sql_password + \' ) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_flat.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'',
},