1 <% include('/elements/header-popup.html', 'Addition successful' ) %>
3 <SCRIPT TYPE="text/javascript">
12 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
14 $cgi->param('taxnum') =~ /^(\d+)$/ or die "Illegal taxnum!";
16 my $cust_main_county = qsearchs('cust_main_county',{'taxnum'=>$taxnum})
17 or die ("Unknown taxnum!");
19 my @expansion = split /[\n\r]{1,2}/, $cgi->param('expansion');
22 unless ( /^\s*([\w \!\@\#\$\%\&\(\)\-\+\;\:\'\"\,\.\?\/\=\[\]]+)\s*$/ ) {
23 $cgi->param('error', "Illegal item in expansion: $_");
24 print $cgi->redirect(popurl(2). "cust_main_county-expand.cgi?". $cgi->query_string );
30 my $what = $cgi->param('what');
31 foreach my $new_tax_area ( @expansion ) {
33 # Clone specific tax columns from original tax row
35 # UI Note: Preserving original behavior, of cloning
36 # tax amounts into new tax record, against better
37 # judgement. If the new city/county/state has a
38 # different tax value than the one being populated
39 # (rather likely?) now the user must remember to
40 # revisit each newly created tax row, and correct
41 # the possibly incorrect tax values that were populated.
42 # Values would be easier to identify and correct if
43 # they were initially populated with 0% tax rates
44 # District Note: The 'district' column is NOT cloned
45 # to the new tax row. Manually entered taxes
46 # are not be divided into road maintenance districts
47 # like Washington state sales taxes
48 my $new = FS::cust_main_county->new({
49 map { $_ => $cust_main_county->getfield($_) }
53 exempt_amount_currency
61 # Clone additional location columns, based on the $what value
62 my %clone_cols_for = (
63 state => [qw/country /],
64 county => [qw/country state/],
65 city => [qw/country state county/],
68 die "unknown what: $what"
69 unless grep { $_ eq $what } keys %clone_cols_for;
71 $new->setfield( $_ => $cust_main_county->getfield($_) )
72 for @{ $clone_cols_for{ $cgi->param('what') } };
74 # In the US, store cities upper case for USPS validation
75 $new_tax_area = uc($new_tax_area)
77 && $new->country eq 'US';
79 $new->setfield( $what, $new_tax_area );
80 if ( my $error = $new->insert ) {