1 package FS::part_event::Condition::cust_bill_hasnt_noauto;
6 use base qw( FS::part_event::Condition );
9 'Invoice eligible for automatic collection';
12 sub eventtable_hashref {
20 #my($self, $cust_bill, %opt) = @_;
21 my($self, $cust_bill) = @_;
23 ! $cust_bill->no_auto;
27 my( $class, $table, %opt ) = @_;
29 # XXX: can be made faster with optimizations?
30 # -remove some/all sub-selects?
31 # -remove the two main separate selects?
32 # -add indices on cust_pkg.no_auto and part_pkg.no_auto and others?
34 "0 = (select count(1) from cust_pkg
35 where cust_pkg.no_auto = 'Y' and cust_pkg.pkgnum in
36 (select distinct cust_bill_pkg.pkgnum
37 from cust_bill_pkg, cust_pkg
38 where cust_bill_pkg.pkgnum = cust_pkg.pkgnum
39 and cust_bill_pkg.invnum = cust_bill.invnum
40 and cust_bill_pkg.pkgnum > 0
44 0 = (select count(1) from part_pkg
45 where part_pkg.no_auto = 'Y' and part_pkg.pkgpart in
46 (select cust_pkg.pkgpart from cust_pkg
48 (select distinct cust_bill_pkg.pkgnum
49 from cust_bill_pkg, cust_pkg
50 where cust_bill_pkg.pkgnum = cust_pkg.pkgnum
51 and cust_bill_pkg.invnum = cust_bill.invnum
52 and cust_bill_pkg.pkgnum > 0