add condition on signupdate age, RT#31213
[freeside.git] / FS / FS / part_event / Condition / signupdate_age.pm
1 package FS::part_event::Condition::signupdate_age;
2 use base qw( FS::part_event::Condition );
3
4 use strict;
5
6 sub description { 'Customer signup age'; }
7
8 #lots of falze laziness w/cust_bill_age, basically just swapped out the field
9
10 sub option_fields {
11   (
12     'age' => { label=>'Age', type=>'freq', },
13   );
14 }
15
16 sub condition {
17   my( $self, $cust_bill, %opt ) = @_;
18
19   my $age = $self->option_age_from('age', $opt{'time'} );
20
21   ( $cust_main->signupdate - 60 ) <= $age;
22
23 }
24
25 sub condition_sql {
26   my( $class, $table, %opt ) = @_;
27
28   my $age  = $class->condition_sql_option_age_from('age', $opt{'time'} );
29
30   "( cust_main.signupdate - 60 ) <= $age";
31 }
32
33 # i don't think it really matters what order, since we're a customer condition?
34 #  this is for ordering different events for a customer
35 sub order_sql {
36   shift->condition_sql_option_age('age');
37 }
38
39 sub order_sql_weight {
40   -1;
41 }
42
43 1;
44 1;