summaryrefslogtreecommitdiff
path: root/httemplate/search/cust_tax_adjustment.html
blob: 925476516f7e7050a021c19e2a6c3636cdb7ab9c (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
<% include( 'elements/search.html',
              'title'         => $title,
              'name_singular' => 'tax adjustment',
              'query'         => $query,
              'count_query'   => $count_query,
              'header'        => [ 'Tax', 'Amount', 'Comment', 'Invoice' ],
              'fields'        => [ 'taxname',
                                   sub { $money_char. shift->amount },
                                   'comment',
                                   sub { my $l = shift->cust_bill_pkg;
                                         $l ? '#'.$l->invnum : '';
                                       },
                                 ],
              'links'         => [ '', '', '', $ilink ],
          )
%>

<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Add customer tax adjustment');

my $conf = new FS::Conf;
my $money_char = $conf->config('money_char') || '$';

my $count_query = 'SELECT COUNT(*) FROM cust_tax_adjustment';

my $hashref = {};

my $custnum = '';
my $cust_main = '';
if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
  $custnum = $1;
  $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
  $hashref->{'custnum'} = $custnum;
  $count_query .= " WHERE custnum = $custnum ";
}

my $title = 'Tax adjustments';
$title .= ' for '. $cust_main->name if $cust_main;

my $query = { 'table'   => 'cust_tax_adjustment',
              'hashref' => $hashref,
            };

my $ilink = [ $p.'view/cust_bill.cgi?', sub { my $l = shift->cust_bill_pkg;
                                               $l ? $l->invnum : 'EXCEPTION';
                                             }
           ];

#XXX would be nice to list customer fields on the report too, if we ever need
# to link to here without a custnum (i'm sure we will, eventually...)

</%init>