1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
<% include('/elements/header-popup.html', $title ) %>
<FORM ACTION="<% popurl(1)."process/bulk-cust_main_county.html" %>" METHOD="POST">
<INPUT TYPE="hidden" NAME="action" VALUE="<% $action %>">
<INPUT TYPE="hidden" NAME="taxnum" VALUE="<% join(',', @taxnum) %>">
<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
<% include('/elements/tr-td-label.html', 'label' => 'Country' ) %>
<TD BGCOLOR="#dddddd"><% $countries %>
</TD>
</TR>
<% include('/elements/tr-td-label.html', 'label' => 'State' ) %>
<TD BGCOLOR="#dddddd"><% $states %>
</TD>
</TR>
% if ( $counties ) {
<% include('/elements/tr-td-label.html', 'label' => 'County' ) %>
<TD BGCOLOR="#dddddd"><% $counties %>
</TD>
</TR>
% }
% if ( $conf->exists('enable_taxclasses') && $taxclasses ) {
<% include('/elements/tr-td-label.html', 'label' => 'Tax Class' ) %>
<TD BGCOLOR="#dddddd"><% $taxclasses %>
</TD>
</TR>
% }
<% include('/elements/tr-input-text.html',
'field' => 'taxname',
'label' => 'Tax name'
)
%>
<% include('/elements/tr-input-percentage.html',
'field' => 'tax',
'label' => 'Tax rate',
)
%>
<% include('/elements/tablebreak-tr-title.html', value=>'Exemptions' ) %>
<% include('/elements/tr-checkbox.html',
'field' => 'setuptax',
'value' => 'Y',
'label' => 'This tax not applicable to setup fees',
)
%>
<% include('/elements/tr-checkbox.html',
'field' => 'recurtax',
'value' => 'Y',
'label' => 'This tax not applicable to recurring fees',
)
%>
<% include('/elements/tr-input-money.html',
'field' => 'exempt_amount',
'label' => 'Monthly exemption per customer ($25 "Texas tax")',
)
%>
</TABLE>
<BR>
<INPUT TYPE="submit" VALUE="Bulk <% $action %> tax">
<%init>
my $conf = new FS::Conf;
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
my @taxnum;
$cgi->param('taxnum') =~ /^([\d,]+)$/
or $m->comp('/elements/errorpage-popup.html', $cgi->param('error') || 'Nothing selected');
my @taxnum = split(',', $1);
$cgi->param('action') =~ /^(add|edit)$/ or die "unknown action";
my $action = $1;
my $title = "Bulk $action tax rate";
my @cust_main_county =
map {
qsearchs('cust_main_county', { 'taxnum' => $_ })
or die "unknown taxnum $1";
}
@taxnum;
my %seen_country = {};
my @countries = map code2country($_)." ($_)",
grep !$seen_country{$_}++,
map $_->country,
@cust_main_county;
my $countries = join(', ', @countries);
my %seen_state = {};
my @states = map state_label($_->[0], $_->[1]),
grep !$seen_state{$_->[0]}++,
map [ $_->state, $_->country ],
@cust_main_county;
my $states = join(', ', @states);
my %seen_county = {};
my @counties = grep !$seen_county{$_}++, map $_->county, @cust_main_county;
my $counties = join(', ', @counties);
my %seen_taxclass = {};
my @taxclasses = grep !$seen_taxclass{$_}++, map $_->taxclass, @cust_main_county;
my $taxclasses = join(', ', @taxclasses);
#my @fields = (
# { field=>'country', type=>'fixed-country', },
# { field=>'state', type=>'fixed-state', },
# { field=>'county', type=>'fixed', },
#);
#push @fields, { field=>'taxclass', type=>'fixed', }
# if $conf->exists('enable_taxclasses');
</%init>
|