1 package FS::part_event::Action::referral_pkg_billdate;
4 use base qw( FS::part_event::Action );
6 sub description { "Increment the referring customer's package's next bill date"; }
8 #sub eventtable_hashref {
13 'if_pkgpart' => { 'label' => 'Only packages',
14 'type' => 'select-part_pkg',
17 'increment' => { 'label' => 'Increment by',
24 #false laziness w/referral_pkg_discount, probably should make
25 # Mixin/referral_pkg.pm if we need changes or anything else in this vein
27 my( $self, $cust_object, $cust_event ) = @_;
29 my $cust_main = $self->cust_main($cust_object);
31 return 'No referring customer' unless $cust_main->referral_custnum;
33 my $referring_cust_main = $cust_main->referring_cust_main;
34 #return 'Referring customer is cancelled'
35 # if $referring_cust_main->status eq 'cancelled';
37 my %if_pkgpart = map { $_=>1 } split(/\s*,\s*/, $self->option('if_pkgpart') );
38 my @cust_pkg = grep $if_pkgpart{ $_->pkgpart },
39 $referring_cust_main->billing_pkgs;
40 return 'No qualifying billing package definition' unless @cust_pkg;
42 my $cust_pkg = $cust_pkg[0]; #only one
44 #end of false laziness
46 my $bill = $cust_pkg->bill || $cust_pkg->setup || time;
49 $cust_pkg->part_pkg->add_freq( $bill, $self->option('increment') )
52 my $error = $cust_pkg->replace;
53 die "Error incrementing next bill date: $error" if $error;