X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FCondition%2Fcust_bill_has_service.pm;h=d85af261e9fc1eebff32c4e67226b0b30cb843c8;hb=624b2d44625f69d71175c3348cae635d580c890b;hp=be7ea2b02174a93ada0031edd2f7d06684f53521;hpb=c648976f0b7975f2328ebd7ba8c711fad0ca4195;p=freeside.git diff --git a/FS/FS/part_event/Condition/cust_bill_has_service.pm b/FS/FS/part_event/Condition/cust_bill_has_service.pm index be7ea2b02..d85af261e 100644 --- a/FS/FS/part_event/Condition/cust_bill_has_service.pm +++ b/FS/FS/part_event/Condition/cust_bill_has_service.pm @@ -32,20 +32,22 @@ sub condition { my($self, $cust_bill) = @_; my $servicenum = $self->option('has_service'); - grep { $servicenum == $_->svcnum } + grep { $servicenum == $_->svcpart } map { $_->cust_pkg->cust_svc } $cust_bill->cust_bill_pkg ; } sub condition_sql { - my( $class, $table ) = @_; + my( $class, $table, %opt ) = @_; + + my $integer = $opt{'driver_name'} =~ /^mysql/ ? 'UNSIGNED INTEGER' : 'INTEGER'; my $servicenum = $class->condition_sql_option('has_service'); my $sql = qq| 0 < ( SELECT COUNT(cs.svcpart) FROM cust_bill_pkg cbp, cust_svc cs WHERE cbp.invnum = cust_bill.invnum AND cs.pkgnum = cbp.pkgnum - AND cs.svcpart = $servicenum + AND cs.svcpart = CAST( $servicenum AS $integer ) ) |; return $sql;