1 package FS::part_event::Action::pkg_referral_credit;
4 use base qw( FS::part_event::Action::Mixin::credit_flat
5 FS::part_event::Action );
7 sub description { 'Credit the referring customer a specific amount'; }
9 sub eventtable_hashref {
14 my( $self, $cust_pkg, $cust_event ) = @_;
16 my $cust_main = $self->cust_main($cust_pkg);
18 # my $part_pkg = $cust_pkg->part_pkg;
20 return 'No referring customer' unless $cust_main->referral_custnum;
22 my $referring_cust_main = $cust_main->referring_cust_main;
23 return 'Referring customer is cancelled'
24 if $referring_cust_main->status eq 'cancelled';
27 my $amount = $self->_calc_credit($cust_pkg, $referring_cust_main, \$warning);
28 return $warning unless $amount > 0;
30 my $reasonnum = $self->option('reasonnum');
32 my $error = $referring_cust_main->credit(
35 'eventnum' => $cust_event->eventnum,
36 'addlinfo' => 'for customer #'. $cust_main->display_custnum.
37 ': '.$cust_main->name,
39 die "Error crediting customer ". $cust_main->referral_custnum.
40 " for referral: $error"