fe232757f85f48a9f9c4817d5274ca9ec12b980e
[freeside.git] / httemplate / edit / process / cust_tax_adjustment.html
1 % if ( $error ) {
2 %   $cgi->param('error', $error );
3 <% $cgi->redirect($p.'cust_tax_adjustment.html?'. $cgi->query_string) %>
4 % } else {
5 <% header("Tax adjustment added") %>
6   <SCRIPT TYPE="text/javascript">
7     //topreload();
8     parent.cClick();
9   </SCRIPT>
10   </BODY></HTML>
11 % }
12 <%init>
13
14 die "access denied"
15   unless $FS::CurrentUser::CurrentUser->access_right('Add customer tax adjustment');
16
17 my $error = '';
18 my $conf = new FS::conf;
19 my $param = $cgi->Vars;
20
21 $param->{"custnum"} =~ /^(\d+)$/
22   or $error .= "Illegal customer number " . $param->{"custnum"} . "  ";
23 my $custnum = $1;
24
25 $param->{"amount"} =~ /^\s*(\d*(?:\.?\d{1,2}))\s*$/
26   or $error .= "Illegal amount " . $param->{"amount"} . "  ";
27 my $amount = $1;
28
29 unless ( $error ) {
30
31   my $cust_tax_adjustment = new FS::cust_tax_adjustment {
32     'custnum' => $custnum,
33     'taxname' => $param->{'taxname'},
34     'amount'  => $amount,
35     'comment' => $param->{'comment'},
36   };
37   $error = $cust_tax_adjustment->insert;
38
39 }
40
41 </%init>