X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Freport_tax.cgi;h=ac76fad6e7ad50c2add0f8cb6a34a41cda96cb97;hb=03ab761a53bffa14d09f23fb8b9702806a1c6b79;hp=bedfdac5feff4995b5c4eb413e506dcaa2e6c0d5;hpb=cefb9727ed4cdfacf3b967485d58b25fbea98c6b;p=freeside.git
diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi
index bedfdac5f..08f255fe4 100755
--- a/httemplate/search/report_tax.cgi
+++ b/httemplate/search/report_tax.cgi
@@ -1,35 +1,199 @@
-<%
+<& /elements/header.html, $report->title &>
+
+Download full results
+as Excel spreadsheet
+ |
-use strict;
-use vars qw( $cgi $user $beginning $ending );
-use CGI;
-use CGI::Carp qw( fatalsToBrowser );
-use FS::UID qw( cgisuidsetup getotaker );
-use FS::CGI qw( header );
+
+<& /elements/table-grid.html &>
+
+
+ |
+ Sales |
+ |
+ Rate |
+ |
+ Estimated tax |
+ Tax invoiced |
+ |
+ Tax credited |
+ |
+ Net tax due |
+
+
+
+ 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
+% $rowlink .= ';pkgclass='.$row->{pkgclass}
+% if $params{breakdown}->{pkgclass};
+%
+% 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
+ − |
+
+
+ <% $money_sprintf->( $row->{credit} ) %>
+
+ |
+% # net tax due
+ = |
+ <% $money_sprintf->( $row->{tax} - $row->{credit} ) %> |
+
+% $rownum++;
+% $prev_row = $row;
+% } # foreach my $row
+
-$cgi = new CGI;
-&cgisuidsetup($cgi);
+<& /elements/footer.html &>
+<%init>
-$user = getotaker;
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
-$cgi->param('beginning') =~ /^([ 0-9\-\/]{0,10})$/;
-$beginning = $1;
+my $DEBUG = $cgi->param('debug') || 0;
-$cgi->param('ending') =~ /^([ 0-9\-\/]{0,10})$/;
-$ending = $1;
+my $conf = new FS::Conf;
-print $cgi->header( '-expires' => '-2m' ),
- header('Tax Report Results');
+my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
-open (REPORT, "/usr/bin/freeside-tax-report -v -s $beginning -d $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 '