summaryrefslogtreecommitdiff
path: root/FS/bin
diff options
context:
space:
mode:
authorivan <ivan>2005-07-08 23:06:31 +0000
committerivan <ivan>2005-07-08 23:06:31 +0000
commitff0258d05484670831222da23427606f719cc009 (patch)
treea82a2efe0e8ab980a8b67fe458529edb31911dfc /FS/bin
parentb68d9424e966cc1e5c9eb384c0a4a0cdd25fdb8e (diff)
fix bug with new efficient customer-finding code. sql isn't perl, null != 0
Diffstat (limited to 'FS/bin')
-rwxr-xr-xFS/bin/freeside-daily16
1 files changed, 11 insertions, 5 deletions
diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
index 702d749..589af89 100755
--- a/FS/bin/freeside-daily
+++ b/FS/bin/freeside-daily
@@ -43,10 +43,16 @@ my $where_bill_event = <<"END";
0 < ( select count(*) from cust_bill
where cust_main.custnum = cust_bill.custnum
and 0 < charged
- - ( select sum(amount) from cust_bill_pay
- where cust_bill.invnum = cust_bill_pay.invnum )
- - ( select sum(amount) from cust_credit_bill
- where cust_bill.invnum = cust_credit_bill.invnum )
+ - coalesce(
+ ( select sum(amount) from cust_bill_pay
+ where cust_bill.invnum = cust_bill_pay.invnum )
+ ,0
+ )
+ - coalesce(
+ ( select sum(amount) from cust_credit_bill
+ where cust_bill.invnum = cust_credit_bill.invnum )
+ ,0
+ )
and 0 < ( select count(*) from part_bill_event
where payby = cust_main.payby
and ( disabled is null or disabled = '' )
@@ -61,7 +67,7 @@ my $where_bill_event = <<"END";
)
END
-my $extra_sql = ( scalar(%search) ? ' AND ' : ' WHERE ' ). "$where_pkg OR $where_bill_event";
+my $extra_sql = ( scalar(%search) ? ' AND ' : ' WHERE ' ). "( $where_pkg OR $where_bill_event )";
my @cust_main;
if ( @ARGV ) {