X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FReport%2FTable.pm;h=d7b100df6c06a2080261cf378696e075d9f25884;hb=5bf0ab2d129310be344a9654c14796c7424138a8;hp=7c4f97309778d026063e3d6a1a34b727da4a4b76;hpb=d5988a9f7a3617de33da3058f2e9f1151b24420e;p=freeside.git 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") {