summaryrefslogtreecommitdiff
path: root/FS/FS/cust_bill_pkg.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-08-08 18:42:57 -0700
committerMark Wells <mark@freeside.biz>2013-08-09 12:04:58 -0700
commit2feef99c412039a2b718e5f3889f2c25dc1bcf73 (patch)
treec96730a1279cd17e97a483881dff064a703c8137 /FS/FS/cust_bill_pkg.pm
parent7d8eccbe9fe50eb5f69ed9bf426623110d2cf960 (diff)
unearned revenue report: consider primary object dates, not application dates, #13289
Diffstat (limited to 'FS/FS/cust_bill_pkg.pm')
-rw-r--r--FS/FS/cust_bill_pkg.pm10
1 files changed, 6 insertions, 4 deletions
diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm
index 0c8c0bbbf..acbaded49 100644
--- a/FS/FS/cust_bill_pkg.pm
+++ b/FS/FS/cust_bill_pkg.pm
@@ -949,8 +949,8 @@ Returns an SQL expression for the sum of payments applied to this item.
sub paid_sql {
my ($class, $start, $end, %opt) = @_;
- my $s = $start ? "AND cust_bill_pay._date <= $start" : '';
- my $e = $end ? "AND cust_bill_pay._date > $end" : '';
+ my $s = $start ? "AND cust_pay._date <= $start" : '';
+ my $e = $end ? "AND cust_pay._date > $end" : '';
my $setuprecur =
$opt{setuprecur} =~ /^s/ ? 'setup' :
$opt{setuprecur} =~ /^r/ ? 'recur' :
@@ -959,6 +959,7 @@ sub paid_sql {
my $paid = "( SELECT COALESCE(SUM(cust_bill_pay_pkg.amount),0)
FROM cust_bill_pay_pkg JOIN cust_bill_pay USING (billpaynum)
+ JOIN cust_pay USING (paynum)
WHERE cust_bill_pay_pkg.billpkgnum = cust_bill_pkg.billpkgnum
$s $e $setuprecur )";
@@ -977,8 +978,8 @@ sub paid_sql {
sub credited_sql {
my ($class, $start, $end, %opt) = @_;
- my $s = $start ? "AND cust_credit_bill._date <= $start" : '';
- my $e = $end ? "AND cust_credit_bill._date > $end" : '';
+ my $s = $start ? "AND cust_credit._date <= $start" : '';
+ my $e = $end ? "AND cust_credit._date > $end" : '';
my $setuprecur =
$opt{setuprecur} =~ /^s/ ? 'setup' :
$opt{setuprecur} =~ /^r/ ? 'recur' :
@@ -987,6 +988,7 @@ sub credited_sql {
my $credited = "( SELECT COALESCE(SUM(cust_credit_bill_pkg.amount),0)
FROM cust_credit_bill_pkg JOIN cust_credit_bill USING (creditbillnum)
+ JOIN cust_credit USING (crednum)
WHERE cust_credit_bill_pkg.billpkgnum = cust_bill_pkg.billpkgnum
$s $e $setuprecur )";