From: ivan Date: Tue, 30 Mar 2010 02:52:46 +0000 (+0000) Subject: employee commissions, RT#6991 X-Git-Tag: root_of_svc_elec_features~344 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=2848f5b5675c28051c3ddbc9b9fb302423a43ca4 employee commissions, RT#6991 --- diff --git a/FS/FS/part_event/Action/pkg_employee_credit.pm b/FS/FS/part_event/Action/pkg_employee_credit.pm new file mode 100644 index 000000000..28fd0256a --- /dev/null +++ b/FS/FS/part_event/Action/pkg_employee_credit.pm @@ -0,0 +1,38 @@ +package FS::part_event::Action::pkg_employee_credit; + +use strict; +use base qw( FS::part_event::Action::pkg_referral_credit ); + +sub description { 'Credit the ordering employee a specific amount'; } + +#a little false laziness w/pkg_referral_credit +sub do_action { + my( $self, $cust_pkg ) = @_; + + my $cust_main = $self->cust_main($cust_pkg); + + my $employee = $cust_pkg->access_user; + return "No customer record for employee ". $employee->username + unless $employee->user_custnum; + + my $employee_cust_main = $employee->user_cust_main; + #? or return "No customer record for employee ". $employee->username; + + my $amount = $self->_calc_credit($cust_pkg); + return '' unless $amount > 0; + + my $reasonnum = $self->option('reasonnum'); + + my $error = $employee_cust_main->credit( + $amount, + \$reasonnum, + 'addlinfo' => + 'for customer #'. $cust_main->display_custnum. ': '.$cust_main->name, + ); + die "Error crediting customer ". $employee_cust_main->custnum. + " for employee commission: $error" + if $error; + +} + +1;