optimize declined payment event condition, RT#81305
[freeside.git] / FS / FS / part_event / Condition / cust_pay_batch_declined.pm
1 package FS::part_event::Condition::cust_pay_batch_declined;
2
3 use strict;
4
5 use base qw( FS::part_event::Condition );
6
7 sub description {
8   'Batch payment declined';
9 }
10
11 sub eventtable_hashref {
12     { 'cust_main'      => 0,
13       'cust_bill'      => 0,
14       'cust_pkg'       => 0,
15       'cust_pay_batch' => 1,
16     };
17 }
18
19 sub condition {
20   my($self, $cust_pay_batch, %opt) = @_;
21
22   $cust_pay_batch->status =~ /Declined/i;
23 }
24
25 sub condition_sql {
26   my( $class, $table ) = @_;
27
28   "(cust_pay_batch.status IS NOT NULL AND cust_pay_batch.status = 'Declined')";
29 }
30
31 1;