[freeside-commits] branch FREESIDE_3_BRANCH updated. bc99ec327381b95589d30e5c6b94ee724532cb91

Mark Wells mark at 420.am
Mon Mar 9 23:13:41 PDT 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  bc99ec327381b95589d30e5c6b94ee724532cb91 (commit)
      from  b041163aaf2e447e66899b0e4a530662431cc680 (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 bc99ec327381b95589d30e5c6b94ee724532cb91
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Mar 9 23:13:05 2015 -0700

    more accurate charge type detail searches from sales report, #33257

diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi
index f4febdb..cbe37bc 100644
--- a/httemplate/search/cust_bill_pkg.cgi
+++ b/httemplate/search/cust_bill_pkg.cgi
@@ -99,11 +99,7 @@ Output control parameters:
   range of the report.  Line items will be limited to those for which this 
   portion is > 0.  This disables filtering on invoice date.
 
-- usage: Separate usage (cust_bill_pkg_detail records) from
-  recurring charges.  If set to "usage", will show usage instead of 
-  recurring charges.  If set to "recurring", will deduct usage and only
-  show the flat rate charge.  If not passed, the "recurring charge" column
-  will include usage charges also.
+- charges: 'S'etup, 'R'ecur, 'U'sage, or any string combination of those.
 
 Filtering parameters:
 - begin, end: Date range.  Applies to invoice date, not necessarily package
@@ -194,7 +190,7 @@ my @total = ( 'COUNT(*)', 'SUM(cust_bill_pkg.setup + cust_bill_pkg.recur)');
 my @total_desc = ( $money_char.'%.2f total' ); # sprintf strings
 
 my @peritem = ( 'setup', 'recur' );
-my @peritem_desc = ( 'Setup charge', 'Recurring charge' );
+my @peritem_desc = ( 'Setup charges', 'Recurring charges' );
 
 my @pkgnum_header = ();
 my @pkgnum = ();
@@ -490,16 +486,32 @@ if ( $cgi->param('nottax') ) {
 
   } # handle all joins to cust_main_county
 
-  # recur/usage separation
-  if ( $cgi->param('usage') eq 'recurring' ) {
+  # setup/recur/usage separation
+  my %charges = map { $_ => 1 } split('', $cgi->param('charges') || 'SRU');
 
-    my $recur_no_usage = FS::cust_bill_pkg->charged_sql('', '', no_usage => 1);
+  if ( $charges{R} and $charges{U} ) {
+
+    # default, don't change @peritem or @total
+    if ( !$charges{S} ) {
+      push @where, 'cust_bill_pkg.recur > 0';
+      $total[1] = "SUM(cust_bill_pkg.recur)";
+      $total_desc[0] = "$money_char%.2f recurring";
+    }
+
+  } elsif ( $charges{R} and !$charges{U} ) {
+
+    my $recur_no_usage = FS::cust_bill_pkg->charged_sql('', '', 
+      setuprecur => 'recur', no_usage => 1);
     push @select, "($recur_no_usage) AS recur_no_usage";
     $peritem[1] = 'recur_no_usage';
-    $total[1] = "SUM(cust_bill_pkg.setup + $recur_no_usage)";
-    $total_desc[0] .= ' (excluding usage)';
+    $peritem_desc[1] = 'Recurring charges (excluding usage)';
+    $total[1] = "SUM($recur_no_usage)";
+    $total_desc[0] = "$money_char%.2f recurring";
+    if ( !$charges{S} ) {
+      push @where, "($recur_no_usage) > 0";
+    }
 
-  } elsif ( $cgi->param('usage') eq 'usage' ) {
+  } elsif ( !$charges{R} and $charges{U} ) {
 
     my $usage = FS::cust_bill_pkg->usage_sql();
     push @select, "($usage) AS _usage";
@@ -507,8 +519,18 @@ if ( $cgi->param('nottax') ) {
     $peritem[1] = '_usage';
     $peritem_desc[1] = 'Usage charge';
     $total[1] = "SUM($usage)";
-    $total_desc[0] .= ' usage charges';
-  }
+    $total_desc[0] = "$money_char%.2f usage charges";
+    if ( !$charges{S} ) {
+      push @where, "($usage) > 0";
+    }
+
+  } elsif ( $charges{S} ) {
+
+    push @where, "cust_bill_pkg.setup > 0";
+    $total[1] = "SUM(cust_bill_pkg.setup)";
+    $total_desc[0] = "$money_char%.2f setup";
+
+  } # else huh? you have to have SOME charges
 
 } elsif ( $cgi->param('istax') ) {
 

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

Summary of changes:
 httemplate/search/cust_bill_pkg.cgi |   50 +++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 14 deletions(-)




More information about the freeside-commits mailing list