summaryrefslogtreecommitdiff
path: root/FS/FS/cust_bill_pkg.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-08-08 18:43:07 -0700
committerMark Wells <mark@freeside.biz>2013-08-09 12:03:46 -0700
commit4109791a9b80df968edaf2e71da8ebcfb8882be3 (patch)
tree0a5d623a8b18a379629d1c23596472a10bcf03a7 /FS/FS/cust_bill_pkg.pm
parentf5158f30ad19d8bc2dbd637610ff0460b9a514e7 (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 572fe79..f94bf9b 100644
--- a/FS/FS/cust_bill_pkg.pm
+++ b/FS/FS/cust_bill_pkg.pm
@@ -955,8 +955,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' :
@@ -965,6 +965,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 )";
@@ -983,8 +984,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' :
@@ -993,6 +994,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 )";