fix late fees, RT#5665
[freeside.git] / FS / FS / part_event / Action / fee.pm
1 package FS::part_event::Action::fee;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description { 'Late fee (flat)'; }
7
8 sub option_fields {
9   ( 
10     'charge'   => { label=>'Amount', type=>'money', }, # size=>7, },
11     'reason'   => 'Reason',
12     'taxclass' => { label=>'Tax class', type=>'select-taxclass', },
13     'nextbill' => { label=>'Hold late fee until next invoice', type=>'checkbox', value=>'Y' },
14   );
15 }
16
17 sub default_weight { 10; }
18
19 sub do_action {
20   my( $self, $cust_object ) = @_;
21
22   my $cust_main = $self->cust_main($cust_object);
23
24   my %charge = (
25     'amount'   => $self->option('charge'),
26     'pkg'      => $self->option('reason'),
27     'taxclass' => $self->option('taxclass')
28   );
29
30   $charge{'start_date'} = $cust_main->next_bill_date #unless its more than N months away?
31     if $self->option('nextbill');
32
33   my $error = $cust_main->charge( \%charge );
34
35   die $error if $error;
36
37   '';
38 }
39
40 1;