X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FAction%2Ffee.pm;h=68288d090f7495c2a184754862240a2b92b034e3;hp=81a84498a147eb41e4bf2fd1ffc8a6d2e6d6e9dd;hb=74e058c8a010ef6feb539248a550d0bb169c1e94;hpb=c648976f0b7975f2328ebd7ba8c711fad0ca4195 diff --git a/FS/FS/part_event/Action/fee.pm b/FS/FS/part_event/Action/fee.pm index 81a84498a..68288d090 100644 --- a/FS/FS/part_event/Action/fee.pm +++ b/FS/FS/part_event/Action/fee.pm @@ -3,19 +3,29 @@ package FS::part_event::Action::fee; use strict; use base qw( FS::part_event::Action ); -sub description { - 'Late fee (flat)'; -} +sub description { 'Late fee (flat)'; } + +sub event_stage { 'pre-bill'; } sub option_fields { ( - 'charge' => { label=>'Amount', type=>'money', }, # size=>7, }, - 'reason' => 'Reason', + 'charge' => { label=>'Amount', type=>'money', }, # size=>7, }, + 'reason' => 'Reason (invoice line item)', + 'classnum' => { label=>'Package class' => type=>'select-pkg_class', }, + 'taxclass' => { label=>'Tax class', type=>'select-taxclass', }, + 'setuptax' => { label=>'Late fee is tax exempt', + type=>'checkbox', value=>'Y' }, + 'nextbill' => { label=>'Hold late fee until next invoice', + type=>'checkbox', value=>'Y' }, ); -}; +} + +sub default_weight { 10; } -sub default_weight { - 10; +sub _calc_fee { + #my( $self, $cust_object ) = @_; + my $self = shift; + $self->option('charge'); } sub do_action { @@ -23,7 +33,22 @@ sub do_action { my $cust_main = $self->cust_main($cust_object); - my $error = $cust_main->charge( $self->option('charge'), $self->option('reason') ); + my $conf = new FS::Conf; + + my %charge = ( + 'amount' => $self->_calc_fee($cust_object), + 'pkg' => $self->option('reason'), + 'taxclass' => $self->option('taxclass'), + 'classnum' => ( $self->option('classnum') + || scalar($conf->config('finance_pkgclass')) ), + 'setuptax' => $self->option('setuptax'), + ); + + #unless its more than N months away? + $charge{'start_date'} = $cust_main->next_bill_date + if $self->option('nextbill'); + + my $error = $cust_main->charge( \%charge ); die $error if $error;