% # Row label
<% $row->{label} |h %> |
% # Total sales
<% $money_sprintf->( $row->{sales} ) %>
|
% # Exemptions: customer
<% $money_sprintf->( $row->{exempt_cust} ) %>
|
% # package
<% $money_sprintf->( $row->{exempt_pkg} ) %>
|
% # monthly (note this uses $exemptlink; it's a completely separate report)
<% $money_sprintf->( $row->{exempt_monthly} ) %>
|
% # taxable sales
">
<% $money_sprintf->( $row->{taxable} ) %>
|
× |
<% $row->{rate} %> |
% # estimated tax
= |
% if ( $row->{estimated} ) {
<% $money_sprintf->( $row->{estimated} ) %>
% }
|
% # invoiced tax
<% $money_sprintf->( $row->{tax} ) %>
|
% # credited tax
− |
<% $money_sprintf->( $row->{credit} ) %>
|
% # net tax due
= |
<% $money_sprintf->( $row->{tax} - $row->{credit} ) %> |
% $rownum++;
% $prev_row = $row;
% } # foreach my $row
<& /elements/footer.html &>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
my $DEBUG = $cgi->param('debug') || 0;
my $conf = new FS::Conf;
my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
my %params = (
beginning => $beginning,
ending => $ending,
);
$params{country} = $cgi->param('country');
$params{debug} = $DEBUG;
$params{breakdown} = { map { $_ => 1 } $cgi->param('breakdown') };
my $agentname;
if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
my $agent = FS::agent->by_key($1) or die "unknown agentnum $1";
$params{agentnum} = $1;
$agentname = $agent->agentname;
}
if ( $cgi->param('taxname') =~ /^([\w ]+)$/ ) {
$params{taxname} = $1;
} else {
die "taxname required";
}
if ( $cgi->param('credit_date') eq 'cust_credit_bill' ) {
$params{credit_date} = 'cust_credit_bill';
} else {
$params{credit_date} = 'cust_bill';
}
warn "PARAMS:\n".Dumper(\%params)."\n\n" if $DEBUG;
my $report = FS::Report::Tax->report_internal(%params);
my @rows = $report->table; # array of hashrefs
my $money_char = $conf->config('money_char') || '$';
my $money_sprintf = sub {
$money_char. sprintf('%.2f', shift);
};
my $dateagentlink = "begin=$beginning;end=$ending";
$dateagentlink .= $params{agentnum} if $params{agentnum};
my $saleslink = $p. "search/cust_bill_pkg.cgi?$dateagentlink;nottax=1";
my $taxlink = $p. "search/cust_bill_pkg.cgi?$dateagentlink;istax=1";
my $exemptlink = $p. "search/cust_tax_exempt_pkg.cgi?$dateagentlink";
my $creditlink = $p. "search/cust_bill_pkg.cgi?$dateagentlink;credit=1;istax=1";
if ( $params{'credit_date'} eq 'cust_credit_bill' ) {
$creditlink =~ s/begin/credit_begin/;
$creditlink =~ s/end/credit_end/;
}
my %pkgclass_name = map { $_->classnum, $_->classname } qsearch('pkg_class');
$pkgclass_name{''} = 'Unclassified';
%init>