diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2016-08-03 23:04:05 -0500 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2016-08-03 23:04:05 -0500 |
commit | c76dee5b859e969a9a1610be53122981f5690687 (patch) | |
tree | a1badbab6e4eee518625828e24cf7aaa307b77e3 /FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm | |
parent | b9f68ca7d2a521b037995d1512067ac19cf6db7b (diff) |
RT#42043: Check for cancelled packages with a cancellation date age option [age_newest options]
Diffstat (limited to 'FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm')
-rw-r--r-- | FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm b/FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm index b4ff6c3..42845cb 100644 --- a/FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm +++ b/FS/FS/part_event/Condition/hasnt_pkgpart_cancelled.pm @@ -18,8 +18,15 @@ sub option_fields { 'type' => 'select-part_pkg', 'multiple' => 1, }, - 'age' => { 'label' => 'Cancellation in last', + 'age_newest' => { 'label' => 'Cancelled more than', 'type' => 'freq', + 'post_text' => ' ago (blank for no limit)', + 'allow_blank' => 1, + }, + 'age' => { 'label' => 'Cancelled less than', + 'type' => 'freq', + 'post_text' => ' ago (blank for no limit)', + 'allow_blank' => 1, }, ); } @@ -29,10 +36,12 @@ sub condition { my $cust_main = $self->cust_main($object); - my $age = $self->option_age_from('age', $opt{'time'} ); + my $oldest = length($self->option('age')) ? $self->option_age_from('age', $opt{'time'} ) : 0; + my $newest = $self->option_age_from('age_newest', $opt{'time'} ); my $if_pkgpart = $self->option('if_pkgpart') || {}; - ! grep { $if_pkgpart->{ $_->pkgpart } && $_->get('cancel') > $age } + + ! grep { $if_pkgpart->{ $_->pkgpart } && ($_->get('cancel') > $oldest) && ($_->get('cancel') <= $newest) } $cust_main->cancelled_pkgs; } |