fix per-package class agent commission percentages, RT#23066
[freeside.git] / FS / FS / part_event / Action / Mixin / credit_agent_pkg_class.pm
1 package FS::part_event::Action::Mixin::credit_agent_pkg_class;
2 use base qw( FS::part_event::Action::Mixin::credit_pkg );
3
4 use strict;
5 use FS::Record qw(qsearchs);
6
7 sub option_fields {
8   my $class = shift;
9   my %option_fields = $class->SUPER::option_fields;
10   delete $option_fields{'percent'};
11   %option_fields;
12 }
13
14 sub _calc_credit_percent {
15   my( $self, $cust_pkg ) = @_;
16
17   my $agent_pkg_class = qsearchs( 'agent_pkg_class', {
18     'agentnum' => $self->cust_main($cust_pkg)->agentnum,
19     'classnum' => $cust_pkg->part_pkg->classnum,
20   });
21
22   $agent_pkg_class ? $agent_pkg_class->commission_percent : 0;
23
24 }
25
26 1;