</TD>
% unless ( $cgi->param('show_taxclasses') ) {
+% my $invlink = $region->{'url_param_inv'}
+% ? ';'. $region->{'url_param_inv'}
+% : $link;
+
<<%$tdh%> ALIGN="right">
- <A HREF="<% $baselink. $link %>;istax=1"
+ <A HREF="<% $baselink. $invlink %>;istax=1"
><% &$money_sprintf( $region->{'tax'} ) %></A>
</TD>
% }
my $label = getlabel($r);
$regions{$label}->{'label'} = $label;
+
+ $regions{$label}->{$_} = $r->$_() for (qw( county state country )); #taxname?
+
$regions{$label}->{'url_param'} =
join(';', map "$_=".uri_escape($r->$_()),
qw( county state country taxname )
# );
# }
+ #false laziness -ish w/report_tax.cgi
+ my $cust_exempt;
+ if ( $r->taxname ) {
+ my $q_taxname = dbh->quote($r->taxname);
+ $cust_exempt =
+ "( tax = 'Y'
+ OR EXISTS ( SELECT 1 FROM cust_main_exemption
+ WHERE cust_main_exemption.custnum = cust_main.custnum
+ AND cust_main_exemption.taxname = $q_taxname
+ )
+ )
+ ";
+ } else {
+ $cust_exempt = " tax = 'Y' ";
+ }
+
my $x_cust = scalar_sql($r, \@param,
"SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur)
- $fromwhere AND $nottax AND tax = 'Y' "
+ $fromwhere AND $nottax AND $cust_exempt "
);
$regions{$label}->{'exempt_cust'} += $x_cust;
my( $total, $tot_taxable, $tot_owed ) = ( 0, 0, 0 );
my( $exempt_cust, $exempt_pkg, $exempt_monthly ) = ( 0, 0, 0 );
my %taxclasses = ();
+my %county = ();
+my %state = ();
+my %country = ();
foreach (@regions) {
$total += $regions{$_}->{'total'};
$tot_taxable += $regions{$_}->{'taxable'};
$exempt_monthly += $regions{$_}->{'exempt_monthly'};
$taxclasses{$regions{$_}->{'taxclass'}} = 1
if $regions{$_}->{'taxclass'};
+ $county{$regions{$_}->{'county'}} = 1;
+ $state{$regions{$_}->{'state'}} = 1;
+ $country{$regions{$_}->{'country'}} = 1;
}
my $total_url_param = '';
+my $total_url_param_invoiced = '';
if ( $group_op ) {
+
+ my @country = keys %country;
+ warn "WARNING: multiple countries on this grouped report; total links broken"
+ if scalar(@country) > 1;
+ my $country = $country[0];
+
+ my @state = keys %state;
+ warn "WARNING: multiple countries on this grouped report; total links broken"
+ if scalar(@state) > 1;
+ my $state = $state[0];
+
+ $total_url_param_invoiced =
$total_url_param =
'report_group='.uri_escape("$group_op $group_value").';'.
- join(';', map 'taxclass='.dbh->quote($_), keys %taxclasses );
+ join(';', map 'taxclass='.uri_escape($_), keys %taxclasses );
+ $total_url_param .= ';'.
+ "country=$country;state=".uri_escape($state).';'.
+ join(';', map 'county='.uri_escape($_), keys %county ) ;
+
}
#ordering
push @regions, {
'label' => 'Total',
'url_param' => $total_url_param,
+ 'url_param_inv' => $total_url_param_invoiced,
'total' => $total,
'exempt_cust' => $exempt_cust,
'exempt_pkg' => $exempt_pkg,