From 86b44a7897af8265bcd87603fbf2632489ca10b8 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Mon, 20 Jul 2015 19:24:48 -0500 Subject: [PATCH 1/1] RT#37125: Include discounts in report: customer accounting summary [some fixes] --- FS/FS/Report/Table.pm | 20 +++++++++++++++----- .../search/report_customer_accounting_summary.html | 9 ++++++--- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/FS/FS/Report/Table.pm b/FS/FS/Report/Table.pm index ffa117240..63e5318c3 100644 --- a/FS/FS/Report/Table.pm +++ b/FS/FS/Report/Table.pm @@ -229,7 +229,8 @@ sub receipts { #net payments my $sql = 'SELECT SUM(cust_bill_pay.amount) FROM cust_bill_pay'; if ( $opt{'setuprecur'} ) { $sql = 'SELECT SUM('. - FS::cust_bill_pkg->paid_sql($speriod, $eperiod, %opt). + #in practice, but not appearance, paid_sql accepts end before start + FS::cust_bill_pkg->paid_sql($eperiod, $speriod, %opt). ') FROM cust_bill_pkg'; } @@ -275,6 +276,11 @@ sub discounted { my $sql = 'SELECT SUM('; if ($opt{'setuprecur'}) { + # (This isn't exact but it works in most cases.) + # When splitting into setup/recur values, + # if the discount is allowed to apply to setup fees (discount.setup = 'Y') + # then split it between the "setup" and "recurring" rows in proportion to + # the "unitsetup" and "unitrecur" fields of the line item. $sql .= < <& /elements/tr-checkbox.html, - 'label' => 'Show Gross & Discounted', - 'field' => 'grossdiscount', - 'value' => 1, + 'label' => 'Show Gross & Discounted', + 'field' => 'grossdiscount', + 'value' => 1, + 'curr_value' => defined($cgi->param('grossdiscount')) + ? scalar($cgi->param('grossdiscount')) + : 1, #default to on in v4 &> -- 2.11.0