RT# 75595 - made it only available for cust_pkg
[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     {
12       'cust_pkg'       => 1,
13     };
14 }
15
16 sub option_fields {
17   my $class = shift;
18   (
19     'within'  =>  { 'label'   => 'Package contract date with in',
20                     'type'    => 'freq',
21                   },
22   );
23 }
24
25 sub condition {
26   my( $self, $cust_pkg, %opt ) = @_;
27   
28   my $contract_end_date = $cust_pkg->contract_end ? $cust_pkg->contract_end : 0;
29   my $contract_within_time = $self->option_age_from('within', $contract_end_date );
30
31   $opt{'time'} >= $contract_within_time and $contract_within_time > 0;
32 }
33
34 1;