X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Freport_tax.cgi;h=1d906473edf2c6e9ac9cdd1ba30a7f815b4be353;hb=c0c5709fb022b83a482d0b35f7094505766d5868;hp=ac76fad6e7ad50c2add0f8cb6a34a41cda96cb97;hpb=eb9668a6f3181ee02cb335272c5ee4616e61fd09;p=freeside.git
diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi
old mode 100755
new mode 100644
index ac76fad6e..1d906473e
--- a/httemplate/search/report_tax.cgi
+++ b/httemplate/search/report_tax.cgi
@@ -1,25 +1,236 @@
-
-<%
+<& /elements/header.html, $report->title &>
+
+Download full results
+as Excel spreadsheet
+ |
-my $user = getotaker;
+
+<& /elements/table-grid.html &>
+
+
+ |
+ Sales |
+ |
+ Rate |
+ |
+ Estimated tax |
+ Tax invoiced |
+ |
+ Tax credited |
+ |
+ Net tax due |
+ |
+ Tax collected |
+
+
+
+ Total |
+ Non-taxable |
+ Non-taxable |
+ Non-taxable |
+ Taxable |
+
+
+
+ (tax-exempt customer) |
+ (tax-exempt package) |
+ (monthly exemption) |
+
+
+
+% my $rownum = 0;
+% my $prev_row = { pkgclass => 'DUMMY PKGCLASS' };
+
+
+% foreach my $row (@rows) {
+% # before anything else: if this row's pkgclass is not the same as the
+% # previous row's, then:
+% if ( $row->{pkgclass} ne $prev_row->{pkgclass} ) {
+% if ( $rownum > 0 ) { # start a new section
+% $rownum = 0;
+
+% }
+% if ( $params{breakdown}->{pkgclass} ) { # and caption the new section
+
+
+ <% $pkgclass_name{$row->{pkgclass}} %>
+ |
+
+% }
+% } # if $row->{pkgclass} ne ...
+
+% # construct base links that limit to the tax rates described by this row
+% my $rowlink = ';taxnum=' . $row->{taxnums};
+% # and also the package class, if we're limiting package class
+% if ( $params{breakdown}->{pkgclass} ) {
+% $rowlink .= ';classnum=' . ($row->{pkgclass} || 0);
+% }
+%
+% if ( $row->{total} ) {
+
+% }
+
+% # 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
+ − |
+
+%# currently broken
+ <% $money_sprintf->( $row->{credit} ) %>
+%#
+ |
+% # net tax due
+ = |
+ <% $money_sprintf->( $row->{tax} - $row->{credit} ) %> |
+% # tax collected
+ |
+ <% $money_sprintf->( $row->{tax_paid} ) %> |
+
+% $rownum++;
+% $prev_row = $row;
+% } # foreach my $row
+% # at the end of everything
+
+% if ( $report->{outside} > 0 ) {
+
+
+
+ <% emt('Out of taxable region') %>
+ |
+
+
+ <% $money_sprintf->( $report->{outside } ) %>
+
+ |
+ |
+
+
+% }
+
+
+<& /elements/footer.html &>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
-$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/;
-my $beginning = $1;
+my $DEBUG = $cgi->param('debug') || 0;
-$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/;
-my $ending = $1;
+my $conf = new FS::Conf;
-print header('Tax Report Results');
+my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
-open (REPORT, "freeside-tax-report -v -s $beginning -f $ending $user |");
+my %params = (
+ beginning => $beginning,
+ ending => $ending,
+);
+$params{country} = $cgi->param('country');
+$params{debug} = $DEBUG;
+$params{breakdown} = { map { $_ => 1 } $cgi->param('breakdown') };
-print '';
-while() {
- print $_;
+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;
}
-print '
';
-print '