event refactor, landing on HEAD!
[freeside.git] / FS / FS / part_event / Condition / cust_bill_owed.pm
1 package FS::part_event::Condition::cust_bill_owed;
2
3 use strict;
4 use FS::cust_bill;
5
6 use base qw( FS::part_event::Condition );
7
8 sub description {
9   'Amount owed on specific invoice';
10 }
11
12 sub eventtable_hashref {
13     { 'cust_main' => 0,
14       'cust_bill' => 1,
15       'cust_pkg'  => 0,
16     };
17 }
18
19 sub option_fields {
20   (
21     'owed' => { 'label'      => 'Amount owed over',
22                 'type'       => 'money',
23                 'value'      => '0.00', #default
24               },
25   );
26 }
27
28 sub condition {
29   #my($self, $cust_bill, %opt) = @_;
30   my($self, $cust_bill) = @_;
31
32   my $over = $self->option('owed');
33   $over = 0 unless length($over);
34
35   $cust_bill->owed > $over;
36 }
37
38 sub condition_sql {
39   my( $class, $table ) = @_;
40   
41   my $over = $class->condition_sql_option('owed');
42
43   my $owed_sql = FS::cust_bill->owed_sql;
44
45   "$owed_sql > $over";
46 }
47
48 1;