2bf791aba3762cadb8694c03a79f3f75f80154a2
[freeside.git] / FS / FS / part_event / Condition / pkg_contract_date.pm
1 package FS::part_event::Condition::pkg_contract_date;
2 use base qw( FS::part_event::Condition );
3
4 use strict;
5
6 sub description {
7   'Package contract date nearing';
8 }
9
10 sub eventtable_hashref {
11     { 'cust_main'      => 1,
12       'cust_bill'      => 1,
13       'cust_pkg'       => 1,
14       'cust_pay'       => 1,
15       'cust_pay_batch' => 1,
16       'cust_statement' => 1,
17     };
18 }
19
20 sub option_fields {
21   my $class = shift;
22   (
23     'within'  =>  { 'label'   => 'Package contract date with in',
24                     'type'    => 'freq',
25                   },
26   );
27 }
28
29 sub condition {
30   my( $self, $cust_pkg, %opt ) = @_;
31   
32   my $contract_end_date = $cust_pkg->contract_end ? $cust_pkg->contract_end : 0;
33   my $contract_within_time = $self->option_age_from('within', $contract_end_date );
34
35   $opt{'time'} >= $contract_within_time and $contract_within_time > 0;
36 }
37
38 1;