diff options
| author | Christopher Burger <burgerc@freeside.biz> | 2018-11-12 10:09:26 -0500 |
|---|---|---|
| committer | Christopher Burger <burgerc@freeside.biz> | 2018-11-13 12:29:05 -0500 |
| commit | df0be9c95187a0f7c2f1449a73166aea733217b6 (patch) | |
| tree | ea6a8a0f89ec1876c7d4e7995c63f1104bd6f7e9 | |
| parent | 206ae45f19e24886aa203f66a732f69632693cfb (diff) | |
RT# 81594 - fix package churn report to properly get future revenue value of changed packages
| -rw-r--r-- | FS/FS/Report/Table.pm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/FS/FS/Report/Table.pm b/FS/FS/Report/Table.pm index 7c4f97309..d7b100df6 100644 --- a/FS/FS/Report/Table.pm +++ b/FS/FS/Report/Table.pm @@ -973,12 +973,15 @@ sub revenue_pkg { my $sql; +## if package has changed and has not reached next due date it will not be in h_cust_bill. +## this causes problems with future months, needed to use change_pkgnum instead. + if ($status eq "active") { $sql = "SELECT DISTINCT ON (revenue.pkgnum) revenue.pkgnum AS pkgnum, revenue.recur AS revenue FROM $from JOIN part_pkg ON (cust_pkg.pkgpart = part_pkg.pkgpart) JOIN cust_main ON (cust_pkg.custnum = cust_main.custnum) - JOIN h_cust_bill_pkg AS revenue ON (cust_pkg.pkgnum = revenue.pkgnum AND cust_pkg.history_date < $speriod ) + JOIN h_cust_bill_pkg AS revenue ON ((cust_pkg.pkgnum = revenue.pkgnum OR cust_pkg.change_pkgnum = revenue.pkgnum) AND cust_pkg.history_date < $speriod ) "; } elsif ($status eq "setup") { |
