From 5cbb1285d26ffe2f7fbf8aed14b5b3d7c037fe83 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Wed, 2 Sep 2015 21:05:28 -0500 Subject: [PATCH] RT#32892: Monthly Sales Tax Report [fixed names and colors] --- FS/FS/Report/Table.pm | 2 +- httemplate/elements/menu.html | 2 ++ httemplate/graph/elements/report.html | 6 ++++-- .../search/{report_tax_sales.cgi => tax_sales.cgi} | 24 +++++++++++++++++----- .../{report_tax_sales.html => tax_sales.html} | 4 ++-- 5 files changed, 28 insertions(+), 10 deletions(-) rename httemplate/search/{report_tax_sales.cgi => tax_sales.cgi} (87%) rename httemplate/search/{report_tax_sales.html => tax_sales.html} (86%) diff --git a/FS/FS/Report/Table.pm b/FS/FS/Report/Table.pm index 4b22b60b8..eeb99bac5 100644 --- a/FS/FS/Report/Table.pm +++ b/FS/FS/Report/Table.pm @@ -753,7 +753,7 @@ sub cust_bill_pkg_taxes { $self->scalar_sql($total_sql); } -#all credits applied to matching pkg line items (ie not taxes or fees) +#all credits applied to matching pkg line items (ie not taxes) sub cust_bill_pkg_credits { my $self = shift; diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 55645cf31..ea6933198 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -381,6 +381,8 @@ if( $curuser->access_right('Financial reports') ) { $report_financial{'Tax Liability (vendor tax data)'} = [ $fsurl.'search/report_newtax.html', 'Tax liability report (vendor tax data)' ] if $taxproducts; + $report_financial{'Monthly Sales and Taxes'} = [$fsurl.'search/tax_sales.html', 'Monthly sales and taxes report']; + # most sites don't need this but there isn't really a config to enable it $report_financial{'E911 Fee Summary'} = [ $fsurl.'search/report_e911.html', 'E911 fee summary' ]; diff --git a/httemplate/graph/elements/report.html b/httemplate/graph/elements/report.html index f1b0d166d..b5d214816 100644 --- a/httemplate/graph/elements/report.html +++ b/httemplate/graph/elements/report.html @@ -11,6 +11,7 @@ Example: #these run parallel to items, and can be given as hashes 'row_labels' => \@row_labels, #required 'colors' => \@colors, #required + 'bgcolors' => \@bgcolors, #optional 'graph_labels' => \@graph_labels, #defaults to row_labels 'links' => \@links, #optional @@ -22,7 +23,7 @@ Example: #optional 'nototal' => 1, - 'graph_type' => 'LinesPoints', + 'graph_type' => 'LinesPoints', #can be 'none' for no graph 'bottom_total' => 1, 'sprintf' => '%u', #sprintf format, overrides default %.2f 'disable_money' => 1, @@ -231,7 +232,8 @@ any delimiter and linked from the elements in @data. % foreach my $row ( @items ) { % #make a style % my $color = shift @{ $opt{'colors'} }; -% push @styles, ".i$i { text-align: right; color: #$color; }"; +% my $bgcolor = $opt{'bgcolors'} ? (shift @{ $opt{'bgcolors'} }) : 'ffffff'; +% push @styles, ".i$i { text-align: right; color: #$color; background: #$bgcolor; }"; % #create the data row % my $links = shift @{$opt{'links'}} || ['']; % my $link_prefix = shift @$links; diff --git a/httemplate/search/report_tax_sales.cgi b/httemplate/search/tax_sales.cgi similarity index 87% rename from httemplate/search/report_tax_sales.cgi rename to httemplate/search/tax_sales.cgi index 5c531c343..4b28c934a 100644 --- a/httemplate/search/report_tax_sales.cgi +++ b/httemplate/search/tax_sales.cgi @@ -1,11 +1,13 @@ <% include('/graph/elements/report.html', - 'title' => 'Monthly Sales Tax Report', - 'items' => \@row_labels, - 'data' => \@rowdata, + 'title' => 'Monthly Sales and Taxes Report', + 'items' => \@row_labels, + 'data' => \@rowdata, 'row_labels' => \@row_labels, - 'colors' => [], + 'colors' => \@rowcolors, + 'bgcolors' => \@rowbgcolors, 'col_labels' => \@col_labels, + 'graph_type' => 'none', ) %> <%init> @@ -139,20 +141,32 @@ while ($countdate < $enddate) { # put the data in the order we want it my @row_labels; my @rowdata; +my @rowcolors; +my @rowbgcolors; +my $pkgcount = 0; #for colors foreach my $classname (@pkg_classname,@taxnames) { + my $istax = ($pkgcount++ < @pkg_classname) ? 0 : 1; my @classlabels = (); my @classdata = (); + my @classcolors = (); + my @classbgcolors = (); my $hasdata = 0; foreach my $item ( qw( invoiced credited ) ) { my $rowlabel = $classname . ' ' . $item; - my $rowdata = $data->{$rowlabel}; + my $rowdata = $data->{$rowlabel}; + my $rowcolor = $istax ? '0000ff' : '000000'; + my $rowbgcolor = ($item eq 'credited') ? 'cccccc' : 'ffffff'; $hasdata = 1 if grep { $_ } @$rowdata; push(@classlabels,$rowlabel); push(@classdata,$rowdata); + push(@classcolors,$rowcolor); + push(@classbgcolors,$rowbgcolor); } next unless $hasdata; # don't include class if it has no data in time range push(@row_labels,@classlabels); push(@rowdata,@classdata); + push(@rowcolors,@classcolors); + push(@rowbgcolors,@classbgcolors); } diff --git a/httemplate/search/report_tax_sales.html b/httemplate/search/tax_sales.html similarity index 86% rename from httemplate/search/report_tax_sales.html rename to httemplate/search/tax_sales.html index 374a15601..61cf86e2e 100755 --- a/httemplate/search/report_tax_sales.html +++ b/httemplate/search/tax_sales.html @@ -1,6 +1,6 @@ -<% include('/elements/header.html', 'Monthly Sales Tax Report' ) %> +<% include('/elements/header.html', 'Monthly Sales and Taxes Report' ) %> -
+ -- 2.11.0