X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2Fpart_event%2FAction%2Fpkg_referral_credit.pm;h=e7c92d6501aa3671175fa4735545b4cbc81991f3;hb=dd2249efe0daa3fc3257029de84d212aa89a4ee9;hp=98d982066020e42af75a83b637035d50bd4cd342;hpb=097a12385d80ef52f37d4cc2bb93bc3f81e6f8e6;p=freeside.git diff --git a/FS/FS/part_event/Action/pkg_referral_credit.pm b/FS/FS/part_event/Action/pkg_referral_credit.pm index 98d982066..e7c92d650 100644 --- a/FS/FS/part_event/Action/pkg_referral_credit.pm +++ b/FS/FS/part_event/Action/pkg_referral_credit.pm @@ -22,9 +22,8 @@ sub option_fields { } -#a little false laziness w/pkg_referral_credit_pkg sub do_action { - my( $self, $cust_pkg ) = @_; + my( $self, $cust_pkg, $cust_event ) = @_; my $cust_main = $self->cust_main($cust_pkg); @@ -36,14 +35,17 @@ sub do_action { return 'Referring customer is cancelled' if $referring_cust_main->status eq 'cancelled'; - my $amount = $self->_calc_referral_credit($cust_pkg); + my $amount = $self->_calc_credit($cust_pkg); + return '' unless $amount > 0; + my $reasonnum = $self->option('reasonnum'); my $error = $referring_cust_main->credit( $amount, \$reasonnum, - 'addlinfo' => - 'for customer #'. $cust_main->display_custnum. ': '.$cust_main->name, + 'eventnum' => $cust_event->eventnum, + 'addlinfo' => 'for customer #'. $cust_main->display_custnum. + ': '.$cust_main->name, ); die "Error crediting customer ". $cust_main->referral_custnum. " for referral: $error" @@ -51,7 +53,7 @@ sub do_action { } -sub _calc_referral_credit { +sub _calc_credit { my( $self, $cust_pkg ) = @_; $self->option('amount');