projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
a582fcf
)
optimize
author
Ivan Kohler
<ivan@freeside.biz>
Thu, 20 Nov 2014 19:48:06 +0000
(11:48 -0800)
committer
Ivan Kohler
<ivan@freeside.biz>
Thu, 20 Nov 2014 19:48:06 +0000
(11:48 -0800)
FS/FS/cust_main/Billing_Discount.pm
patch
|
blob
|
history
diff --git
a/FS/FS/cust_main/Billing_Discount.pm
b/FS/FS/cust_main/Billing_Discount.pm
index
9dda389
..
d437740
100644
(file)
--- a/
FS/FS/cust_main/Billing_Discount.pm
+++ b/
FS/FS/cust_main/Billing_Discount.pm
@@
-42,11
+42,13
@@
sub _discount_pkgs_and_bill {
push @where, "part_pkg.freq = '1'";
push @where, "(cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0)";
push @where, "(cust_pkg.susp IS NULL OR cust_pkg.susp = 0)";
push @where, "part_pkg.freq = '1'";
push @where, "(cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0)";
push @where, "(cust_pkg.susp IS NULL OR cust_pkg.susp = 0)";
- push @where, "
0<(SELECT count(*)
FROM part_pkg_discount
-
WHERE part_pkg.pkgpart = part_pkg_discount.pkgpart
)";
+ push @where, "
EXISTS( SELECT 1
FROM part_pkg_discount
+
WHERE part_pkg.pkgpart = part_pkg_discount.pkgpart
)";
push @where,
push @where,
- "0=(SELECT count(*) FROM cust_bill_pkg_discount
- WHERE cust_bill_pkg.billpkgnum = cust_bill_pkg_discount.billpkgnum)";
+ "NOT EXISTS (
+ SELECT 1 FROM cust_bill_pkg_discount
+ WHERE cust_bill_pkg.billpkgnum = cust_bill_pkg_discount.billpkgnu:
+ )";
my $extra_sql = 'WHERE '. join(' AND ', @where);
my $extra_sql = 'WHERE '. join(' AND ', @where);