This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / FS / FS / part_event / Condition / cust_bill_age.pm
1 package FS::part_event::Condition::cust_bill_age;
2
3 use strict;
4 use base qw( FS::part_event::Condition );
5
6 sub description { 'Invoice age'; }
7
8 sub eventtable_hashref {
9     { 'cust_main' => 0,
10       'cust_bill' => 1,
11       'cust_pkg'  => 0,
12     };
13 }
14
15 sub option_fields {
16   (
17     'age' => { label=>'Age', type=>'freq', },
18   );
19 }
20
21 sub condition {
22   my( $self, $cust_bill, %opt ) = @_;
23
24   my $age = $self->option_age_from('age', $opt{'time'} );
25
26   ( $cust_bill->_date - 60 ) <= $age;
27
28 }
29
30 sub condition_sql {
31   my( $class, $table, %opt ) = @_;
32
33   my $age  = $class->condition_sql_option_age_from('age', $opt{'time'} );
34
35   "( cust_bill._date - 60 ) <= $age";
36 }
37
38 sub order_sql {
39   shift->condition_sql_option_age('age');
40 }
41
42 sub order_sql_weight {
43   0;
44 }
45
46 1;