summaryrefslogtreecommitdiff
path: root/httemplate/search/sales_pkg_class.html
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-10-16 17:49:20 -0700
committerMark Wells <mark@freeside.biz>2013-10-16 17:49:20 -0700
commit511df0f6b2b42849d3174fa6c8267a9e36191baf (patch)
treef01f0603d968b803189bd6fd31dccb4c2afa88c2 /httemplate/search/sales_pkg_class.html
parent0b52519a5a11bb839b1ef5abe79b97a442bc1909 (diff)
sales commission report improvements, #25256
Diffstat (limited to 'httemplate/search/sales_pkg_class.html')
-rw-r--r--httemplate/search/sales_pkg_class.html27
1 files changed, 19 insertions, 8 deletions
diff --git a/httemplate/search/sales_pkg_class.html b/httemplate/search/sales_pkg_class.html
index da5d512d5..8bb6bde4c 100644
--- a/httemplate/search/sales_pkg_class.html
+++ b/httemplate/search/sales_pkg_class.html
@@ -9,7 +9,7 @@
$sales_sub_maker->('setup'),
$sales_sub_maker->('recur'),
$commission_sub, ],
- 'links' => [ '', '', '', $commission_link ],
+ 'links' => [ '', $sales_link, $sales_link, $commission_link ],
'align' => 'lrrr',
'query' => { 'table' => 'sales_pkg_class',
'hashref' => { 'salesnum' => $salesnum },
@@ -40,6 +40,9 @@ $title .= ': '. time2str($date_format, $beginning). ' to '.
if $beginning;
my $cust_main_sales = $cgi->param('cust_main_sales') eq 'Y' ? 'Y' : '';
+my $paid = $cgi->param('paid') ? 1 : 0;
+
+$title .= " - paid sales only" if $paid;
my $sales_link = [ 'cust_bill_pkg.cgi?'.
"begin=$beginning;".
@@ -55,18 +58,17 @@ my $sales_sub_maker = sub {
my $field = shift;
sub {
my $sales_pkg_class = shift;
-
- #efficiency improvement: ask the db for a sum instead of all the records
- my $total = 0;
- my @cust_bill_pkg = $sales->cust_bill_pkg(
+ # could be even more efficient but this is pretty good
+ my $search = $sales->cust_bill_pkg_search(
$beginning,
$ending,
'cust_main_sales' => $cust_main_sales,
'classnum' => $sales_pkg_class->classnum,
+ 'paid' => $paid,
);
- $total += $_->get($field) foreach @cust_bill_pkg;
-
- $money_char. sprintf('%.2f', $total);
+ $search->{'select'} = "SUM(cust_bill_pkg.$field) AS total";
+ my $result = qsearchs($search);
+ $money_char. sprintf('%.2f', $result ? $result->get('total') : 0);
};
};
@@ -85,6 +87,15 @@ my $commission_sub = sub {
$money_char. sprintf('%.2f', $total_credit);
};
+my $sales_link = [ 'cust_bill_pkg.cgi?'.
+ "begin=$beginning;".
+ "end=$ending;".
+ "cust_main_sales=$cust_main_sales;".
+ "salesnum=$salesnum;".
+ "classnum=",
+ 'classnum'
+ ];
+
my $commission_link = [ 'cust_credit.html?'.
"begin=$beginning;".
"end=$ending;".