From: Christopher Burger Date: Tue, 13 Nov 2018 18:59:47 +0000 (-0500) Subject: Merge branch 'FREESIDE_3_BRANCH' of ssh://git.freeside.biz/home/git/freeside into... X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=89e1257e03af79981f378a53cb184f35060e0548;hp=95ea28727a29f53f945dd0c68fda95ec1f6e4560 Merge branch 'FREESIDE_3_BRANCH' of ssh://git.freeside.biz/home/git/freeside into FREESIDE_3_BRANCH --- 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") {