summaryrefslogtreecommitdiff
path: root/httemplate/search/report_tax.html
blob: 8d8d1084c4eb12f1f73b26a74d16ef0f17cd3527 (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
<% include('/elements/header.html', 'Tax Report' ) %>

<FORM ACTION="report_tax.cgi" METHOD="GET">

<TABLE>

  <& /elements/tr-select-agent.html, 'disable_empty'=>0 &>

  <& /elements/tr-input-beginning_ending.html &>

  <& /elements/tr-select.html,
    'label'         => 'Country',
    'field'         => 'country',
    'options'       => \@countries,
    'curr_value'    => ($conf->config('countrydefault') || 'US'),
  &>

  <& /elements/tr-select.html,
    'label'         => 'For tax named ',
    'field'         => 'taxname',
    'options'       => \@taxnames,
    'disable_empty' => 1,
  &>

  <& /elements/tr-checkbox-multiple.html,
    'label'         => 'Break down by ',
    'field'         => 'breakdown',
    'options'       => \@breakdown,
    'option_labels' => {
      taxclass  => 'Tax class',
      pkgclass  => 'Package class',
      city      => 'City',
      district  => 'District',
    },
  &>
  <TR>
    <TD></TD>
    <TD>Deduct credited tax if it was 
      <SELECT NAME="credit_date">
        <OPTION VALUE="cust_bill" SELECTED>invoiced in this period</OPTION>
        <OPTION VALUE="cust_credit_bill">credited in this period</OPTION>
      </SELECT>
    </TD>
  </TR>

</TABLE>

<BR><INPUT TYPE="submit" VALUE="Get Report">

</FORM>

<% include('/elements/footer.html') %>
<%init>

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

my $conf = new FS::Conf;

my $sth = dbh->prepare('SELECT DISTINCT(COALESCE(taxname, \'Tax\')) FROM cust_main_county');
$sth->execute or die $sth->errstr;
my @taxnames = map { $_->[0] } @{ $sth->fetchall_arrayref };

$sth = dbh->prepare('SELECT DISTINCT(country) FROM cust_location');
$sth->execute or die $sth->errstr;
my @countries = map { $_->[0] } @{ $sth->fetchall_arrayref };

my @breakdown;
if ( $conf->exists('enable_taxclasses') ) {
  push @breakdown, 'taxclass';
}
if ( FS::pkg_class->count() > 0 ) {
  push @breakdown, 'pkgclass';
}
if ( FS::cust_main_county->count("city is not null and city != ''") > 0 ) {
  push @breakdown, 'city';
}
if ( FS::cust_main_county->count("district is not null") > 0 ) {
  push @breakdown, 'district';
}

</%init>