tax adjustments, RT#5595
[freeside.git] / httemplate / search / cust_tax_adjustment.html
1 <% include( 'elements/search.html',
2               'title'         => $title,
3               'name_singular' => 'tax adjustment',
4               'query'         => $query,
5               'count_query'   => $count_query,
6               'header'        => [ 'Tax', 'Amount', 'Comment', 'Invoice' ],
7               'fields'        => [ 'taxname',
8                                    sub { $money_char. shift->amount },
9                                    'comment',
10                                    sub { my $l = shift->cust_bill_pkg;
11                                          $l ? '#'.$l->invnum : '';
12                                        },
13                                  ],
14               'links'         => [ '', '', '', $ilink ],
15           )
16 %>
17
18 <%init>
19
20 die "access denied"
21   unless $FS::CurrentUser::CurrentUser->access_right('Add customer tax adjustment');
22
23 my $conf = new FS::Conf;
24 my $money_char = $conf->config('money_char') || '$';
25
26 my $count_query = 'SELECT COUNT(*) FROM cust_tax_adjustment';
27
28 my $hashref = {};
29
30 my $custnum = $cgi->param('custnum');
31 my $cust_main;
32 if ( $custnum ) {
33   $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
34   $hashref->{'custnum'} = $custnum;
35 }
36
37 my $title = 'Tax adjustments';
38 $title .= ' for '. $cust_main->name if $cust_main;
39
40 my $query = { 'table'   => 'cust_tax_adjustment',
41               'hashref' => $hashref,
42             };
43
44 my $ilink = [ $p.'view/cust_bill.cgi?', sub { my $l = shift->cust_bill_pkg;
45                                                $l ? $l->invnum : 'EXCEPTION';
46                                              }
47            ];
48
49 #XXX would be nice to list customer fields on the report too, if we ever need
50 # to link to here without a custnum (i'm sure we will, eventually...)
51
52 </%init>