[freeside-commits] branch master updated. ef6a0f24282dc56037d8ed72aa2b8ce39b830310

Mark Wells mark at 420.am
Wed Jul 30 13:56:48 PDT 2014


The branch, master has been updated
       via  ef6a0f24282dc56037d8ed72aa2b8ce39b830310 (commit)
      from  8fcfaab8b0a383d8fdce74af5f88cc8f86a36a1d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ef6a0f24282dc56037d8ed72aa2b8ce39b830310
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Jul 30 13:56:32 2014 -0700

    add uncollected E911 fees to summary report, #26320

diff --git a/httemplate/search/e911.html b/httemplate/search/e911.html
index 6a9dd0a..e2283f8 100644
--- a/httemplate/search/e911.html
+++ b/httemplate/search/e911.html
@@ -14,7 +14,11 @@ table.grid TD { font-weight: bold;
     <TD><% $row->{quantity} || 0 %></TD>
   </TR>
   <TR>
-    <TD>Total fees collected: </TD>
+    <TD>Total fees charged: </TD>
+    <TD><% $money_char.sprintf('%.2f', $row->{charged_amount}) %></TD>
+  </TD>
+  <TR>
+    <TD>Fee payments collected: </TD>
     <TD><% $money_char.sprintf('%.2f', $row->{paid_amount}) %></TD>
   </TR>
   <TR>
@@ -53,18 +57,19 @@ my $agentnum = $1;
 # bazillion scalar_sql queries.  Use a properly grouped aggregate query.
 
 my $select = 'SELECT cust_bill_pkg.billpkgnum, cust_bill_pkg.quantity, '.
-'SUM(cust_bill_pay_pkg.amount) AS paid_amount';
+'cust_bill_pkg.setup, SUM(cust_bill_pay_pkg.amount) AS paid_amount';
 
 my $from = 'FROM cust_pkg
   JOIN cust_bill_pkg      USING (pkgnum)
   JOIN cust_bill          USING (invnum)
-  JOIN cust_bill_pay_pkg  USING (billpkgnum)
-  JOIN cust_bill_pay      USING (billpaynum)
+  LEFT JOIN cust_bill_pay_pkg  USING (billpkgnum)
+  LEFT JOIN cust_bill_pay      USING (billpaynum)
 ';
 # going by payment application date here, which should be
 # max(invoice date, payment date)
 my $where = "WHERE cust_pkg.pkgpart = $pkgpart
-AND cust_bill_pay._date >= $begin AND cust_bill_pay._date < $end";
+AND ( (cust_bill_pay._date >= $begin AND cust_bill_pay._date < $end)
+      OR cust_bill_pay.paynum IS NULL )";
 
 if ( $agentnum ) {
   $from .= '  JOIN cust_main ON (cust_pkg.custnum = cust_main.custnum)';
@@ -73,13 +78,14 @@ if ( $agentnum ) {
 
 my $subquery = "$select $from $where
 GROUP BY cust_bill_pkg.billpkgnum, cust_bill_pkg.quantity";
+warn $subquery;
 # This has one row for each E911 line item that has any payments applied.
 # Fields are the billpkgnum of the item (currently unused), the number of
 # E911 charges, and the total amount paid (always > 0).
 
 # now sum those rows.
-my $sql = "SELECT SUM(quantity) AS quantity, SUM(paid_amount) AS paid_amount
-FROM ($subquery) AS paid_fees"; # no grouping
+my $sql = "SELECT SUM(quantity) AS quantity, SUM(setup) AS charged_amount,
+SUM(paid_amount) AS paid_amount FROM ($subquery) AS paid_fees"; # no grouping
 
 my $sth = dbh->prepare($sql);
 $sth->execute;

-----------------------------------------------------------------------

Summary of changes:
 httemplate/search/e911.html |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)




More information about the freeside-commits mailing list