1 package FS::part_event::Action::pkg_agent_credit;
4 use base qw( FS::part_event::Action::Mixin::credit_flat
5 FS::part_event::Action );
7 sub description { 'Credit the agent a specific amount'; }
9 #a little false laziness w/pkg_referral_credit
11 my( $self, $cust_pkg, $cust_event ) = @_;
13 my $cust_main = $self->cust_main($cust_pkg);
15 my $agent = $cust_main->agent;
16 return "No customer record for agent ". $agent->agent
17 unless $agent->agent_custnum;
19 my $agent_cust_main = $agent->agent_cust_main;
20 #? or return "No customer record for agent ". $agent->agent;
23 my $amount = $self->_calc_credit($cust_pkg, $agent, \$warning);
24 return $warning unless $amount > 0;
26 my $reasonnum = $self->option('reasonnum');
28 my $error = $agent_cust_main->credit(
31 'eventnum' => $cust_event->eventnum,
32 'addlinfo' => 'for customer #'. $cust_main->display_custnum.
33 ': '.$cust_main->name,
34 'commission_agentnum' => $agent->agentnum,
35 'commission_pkgnum' => $cust_pkg->pkgnum,
37 die "Error crediting customer ". $agent_cust_main->custnum.
38 " for agent commission: $error"