1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package FS::part_event::Condition::pkg_age;
use strict;
use base qw( FS::part_event::Condition );
use FS::Record qw( qsearch );
sub description {
'Package Age';
}
sub eventtable_hashref {
{ 'cust_main' => 0,
'cust_bill' => 0,
'cust_pkg' => 1,
};
}
#something like this
sub option_fields {
(
'age' => { 'label' => 'Package date age',
'type' => 'freq',
},
'field' => { 'label' => 'Compare date',
'type' => 'select',
'options' =>
[qw( setup last_bill bill adjourn susp expire cancel )],
'labels' => {
'setup' => 'Setup date',
'last_bill' => 'Last bill date',
'bill' => 'Next bill date',
'adjourn' => 'Adjournment date',
'susp' => 'Suspension date',
'expire' => 'Expiration date',
'cancel' => 'Cancellation date',
},
},
);
}
sub condition {
my( $self, $cust_pkg, %opt ) = @_;
my $age = $self->option_age_from('age', $opt{'time'} );
my $pkg_date = $cust_pkg->get( $self->option('field') );
$pkg_date && $pkg_date <= $age;
}
#XXX write me for efficiency
#sub condition_sql {
#
#}
1;
|