summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2011-01-24 00:26:11 +0000
committerivan <ivan>2011-01-24 00:26:11 +0000
commitb608648e0c400ea4ecf85c00601e13ee54c906d5 (patch)
treea1d4975ec3d23288779637d33ac189bb94252eb6
parenta32c9f2fff7814979894fa1fca729b7dd70f6af7 (diff)
torrus, RT#10574
-rw-r--r--FS/FS/part_pkg/torrus_Common.pm7
1 files changed, 7 insertions, 0 deletions
diff --git a/FS/FS/part_pkg/torrus_Common.pm b/FS/FS/part_pkg/torrus_Common.pm
index 2465ab509..38e5499da 100644
--- a/FS/FS/part_pkg/torrus_Common.pm
+++ b/FS/FS/part_pkg/torrus_Common.pm
@@ -5,6 +5,8 @@ use List::Util qw(max);
our %info = ( 'disabled' => 1 ); #torrus_Common not a usable price plan directly
+our $DEBUG = 1;
+
sub calc_recur {
my $self = shift;
my($cust_pkg, $sdate, $details, $param ) = @_;
@@ -28,13 +30,16 @@ sub calc_usage {
my $self = shift;
my($cust_pkg, $sdate, $details, $param ) = @_;
+
my @sdate = localtime($$sdate);
my $rep_date = ($sdate[5]+1900). '-'. ($sdate[4]+1). '-01';
+ warn "searching for MonthlyUsage report for $rep_date\n" if $DEBUG;
my $rep_sql = "
SELECT id FROM reports WHERE rep_date = ?
AND reportname = 'MonthlyUsage' and iscomplete = 1
";
my $rep_id = $self->scalar_sql($rep_sql, $rep_date) or return 0;
+ warn "report id $rep_id found\n" if $DEBUG;
#abort if ! iscomplete instead?
@@ -55,10 +60,12 @@ sub calc_usage {
my $serviceid = $svc_port->serviceid;
+ warn "searching for $serviceid usage\n" if $DEBUG;
my $in = $self->scalar_sql($sql, $self->_torrus_name, $serviceid.'_IN');
my $out = $self->scalar_sql($sql, $self->_torrus_name, $serviceid.'_OUT');
my $max = max($in,$out);
+ warn "$serviceid usage is $max\n" if $DEBUG;
my $inc = $self->option($self->_torrus_base);#aggregate instead of per-port?
$max -= $inc;