1 package FS::part_event::Action::fee;
4 use base qw( FS::part_event::Action );
6 sub description { 'Late fee (flat)'; }
8 sub event_stage { 'pre-bill'; }
12 'charge' => { label=>'Amount', type=>'money', }, # size=>7, },
13 'reason' => 'Reason (invoice line item)',
14 'classnum' => { label=>'Package class' => type=>'select-pkg_class', },
15 'taxclass' => { label=>'Tax class', type=>'select-taxclass', },
16 'setuptax' => { label=>'Late fee is tax exempt',
17 type=>'checkbox', value=>'Y' },
18 'nextbill' => { label=>'Hold late fee until next invoice',
19 type=>'checkbox', value=>'Y' },
21 { label=>"Charge no more than the customer's credit balance",
22 type=>'checkbox', value=>'Y' },
26 sub default_weight { 10; }
29 my( $self, $cust_object ) = @_;
30 if ( $self->option('limit_to_credit') ) {
31 my $balance = $cust_object->cust_main->balance;
32 if ( $balance >= 0 ) {
34 } elsif ( (-1 * $balance) < $self->option('charge') ) {
39 $self->option('charge');
43 my( $self, $cust_object ) = @_;
45 my $cust_main = $self->cust_main($cust_object);
47 my $conf = new FS::Conf;
50 'amount' => $self->_calc_fee($cust_object),
51 'pkg' => $self->option('reason'),
52 'taxclass' => $self->option('taxclass'),
53 'classnum' => ( $self->option('classnum')
54 || scalar($conf->config('finance_pkgclass')) ),
55 'setuptax' => $self->option('setuptax'),
58 # amazingly, FS::cust_main::charge will allow a charge of zero
59 return '' if $charge{'amount'} == 0;
61 #unless its more than N months away?
62 $charge{'start_date'} = $cust_main->next_bill_date
63 if $self->option('nextbill');
65 my $error = $cust_main->charge( \%charge );