summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2016-01-22 16:15:50 -0800
committerMark Wells <mark@freeside.biz>2016-01-22 16:15:50 -0800
commit19ecc46addd9225704aa524126169ec30d353822 (patch)
treea62ba1ebfeb5a2f20761554bc77f8e11df5e2213
parentf75e09ff051137a6b298801b1faae9443c6343a5 (diff)
parentcae584bf375249ab6c1143f5c7cce2776e849e05 (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
-rw-r--r--FS/FS/part_event/Action/pkg_discount.pm34
1 files changed, 26 insertions, 8 deletions
diff --git a/FS/FS/part_event/Action/pkg_discount.pm b/FS/FS/part_event/Action/pkg_discount.pm
index 592e04410..bae3c342a 100644
--- a/FS/FS/part_event/Action/pkg_discount.pm
+++ b/FS/FS/part_event/Action/pkg_discount.pm
@@ -3,10 +3,12 @@ package FS::part_event::Action::pkg_discount;
use strict;
use base qw( FS::part_event::Action );
-sub description { "Discount unsuspended customer packages (monthly recurring only)"; }
+sub description { "Discount unsuspended package(s) (monthly recurring only)"; }
sub eventtable_hashref {
- { 'cust_main' => 1 };
+ { 'cust_main' => 1,
+ 'cust_pkg' => 1,
+ };
}
sub event_stage { 'pre-bill'; }
@@ -42,12 +44,28 @@ sub do_action {
my $cust_main = $self->cust_main($object);
my %if_pkgpart = map { $_=>1 } split(/\s*,\s*/, $self->option('if_pkgpart') );
my $allpkgs = (keys %if_pkgpart) ? 0 : 1;
- my @cust_pkg = grep { ( $allpkgs || $if_pkgpart{ $_->pkgpart } )
- && $_->part_pkg->freq
- #can remove after fixing discount bug with non-monthly pkgs
- && ( $_->part_pkg->freq =~ /^\d+$/) }
- $cust_main->unsuspended_pkgs;
- return 'No qualifying packages' unless @cust_pkg;
+
+ my @cust_pkg = ();
+ if ( $object->table eq 'cust_pkg' ) {
+
+ return 'Package is suspended' if $object->susp;
+ return 'Package not selected'
+ if ! $allpkgs && ! $if_pkgpart{ $object->pkgpart };
+ return 'Package frequency not monthly or a multiple'
+ if $object->part_pkg->freq !~ /^\d+$/;
+
+ @cust_pkg = ( $object );
+
+ } else {
+
+ @cust_pkg = grep { ( $allpkgs || $if_pkgpart{ $_->pkgpart } )
+ && $_->part_pkg->freq
+ #remove after fixing discount bug with non-monthly pkgs
+ && ( $_->part_pkg->freq =~ /^\d+$/) }
+ $cust_main->unsuspended_pkgs;
+ return 'No qualifying packages' unless @cust_pkg;
+
+ }
my $gotit = 0;
foreach my $cust_pkg (@cust_pkg) {