summaryrefslogtreecommitdiff
path: root/FS/FS/part_event/Condition/pkg_contract_date.pm
blob: 9cb75f60d73982bb8eeea74e4dfd64e9ab14fc75 (plain)
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
package FS::part_event::Condition::pkg_contract_date;
use base qw( FS::part_event::Condition );

use strict;

sub description {
  'Package contract date nearing';
}

sub eventtable_hashref {
    {
      'cust_pkg'       => 1,
    };
}

sub option_fields {
  my $class = shift;
  (
    'within'  =>  { 'label'   => 'Package contract date with in',
                    'type'    => 'freq',
                  },
  );
}

sub condition {
  my( $self, $cust_pkg, %opt ) = @_;
  
  my $contract_end_date = $cust_pkg->contract_end ? $cust_pkg->contract_end : 0;
  my $contract_within_time = $self->option_age_from('within', $contract_end_date );

  $opt{'time'} >= $contract_within_time and $contract_within_time > 0;
}

1;