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',
25 my( $self, $cust_object, $cust_event ) = @_;
27 my $cust_main = $self->cust_main($cust_object);
29 return 'No referring customer' unless $cust_main->referral_custnum;
31 my $referring_cust_main = $cust_main->referring_cust_main;
32 #return 'Referring customer is cancelled'
33 # if $referring_cust_main->status eq 'cancelled';
35 my %if_pkgpart = map { $_=>1 } split(/\s*,\s*/, $self->option('if_pkgpart') );
36 my @cust_pkg = grep $if_pkgpart{ $_->pkgpart },
37 $referring_cust_main->billing_pkgs;
38 return 'No qualifying billing package definition' unless @cust_pkg;
40 my $cust_pkg = $cust_pkg[0]; #only one
42 my $bill = $cust_pkg->bill || $cust_pkg->setup || time;
45 $cust_pkg->part_pkg->add_freq( $bill, $self->option('increment') )
48 my $error = $cust_pkg->replace;
49 die "Error incrementing next bill date: $error" if $error;