summaryrefslogtreecommitdiff
path: root/httemplate/edit/tax_rate.html
blob: bff699946c93a3d1e9953a9c9cb4ff11f75d60d5 (plain)
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
<% include('elements/edit.html',
     'popup'          => 1,
     'name'           => 'Tax rate', #Edit tax rate
     'table'          => 'tax_rate',
     'labels'         => $labels,
     'fields'         => \@fields,
     'value_callback' => $value_callback,
   )
%>
<%once>

my $conf = new FS::Conf;
my $value_callback =
  sub { my ( $field, $value ) = @_;
        ( $field =~ /^(tax|excessrate|usetax|useexcessrate)$/ )
          ? $value*100
          : $value;
      };

</%once>

<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $taxnum;
if ( $cgi->param('error') ) {
  $cgi->param('taxnum') =~ /^(\d+)$/ or die 'error, but no taxnum';
  $taxnum = $1;
} else {
  my($query) = $cgi->keywords;
  $query =~ /^(\d+)$/ or die 'no taxnum';
  $taxnum = $1;
}

my $tax_rate = qsearchs('tax_rate', { 'taxnum' => $taxnum })
  or die "unknown taxnum $1";

my $labels =  { 'taxnum'               => 'Tax',
                'data_vendor'          => 'Data vendor',
                'geocode'              => 'Vendor location code',
                'location'             => 'Tax auth loc code',
                'taxclass_description' => 'Tax class',
                'taxname'              => 'Tax name',
                'effective_date'       => 'Effective date',
                'tax'                  => 'Tax rate (1st bracket)',
                'excessrate'           => 'Tax rate (2nd bracket)',
                'taxbase'              => 'First bracket',
                'taxmax'               => 'Max tax',
                'usetax'               => 'Use tax rate (1st bracket)',
                'useexcessrate'        => 'Use tax rate (2nd bracket)',
                'unittype_name'        => 'Units',
                'fee'                  => 'Fee per unit (1st bracket)',
                'excessfee'            => 'Fee per unit (2st bracket)',
                'feebase'              => 'Units in first bracket',
                'feemax'               => 'Max Units',
                'maxtype_name'         => 'Threshold accumulation',
                'taxauth_name',        => 'Tax authority',
                'basetype_name'        => 'Basis',
                'passtype_name'        => 'Passthru',
                'passflag'             => 'Passable',
                'setuptax'             => 'This tax not applicable to setup fees',
                'recurtax'             => 'This tax not applicable to recurring fees',
              };

my @fields = (
    { type=>'tablebreak-tr-title',   value=>'Location' },
    { field=>'data_vendor',          type=>'hidden',},
    { field=>'geocode',              type=>'fixed' },
    { field=>'taxclassnum',          type=>'hidden' } ,
    { field=>'taxclass_description', type=>'fixed' } ,
    { field=>'taxname',              type=>'text' } ,
    { field=>'effective_date',       type=>'fixed' } ,
    { field=>'location',             type=>'text' },
    { type=>'tablebreak-tr-title',   value=>'Money based rates' },
    { field=>'tax',                  type=>'percentage' } ,
    { field=>'excessrate',           type=>'percentage' } ,
    { field=>'taxbase',              type=>'money' } ,
    { field=>'taxmax',               type=>'money' } ,
    { field=>'usetax',               type=>'percentage' } ,
    { field=>'useexcessrate',        type=>'percentage' } ,
    { type=>'tablebreak-tr-title',   value=>'Service based rates' },
    { field=>'unittype',             type=>'hidden' } ,
    { field=>'unittype_name',        type=>'fixed' } ,
    { field=>'fee',                  type=>'money' } ,
    { field=>'excessfee',            type=>'money' } ,
    { field=>'feebase',              type=>'text' } ,
    { field=>'feemax',               type=>'text' } ,
    { type=>'tablebreak-tr-title',   value=>'Taxation rules' },
    { field=>'maxtype',              type=>'hidden' } ,
    { field=>'maxtype_name',         type=>'fixed' } ,
    { field=>'taxauth',              type=>'hidden' } ,
    { field=>'taxauth_name',         type=>'fixed' } ,
    { field=>'basetype',             type=>'hidden' } ,
    { field=>'basetype_name',        type=>'fixed' } ,
    { field=>'passtype',             type=>'hidden' } ,
    { field=>'passtype_name',        type=>'fixed' } ,
    { field=>'passflag',             type=>'fixed' } ,
    { field=>'setuptax',             type=>'checkbox', value=>'Y'  } ,
    { field=>'recurtax',             type=>'checkbox', value=>'Y'  } ,
    { field=>'disabled',             type=>'checkbox', value=>'Y'  } ,
    { field=>'manual',               type=>'hidden', value=>'Y' } ,
);

</%init>