From a3493ac498ed57b754f776390fb20239a11e4a04 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 25 Dec 2005 03:18:21 +0000 Subject: [PATCH] add switch to enable taxclass breakdown, report invoiced tax separately in that case --- httemplate/search/report_tax.cgi | 96 +++++++++++++++++++++++++++++++++------ httemplate/search/report_tax.html | 4 ++ 2 files changed, 86 insertions(+), 14 deletions(-) diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index cf5306c21..bfc76d787 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -3,7 +3,6 @@ my $user = getotaker; my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); -warn("***** $beginning $ending\n"); my $from_join_cust = " FROM cust_bill_pkg @@ -45,6 +44,7 @@ my $gotcust = " "; my $monthly_exempt_warning = 0; +my $taxclass_flag = 0; my($total, $tot_taxable, $owed, $tax) = ( 0, 0, 0, 0, 0 ); my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0 ); my $out = 'Out of taxable region(s)'; @@ -54,7 +54,6 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { my $label = getlabel($r); $regions{$label}->{'label'} = $label; - $regions{$label}->{'url_param'} = join(';', map "$_=".$r->$_(), qw( county state country ) ); my $fromwhere = $from_join_cust. $join_pkg. $where; @@ -63,7 +62,9 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { if ( $r->taxclass ) { $fromwhere .= " AND taxclass = ? "; push @param, 'taxclass'; - $regions{$label}->{'url_param'} .= ';taxclass='. $r->taxclass; + $regions{$label}->{'url_param'} .= ';taxclass='. $r->taxclass + if $cgi->param('show_taxclasses'); + $taxclass_flag = 1; } # my $label = getlabel($r); @@ -147,7 +148,7 @@ foreach my $r (qsearch('cust_main_county', {}, '', $gotcust) ) { my $taxwhere = "$from_join_cust $where"; my @taxparam = @base_param; - +my %base_regions = (); #foreach my $label ( keys %regions ) { foreach my $r ( qsearch( 'cust_main_county', @@ -176,12 +177,26 @@ foreach my $r ( $tax += $x; $regions{$label}->{'tax'} += $x; + if ( $cgi->param('show_taxclasses') ) { + my $base_label = getlabel($r, 'no_taxclass'=>1 ); + $base_regions{$base_label}->{'label'} = $base_label; + $base_regions{$base_label}->{'url_param'} = + join(';', map "$_=".$r->$_(), qw( county state country ) ); + $base_regions{$base_label}->{'tax'} += $x; + } + } #ordering -my @regions = map $regions{$_}, - sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } - keys %regions; +my @regions = + map $regions{$_}, + sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } + keys %regions; + +my @base_regions = + map $base_regions{$_}, + sort { ( ($a eq $out) cmp ($b eq $out) ) || ($b cmp $a) } + keys %base_regions; push @regions, { 'label' => 'Total', @@ -200,6 +215,7 @@ push @regions, { sub getlabel { my $r = shift; + my %opt = @_; my $label; if ( @@ -224,7 +240,10 @@ sub getlabel { $label = $r->country; $label = $r->state.", $label" if $r->state; $label = $r->county." county, $label" if $r->county; - $label = "$label (". $r->taxclass. ")" if $r->taxclass; + $label = "$label (". $r->taxclass. ")" + if $r->taxclass + && $cgi->param('show_taxclasses') + && ! $opt{'no_taxclasses'}; #$label = $r->taxname. " ($label)" if $r->taxname; } return $label; @@ -263,11 +282,13 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; <%= include('/elements/table-grid.html') %> - - Sales - Rate - Tax owed - Tax invoiced + + Sales + Rate + Tax owed + <% unless ( $cgi->param('show_taxclasses') ) { %> + Tax invoiced + <% } %> Total @@ -299,6 +320,7 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; } } %> + <%= $region->{'label'} %> @@ -320,13 +342,59 @@ my $baselink = $p. "search/cust_bill_pkg.cgi?begin=$beginning;end=$ending"; $<%= sprintf('%.2f', $region->{'owed'} ) %> + <% unless ( $cgi->param('show_taxclasses') ) { %> + + $<%= sprintf('%.2f', $region->{'tax'} ) %> + + <% } %> + + + <% } %> + + + + +<% if ( $cgi->param('show_taxclasses') ) { %> + +
+ <%= include('/elements/table-grid.html') %> + + + Tax invoiced + + + <% #some false laziness w/above + foreach my $region ( @base_regions ) { + + if ( $bgcolor eq $bgcolor1 ) { + $bgcolor = $bgcolor2; + } else { + $bgcolor = $bgcolor1; + } + + my $link = $baselink; + if ( $region->{'label'} ne 'Total' ) { + if ( $region->{'label'} eq $out ) { + $link .= ';out=1'; + } else { + $link .= ';'. $region->{'url_param'}; + } + } + %> + + + <%= $region->{'label'} %> $<%= sprintf('%.2f', $region->{'tax'} ) %> + <% } %> - + + +<% } %> + <% if ( $monthly_exempt_warning ) { %>
diff --git a/httemplate/search/report_tax.html b/httemplate/search/report_tax.html index 38b665a5a..eeaccc1ab 100755 --- a/httemplate/search/report_tax.html +++ b/httemplate/search/report_tax.html @@ -8,6 +8,10 @@ <%= include( '/elements/tr-select-agent.html' ) %> <%= include( '/elements/tr-input-beginning_ending.html' ) %> + + + +
Show tax classes

-- 2.11.0