diff options
author | Mark Wells <mark@freeside.biz> | 2015-07-03 11:38:23 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2015-07-03 15:31:10 -0700 |
commit | 32365ef65ca6a40b5262cf166543b1d84c6aa57d (patch) | |
tree | a052352c992beafb27d09a3cdb94533451335089 /FS | |
parent | 53b6529e6a9c3eb3a314d87e4a405b17af4daf45 (diff) |
make new gross sales calculation optional, #25943
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Report/Table/Monthly.pm | 8 | ||||
-rw-r--r-- | FS/FS/cust_bill/Search.pm | 47 |
2 files changed, 37 insertions, 18 deletions
diff --git a/FS/FS/Report/Table/Monthly.pm b/FS/FS/Report/Table/Monthly.pm index 0ff7efd16..f4ba02008 100644 --- a/FS/FS/Report/Table/Monthly.pm +++ b/FS/FS/Report/Table/Monthly.pm @@ -182,9 +182,15 @@ sub data { push @{$data{label}}, "$smonth/$syear"; # sprintf? my $speriod = timelocal(0,0,0,1,$smonth-1,$syear); - push @{$data{speriod}}, $speriod; if ( ++$smonth == 13 ) { $syear++; $smonth=1; } my $eperiod = timelocal(0,0,0,1,$smonth-1,$syear); + # 12-month mode: show results in a sliding window ending at $eperiod, + # but starting 12 months before. + if ( $self->{'12mo'}) { + $speriod = timelocal(0,0,0,1,$smonth-1,$syear-1); + } + + push @{$data{speriod}}, $speriod; push @{$data{eperiod}}, $eperiod; my $col = 0; # a "column" here is the data corresponding to an item diff --git a/FS/FS/cust_bill/Search.pm b/FS/FS/cust_bill/Search.pm index 62c55d6df..38f11d165 100644 --- a/FS/FS/cust_bill/Search.pm +++ b/FS/FS/cust_bill/Search.pm @@ -7,6 +7,7 @@ use FS::Record qw( qsearchs dbh ); use FS::cust_main; use FS::access_user; use FS::Conf; +use charnames ':full'; =item search HASHREF @@ -18,7 +19,9 @@ following additional parameters valid: =over 4 -=item newest_percust +=item newest_percust - only show the most recent invoice for each customer + +=item invoiced - show the invoiced amount (excluding discounts) instead of gross sales =back @@ -27,7 +30,8 @@ following additional parameters valid: sub search { my( $class, $params ) = @_; - my( $count_query, $count_addl ) = ( '', '' ); + my $count_query = ''; + my @count_addl; #some false laziness w/cust_bill::re_X @@ -77,21 +81,30 @@ sub search { my $money = (FS::Conf->new->config('money_char') || '$') . '%.2f'; - $count_query = 'SELECT COUNT(*), '. join(', ', - map "SUM($_)", - ( 'charged + discounted', - 'discounted', - 'credited', - 'charged - credited', - 'charged - credited - paid', - ) - ); - $count_addl = [ "$money sales (gross)", - "− $money discounted", - "− $money credited", - "= $money sales (net)", + my @sums = ( 'credited', # credits + 'charged - credited', # net sales + 'charged - credited - paid', # balance due + ); + + @count_addl = ( "\N{MINUS SIGN} $money credited", + "= $money net sales", "$money outstanding balance", - ]; + ); + + if ( $params->{'invoiced'} ) { + + unshift @sums, 'charged'; + unshift @count_addl, "$money invoiced"; + + } else { + + unshift @sums, 'charged + discounted', 'discounted'; + unshift @count_addl, "$money gross sales", + "\N{MINUS SIGN} $money discounted"; + + } + + $count_query = 'SELECT COUNT(*), '. join(', ', map "SUM($_)", @sums); } $count_query .= " FROM cust_bill $join $extra_sql"; @@ -115,7 +128,7 @@ sub search { 'order_by' => 'ORDER BY '. ( $params->{'order_by'} || 'cust_bill._date' ), 'count_query' => $count_query, - 'count_addl' => $count_addl, + 'count_addl' => \@count_addl, }; } |