[freeside-commits] freeside/httemplate/search report_tax.cgi, 1.53, 1.54

Ivan,,, ivan at wavetail.420.am
Mon May 25 19:03:34 PDT 2009


Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv8531/httemplate/search

Modified Files:
	report_tax.cgi 
Log Message:
mostly fix total line when using config option for some basic tax grouping by name, RT#5446

Index: report_tax.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_tax.cgi,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- report_tax.cgi	26 May 2009 01:43:30 -0000	1.53
+++ report_tax.cgi	26 May 2009 02:03:32 -0000	1.54
@@ -275,16 +275,6 @@
     "WHERE 0 < ( SELECT COUNT(*) FROM cust_main WHERE $gotcust LIMIT 1 )";
 }
 
-#tax-report_groups filtering
-my($group_op, $group_value) = ( '', '' );
-if ( $cgi->param('report_group') =~ /^(=|!=) (.*)$/ ) {
-  ( $group_op, $group_value ) = ( $1, $2 );
-}
-my $skipping_out = $group_op ? 1 : 0; #in case there are other reasons
-
-my( $total, $tot_taxable, $tot_owed ) = ( 0, 0, 0 );
-my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0, 0 );
-
 my $out = 'Out of taxable region(s)';
 my %regions = ();
 
@@ -335,9 +325,8 @@
    "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) $fromwhere AND $nottax";
   my $t = scalar_sql($r, \@param, $t_sql);
   $regions{$label}->{'total'} += $t;
-  $total += $t unless $label eq $out && $skipping_out;
 
-  #if ( $label eq $out ) {# && $t ) {
+  #if ( $label eq $out ) # && $t ) {
   #  warn "adding $t for ".
   #       join('/', map $r->$_, qw( taxclass county state country ) ). "\n";
   #  #warn $t_sql if $r->state eq 'FL';
@@ -365,7 +354,6 @@
   );
 
   $regions{$label}->{'exempt_cust'} += $x_cust;
-  $exempt_cust += $x_cust unless $label eq $out && $skipping_out;
   
   ## calculate package-exemption for this region
 
@@ -393,7 +381,6 @@
     "
   );
   $regions{$label}->{'exempt_pkg'} += $x_pkg;
-  $exempt_pkg += $x_pkg unless $label eq $out && $skipping_out;
 
   ## calculate monthly exemption (texas tax) for this region
 
@@ -407,22 +394,12 @@
        $join_cust_pkg
      $mywhere"
   );
-#  if ( $x_monthly ) {
-#    #warn $r->taxnum(). ": $x_monthly\n";
-#    $taxable -= $x_monthly;
-#  }
-
   $regions{$label}->{'exempt_monthly'} += $x_monthly;
-  $exempt_monthly += $x_monthly unless $label eq $out && $skipping_out;
 
   my $taxable = $t - $x_cust - $x_pkg - $x_monthly;
-
   $regions{$label}->{'taxable'} += $taxable;
-  $tot_taxable += $taxable unless $label eq $out && $skipping_out;
 
-  my $owed = $taxable * ($r->tax/100);
-  $regions{$label}->{'owed'} += $owed;
-  $tot_owed += $owed unless $label eq $out && $skipping_out;
+  $regions{$label}->{'owed'} += $taxable * ($r->tax/100);
 
   if ( defined($regions{$label}->{'rate'})
        && $regions{$label}->{'rate'} != $r->tax.'%' ) {
@@ -523,11 +500,12 @@
 
 }
 
-
 my @regions = keys %regions;
 
 #tax-report_groups filtering
-if ( $group_op ) {
+my($group_op, $group_value) = ( '', '' );
+if ( $cgi->param('report_group') =~ /^(=|!=) (.*)$/ ) {
+  ( $group_op, $group_value ) = ( $1, $2 );
   @regions = grep {
     if ( $_ eq $out ) { #don't display "out of taxable region" in this case
       0;
@@ -541,6 +519,18 @@
   } @regions;
 }
 
+#now calculate totals
+my( $total, $tot_taxable, $tot_owed ) = ( 0, 0, 0 );
+my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0, 0 );
+foreach (@regions) {
+  $total          += $regions{$_}->{'total'};
+  $tot_taxable    += $regions{$_}->{'taxable'};
+  $tot_owed       += $regions{$_}->{'owed'};
+  $exempt_cust    += $regions{$_}->{'exempt_cust'};
+  $exempt_pkg     += $regions{$_}->{'exempt_pkg'};
+  $exempt_monthly += $regions{$_}->{'exempt_monthly'};
+}
+
 #ordering
 @regions =
   map $regions{$_},



More information about the freeside-commits mailing list