add conditions for customer cancelled packages, RT#42043
[freeside.git] / httemplate / search / report_tax.html
1 <% include('/elements/header.html', 'Tax Report' ) %>
2
3 <FORM ACTION="report_tax.cgi" METHOD="GET">
4
5 <TABLE>
6
7   <& /elements/tr-select-agent.html, 'disable_empty'=>0 &>
8
9   <& /elements/tr-input-beginning_ending.html &>
10
11   <& /elements/tr-select.html,
12     'label'         => 'Country',
13     'field'         => 'country',
14     'options'       => \@countries,
15     'curr_value'    => ($conf->config('countrydefault') || 'US'),
16   &>
17
18   <& /elements/tr-select.html,
19     'label'         => 'For tax named ',
20     'field'         => 'taxname',
21     'options'       => \@taxnames,
22     'disable_empty' => 1,
23   &>
24
25   <& /elements/tr-checkbox-multiple.html,
26     'label'         => 'Break down by ',
27     'field'         => 'breakdown',
28     'options'       => \@breakdown,
29     'option_labels' => {
30       taxclass  => 'Tax class',
31       pkgclass  => 'Package class',
32       city      => 'City',
33       district  => 'District',
34     },
35   &>
36   <TR>
37     <TD></TD>
38     <TD>Deduct credited tax if it was 
39       <SELECT NAME="credit_date">
40         <OPTION VALUE="cust_bill" SELECTED>invoiced in this period</OPTION>
41         <OPTION VALUE="cust_credit_bill">credited in this period</OPTION>
42       </SELECT>
43     </TD>
44   </TR>
45
46 </TABLE>
47
48 <BR><INPUT TYPE="submit" VALUE="Get Report">
49
50 </FORM>
51
52 <% include('/elements/footer.html') %>
53 <%init>
54
55 die "access denied"
56   unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
57
58 my $conf = new FS::Conf;
59
60 my $sth = dbh->prepare('SELECT DISTINCT(COALESCE(taxname, \'Tax\')) FROM cust_main_county');
61 $sth->execute or die $sth->errstr;
62 my @taxnames = map { $_->[0] } @{ $sth->fetchall_arrayref };
63
64 $sth = dbh->prepare('SELECT DISTINCT(country) FROM cust_location');
65 $sth->execute or die $sth->errstr;
66 my @countries = map { $_->[0] } @{ $sth->fetchall_arrayref };
67
68 my @breakdown;
69 if ( $conf->exists('enable_taxclasses') ) {
70   push @breakdown, 'taxclass';
71 }
72 if ( FS::pkg_class->count() > 0 ) {
73   push @breakdown, 'pkgclass';
74 }
75 if ( FS::cust_main_county->count("city is not null and city != ''") > 0 ) {
76   push @breakdown, 'city';
77 }
78 if ( FS::cust_main_county->count("district is not null") > 0 ) {
79   push @breakdown, 'district';
80 }
81
82 </%init>