add pre-bill event stage for late fees, RT#5589
[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 event_stage { 'pre-bill'; }
9
10 sub option_fields {
11   ( 
12     'charge'   => { label=>'Amount', type=>'money', }, # size=>7, },
13     'reason'   => 'Reason',
14     'taxclass' => { label=>'Tax class', type=>'select-taxclass', },
15     'nextbill' => { label=>'Hold late fee until next invoice', type=>'checkbox', value=>'Y' },
16   );
17 }
18
19 sub default_weight { 10; }
20
21 sub do_action {
22   my( $self, $cust_object ) = @_;
23
24   my $cust_main = $self->cust_main($cust_object);
25
26   my %charge = (
27     'amount'   => $self->option('charge'),
28     'pkg'      => $self->option('reason'),
29     'taxclass' => $self->option('taxclass')
30   );
31
32   $charge{'start_date'} = $cust_main->next_bill_date #unless its more than N months away?
33     if $self->option('nextbill');
34
35   my $error = $cust_main->charge( \%charge );
36
37   die $error if $error;
38
39   '';
40 }
41
42 1;