summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2011-01-24 00:38:00 +0000
committerivan <ivan>2011-01-24 00:38:00 +0000
commit579f53d902c7a040f853587f7e3e15eb3ec46087 (patch)
treed60aa06ec0bd89e6efe5135ff3a55916d3d885a2
parentb608648e0c400ea4ecf85c00601e13ee54c906d5 (diff)
torrus, RT#10574
-rw-r--r--FS/FS/part_pkg/torrus_Common.pm7
1 files changed, 5 insertions, 2 deletions
diff --git a/FS/FS/part_pkg/torrus_Common.pm b/FS/FS/part_pkg/torrus_Common.pm
index 38e5499da..61cdde0df 100644
--- a/FS/FS/part_pkg/torrus_Common.pm
+++ b/FS/FS/part_pkg/torrus_Common.pm
@@ -30,9 +30,12 @@ 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';
+ #sdate is next bill date, but we want the report from last month
+ my($m, $y) = ($sdate[4], $sdate[5]);
+ if ( $m == 0 ) { $m=12; $y--; }
+ $m = "0$m" if length($m) == 1;
+ my $rep_date = "$y-$m-01";
warn "searching for MonthlyUsage report for $rep_date\n" if $DEBUG;
my $rep_sql = "
SELECT id FROM reports WHERE rep_date = ?