From cc4caa54e9974ea3d6ac7cf55cf45863d2a8905e Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 25 Apr 2016 09:58:11 -0700 Subject: [PATCH 1/1] add conditions for customer cancelled packages, RT#42043 --- .../part_event/Condition/has_pkgpart_cancelled.pm | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 FS/FS/part_event/Condition/has_pkgpart_cancelled.pm diff --git a/FS/FS/part_event/Condition/has_pkgpart_cancelled.pm b/FS/FS/part_event/Condition/has_pkgpart_cancelled.pm new file mode 100644 index 000000000..7e2a5671c --- /dev/null +++ b/FS/FS/part_event/Condition/has_pkgpart_cancelled.pm @@ -0,0 +1,45 @@ +package FS::part_event::Condition::has_pkgpart_cancelled; +use base qw( FS::part_event::Condition ); + +use strict; + +sub description { 'Customer has canceled specific package(s)'; } + +sub eventtable_hashref { + { 'cust_main' => 1, + 'cust_bill' => 1, + 'cust_pkg' => 1, + }; +} + +sub option_fields { + ( + 'if_pkgpart' => { 'label' => 'Only packages: ', + 'type' => 'select-part_pkg', + 'multiple' => 1, + }, + 'age' => { 'label' => 'Cancellation in last', + 'type' => 'freq', + }, + ); +} + +sub condition { + my( $self, $object, %opt ) = @_; + + my $cust_main = $self->cust_main($object); + + my $age = $self->option_age_from('age', $opt{'time'} ); + + my $if_pkgpart = $self->option('if_pkgpart') || {}; + grep { $if_pkgpart->{ $_->pkgpart } && $_->get('cancel') > $age } + $cust_main->cancelled_pkgs; + +} + +#XXX +#sub condition_sql { +# +#} + +1; -- 2.11.0