[freeside-commits] freeside/httemplate/search report_tax.cgi, 1.55, 1.56 cust_bill_pkg.cgi, 1.19, 1.20
Ivan,,,
ivan at wavetail.420.am
Wed May 27 10:18:38 PDT 2009
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv17287
Modified Files:
report_tax.cgi cust_bill_pkg.cgi
Log Message:
fix total line links on tax report when using report_group kludge? (possibly not in all corner cases), RT#5446
Index: report_tax.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_tax.cgi,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- report_tax.cgi 26 May 2009 02:48:44 -0000 1.55
+++ report_tax.cgi 27 May 2009 17:18:36 -0000 1.56
@@ -44,12 +44,11 @@
% foreach my $region ( @regions ) {
%
% my $link = '';
-% if ( $region->{'label'} ne 'Total' ) {
-% if ( $region->{'label'} eq $out ) {
-% $link = ';out=1';
-% } else {
-% $link = ';'. $region->{'url_param'};
-% }
+% if ( $region->{'label'} eq $out ) {
+% $link = ';out=1';
+% } else {
+% $link = ';'. $region->{'url_param'}
+% if $region->{'url_param'};
% }
%
% if ( $bgcolor eq $bgcolor1 ) {
@@ -138,13 +137,12 @@
% foreach my $region ( @base_regions ) {
%
% my $link = '';
-% #if ( $region->{'label'} ne 'Total' ) {
-% if ( $region->{'label'} eq $out ) {
-% $link = ';out=1';
-% } else {
-% $link = ';'. $region->{'url_param'};
-% }
-% #}
+% if ( $region->{'label'} eq $out ) {
+% $link = ';out=1';
+% } else {
+% $link = ';'. $region->{'url_param'}
+% if $region->{'url_param'};
+% }
%
% if ( $bgcolor eq $bgcolor1 ) {
% $bgcolor = $bgcolor2;
@@ -277,6 +275,7 @@
my $out = 'Out of taxable region(s)';
my %regions = ();
+my %taxclasses = ();
foreach my $r ( qsearch({ 'table' => 'cust_main_county',
'extra_sql' => $gotcust,
@@ -302,6 +301,8 @@
$regions{$label}->{'url_param'} .= ';taxclass='. uri_escape($r->taxclass);
#no, always# if $cgi->param('show_taxclasses');
+ $taxclasses{$r->taxclass} = 1;
+
} else {
$regions{$label}->{'url_param'} .= ';taxclassNULL=1'
@@ -528,7 +529,18 @@
@regions = grep &{$group_test}($_), @regions
if $group_op;
-#now calculate totals
+#ordering
+ at regions =
+ map $regions{$_},
+ sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) }
+ @regions;
+
+my @base_regions =
+ map $base_regions{$_},
+ sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) }
+ keys %base_regions;
+
+#totals
my( $total, $tot_taxable, $tot_owed ) = ( 0, 0, 0 );
my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0, 0 );
foreach (@regions) {
@@ -540,20 +552,16 @@
$exempt_monthly += $regions{$_}->{'exempt_monthly'};
}
-#ordering
- at regions =
- map $regions{$_},
- sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) }
- @regions;
+my $total_url_param = '';
-my @base_regions =
- map $base_regions{$_},
- sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) }
- keys %base_regions;
+if ( $group_op ) {
+ $total_url_param = 'report_group='.uri_escape("$group_op $group_value").';'.
+ join(';', 'taxclass = '.dbh->quote($_), keys %taxclasses );
+}
push @regions, {
'label' => 'Total',
- 'url_param' => '',
+ 'url_param' => $total_url_param,
'total' => $total,
'exempt_cust' => $exempt_cust,
'exempt_pkg' => $exempt_pkg,
Index: cust_bill_pkg.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/cust_bill_pkg.cgi,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- cust_bill_pkg.cgi 13 May 2009 22:27:42 -0000 1.19
+++ cust_bill_pkg.cgi 27 May 2009 17:18:36 -0000 1.20
@@ -83,6 +83,10 @@
push @where, "cust_main.agentnum = $1";
}
+#classnum
+# not specified: all classes
+# 0: empty class
+# N: classnum
if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
if ( $1 == 0 ) {
push @where, "classnum IS NULL";
@@ -91,6 +95,13 @@
}
}
+push @where, map ' taxclass = '.dbh->quote($_), $cgi->param('taxclass')
+ if $cgi->param('taxclass')
+ && ! $cgi->param('istax'); #no part_pkg.taxclass in this case
+ #(should we save a taxclass or a link to taxnum
+ # in cust_bill_pkg or something like
+ # cust_bill_pkg_tax_location?)
+
#sub _where {
# my $table = shift;
# my $prefix = @_ ? shift : '';
@@ -143,7 +154,7 @@
}
-} elsif ( $cgi->param('country' ) ) {
+} elsif ( $cgi->param('country') ) {
my %ph = map { $_ => dbh->quote( $cgi->param($_) ) }
qw( county state country );
@@ -168,13 +179,6 @@
#warn "neither nottax nor istax parameters specified";
}
- push @where, ' taxclass = '. dbh->quote( $cgi->param('taxclass') )
- if $cgi->param('taxclass')
- && ! $cgi->param('istax'); #no part_pkg.taxclass in this case
- #(should we save a taxclass or a link to taxnum
- # in cust_bill_pkg or something like
- # cust_bill_pkg_tax_location?)
-
if ( $cgi->param('taxclassNULL') ) {
my %hash = ( 'country' => scalar($cgi->param('country')) );
@@ -189,7 +193,7 @@
}
- } elsif ( scalar( grep( /locationtaxid/, $cgi->param ) ) ) {
+} elsif ( scalar( grep( /locationtaxid/, $cgi->param ) ) ) {
# this should really be shoved out to FS::cust_pkg->location_sql or something
# along with the code in report_newtax.cgi
@@ -211,13 +215,27 @@
}
-if ($cgi->param('itemdesc')) {
- if ($cgi->param('itemdesc') eq 'Tax') {
+if ( $cgi->param('itemdesc') ) {
+ if ( $cgi->param('itemdesc') eq 'Tax' ) {
push @where, "(itemdesc='Tax' OR itemdesc is null)";
- }else{
+ } else {
push @where, 'itemdesc='. dbh->quote($cgi->param('itemdesc'));
}
}
+
+if ( $cgi->param('report_group') =~ /^(=|!=) (.*)$/ && $cgi->param('istax') ) {
+ my ( $group_op, $group_value ) = ( $1, $2 );
+ if ( $group_op eq '=' ) {
+ #push @where, 'itemdesc LIKE '. dbh->quote($group_value.'%');
+ push @where, 'itemdesc = '. dbh->quote($group_value);
+ } elsif ( $group_op eq '!=' ) {
+ push @where, '( itemdesc != '. dbh->quote($group_value) .' OR itemdesc IS NULL )';
+ } else {
+ die "guru meditation #00de: group_op $group_op\n";
+ }
+
+}
+
push @where, 'cust_bill_pkg.pkgnum != 0' if $cgi->param('nottax');
push @where, 'cust_bill_pkg.pkgnum = 0' if $cgi->param('istax');
More information about the freeside-commits
mailing list