X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2Fpart_event%2FAction%2Fcust_bill_fee_percent.pm;h=48daf15e3479a490d891892ac7e09f17cda21141;hb=74e058c8a010ef6feb539248a550d0bb169c1e94;hp=c85339398b71eb52850118ac393935df07b6d54c;hpb=5470df9cd0062a366aaf8ff7d1e66cf6fac60311;p=freeside.git diff --git a/FS/FS/part_event/Action/cust_bill_fee_percent.pm b/FS/FS/part_event/Action/cust_bill_fee_percent.pm index c85339398..48daf15e3 100644 --- a/FS/FS/part_event/Action/cust_bill_fee_percent.pm +++ b/FS/FS/part_event/Action/cust_bill_fee_percent.pm @@ -1,7 +1,8 @@ package FS::part_event::Action::cust_bill_fee_percent; use strict; -use base qw( FS::part_event::Action ); +use base qw( FS::part_event::Action::fee ); +use Tie::IxHash; sub description { 'Late fee (percentage of invoice)'; } @@ -9,46 +10,19 @@ sub eventtable_hashref { { 'cust_bill' => 1 }; } -sub event_stage { 'pre-bill'; } - sub option_fields { - ( - 'percent' => { label=>'Percent', size=>2, }, - 'reason' => 'Reason', - 'taxclass' => { label=>'Tax class', type=>'select-taxclass', }, - 'nextbill' => { label=>'Hold late fee until next invoice', - type=>'checkbox', value=>'Y' }, - 'setuptax' => { label=>'Late fee is tax exempt', - type=>'checkbox', value=>'Y' }, - ); -} - -sub default_weight { 10; } - -sub do_action { - my( $self, $cust_bill ) = @_; - - #my $cust_main = $self->cust_main($cust_bill); - my $cust_main = $cust_bill->cust_main; + my $class = shift; - my $amount = - sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 ); + my $t = tie my %option_fields, 'Tie::IxHash', $class->SUPER::option_fields(); + $t->Shift; #assumes charge is first + $t->Unshift( 'percent' => { label=>'Percent', size=>2, } ); - my %charge = ( - 'amount' => $amount, - 'pkg' => $self->option('reason'), - 'taxclass' => $self->option('taxclass'), - 'setuptax' => $self->option('setuptax'), - ); - - $charge{'start_date'} = $cust_main->next_bill_date #unless its more than N months away? - if $self->option('nextbill'); - - my $error = $cust_main->charge( \%charge ); - - die $error if $error; + %option_fields; +} - ''; +sub _calc_fee { + my( $self, $cust_bill ) = @_; + sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 ); } 1;