X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FAction%2Fpkg_referral_credit_pkg.pm;h=667c4ce19da15803a376ba00c796db065a8cb9f3;hb=2512fe5818a8d66d404169cbf9b687d3339f750b;hp=eb9b5107c41f88d88a9f1e8ffc45b934a20090a9;hpb=a83a000a027d1272e813259d09230d701d84df64;p=freeside.git diff --git a/FS/FS/part_event/Action/pkg_referral_credit_pkg.pm b/FS/FS/part_event/Action/pkg_referral_credit_pkg.pm index eb9b5107c..667c4ce19 100644 --- a/FS/FS/part_event/Action/pkg_referral_credit_pkg.pm +++ b/FS/FS/part_event/Action/pkg_referral_credit_pkg.pm @@ -1,58 +1,9 @@ package FS::part_event::Action::pkg_referral_credit_pkg; use strict; -use base qw( FS::part_event::Action::pkg_referral_credit ); +use base qw( FS::part_event::Action::Mixin::credit_pkg + FS::part_event::Action::pkg_referral_credit ); sub description { 'Credit the referring customer an amount based on the referred package'; } -#sub eventtable_hashref { -# { 'cust_pkg' => 1 }; -#} - -sub option_fields { - ( - 'reasonnum' => { 'label' => 'Credit reason', - 'type' => 'select-reason', - 'reason_class' => 'R', - }, - 'percent' => { 'label' => 'Percent', - 'type' => 'input-percentage', - 'default' => '100', - }, - 'what' => { 'label' => 'Of', - 'type' => 'select', - #also add some way to specify in the package def, no? - 'options' => [ qw( base_recur_permonth ) ], - 'labels' => { 'base_recur_permonth' => 'Base monthly fee', }, - }, - ); - -} - -sub _calc_referral_credit { - my( $self, $cust_pkg ) = @_; - - my $cust_main = $self->cust_main($cust_pkg); - - my $part_pkg = $cust_pkg->part_pkg; - - my $what = $self->option('what'); - - #false laziness w/Condition/cust_payments_pkg.pm - if ( $what eq 'base_recur_permonth' ) { #huh. yuck. - if ( $part_pkg->freq !~ /^\d+$/ ) { - die 'WARNING: Not crediting customer '. $cust_main->referral_custnum. - ' for package '. $cust_pkg->pkgnum. - ' ( customer '. $cust_pkg->custnum. ')'. - ' - Referral credits not (yet) available for '. - ' packages with '. $part_pkg->freq_pretty. ' frequency'; - } - } - - my $percent = $self->option('percent'); - - sprintf('%.2f', $part_pkg->$what($cust_pkg) * $percent / 100 ); - -} - 1;