X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FCondition%2Finactive_age.pm;h=562e101758a373140723ff86eabce74530ce77d9;hp=cbf4b9e0aa84bf06bbaa1e52ce1530295f434868;hb=2322f0123062b8cf2f52aed0a63bb4634cdbaef1;hpb=a0f5ae295297e1b17ab89640346fc06cfb1e5892 diff --git a/FS/FS/part_event/Condition/inactive_age.pm b/FS/FS/part_event/Condition/inactive_age.pm index cbf4b9e0a..562e10175 100644 --- a/FS/FS/part_event/Condition/inactive_age.pm +++ b/FS/FS/part_event/Condition/inactive_age.pm @@ -57,20 +57,24 @@ sub condition_sql { # will evaluate to zero if there isn't one my @sql; for my $t (qw(cust_pay cust_credit cust_refund)) { - push @sql, - "NOT EXISTS( SELECT 1 FROM $t ". - "WHERE $t.custnum = cust_main.custnum AND $t._date >= $age". - ")"; + push @sql, " + NOT EXISTS( SELECT 1 FROM $t + WHERE $t.custnum = cust_main.custnum AND $t._date >= $age + LIMIT 1 + ) + "; } #cust_bill - push @sql, - "NOT EXISTS( ". - "SELECT 1 FROM cust_bill JOIN cust_bill_pkg USING (invnum) ". - "JOIN cust_pkg USING (pkgnum) JOIN part_pkg USING (pkgpart) ". - "WHERE cust_bill.custnum = cust_main.custnum ". - "AND cust_bill._date >= $age ". - "AND COALESCE(part_pkg.classnum, -1) != $ignore_pkgclass ". - ")"; + push @sql, " + NOT EXISTS( + SELECT 1 FROM cust_bill JOIN cust_bill_pkg USING (invnum) + JOIN cust_pkg USING (pkgnum) JOIN part_pkg USING (pkgpart) + WHERE cust_bill.custnum = cust_main.custnum + AND cust_bill._date >= $age + AND COALESCE(part_pkg.classnum, -1) != $ignore_pkgclass + LIMIT 1 + ) + "; join(' AND ', @sql); }