From: Ivan Kohler Date: Mon, 25 Apr 2016 16:57:16 +0000 (-0700) Subject: add conditions for customer cancelled packages, RT#42043 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=395927e9939742a20f8f5bf8578f6b8f9b6387b4 add conditions for customer cancelled packages, RT#42043 --- diff --git a/FS/FS/part_event/Condition/has_pkg_class_cancelled.pm b/FS/FS/part_event/Condition/has_pkg_class_cancelled.pm new file mode 100644 index 000000000..d6e25a4f7 --- /dev/null +++ b/FS/FS/part_event/Condition/has_pkg_class_cancelled.pm @@ -0,0 +1,43 @@ +package FS::part_event::Condition::has_pkg_class_cancelled; +use base qw( FS::part_event::Condition ); + +use strict; + +sub description { + 'Customer has canceled package with class'; +} + +sub eventtable_hashref { + { 'cust_main' => 1, + 'cust_bill' => 1, + 'cust_pkg' => 1, + }; +} + +#something like this +sub option_fields { + ( + 'pkgclass' => { 'label' => 'Package Class', + 'type' => 'select-pkg_class', + 'multiple' => 1, + }, + 'age' => { 'label' => 'Cacnellation 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'} ); + + #XXX test + my $hashref = $self->option('pkgclass') || {}; + grep { $hashref->{ $_->part_pkg->classnum } && $_->get('cancel') > $age } + $cust_main->cancelled_pkgs; +} + +1;