[freeside-commits] branch FREESIDE_4_BRANCH updated. e86b1e9c3887bea0e3b0af13938e45f9f0ebe1e3
Ivan
ivan at 420.am
Fri Jan 22 15:13:31 PST 2016
The branch, FREESIDE_4_BRANCH has been updated
via e86b1e9c3887bea0e3b0af13938e45f9f0ebe1e3 (commit)
from b5ba8c79c7a22cb0ee7d001cc8fe87de527b702e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e86b1e9c3887bea0e3b0af13938e45f9f0ebe1e3
Author: Ivan Kohler <ivan at freeside.biz>
Date: Fri Jan 22 15:13:30 2016 -0800
discount as a package-specific event, RT#39870
diff --git a/FS/FS/part_event/Action/pkg_discount.pm b/FS/FS/part_event/Action/pkg_discount.pm
index 592e044..bae3c34 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) {
-----------------------------------------------------------------------
Summary of changes:
FS/FS/part_event/Action/pkg_discount.pm | 34 +++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
More information about the freeside-commits
mailing list