c700301e23e486cbafb0c61e712b48f256b07a26
[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',
16                     type=>'checkbox', value=>'Y' },
17     'setuptax' => { label=>'Late fee is tax exempt',
18                     type=>'checkbox', value=>'Y' },
19   );
20 }
21
22 sub default_weight { 10; }
23
24 sub do_action {
25   my( $self, $cust_object ) = @_;
26
27   my $cust_main = $self->cust_main($cust_object);
28
29   my %charge = (
30     'amount'   => $self->option('charge'),
31     'pkg'      => $self->option('reason'),
32     'taxclass' => $self->option('taxclass'),
33     'setuptax' => $self->option('setuptax'),
34   );
35
36   $charge{'start_date'} = $cust_main->next_bill_date #unless its more than N months away?
37     if $self->option('nextbill');
38
39   my $error = $cust_main->charge( \%charge );
40
41   die $error if $error;
42
43   '';
44 }
45
46 1;