event refactor, landing on HEAD!
[freeside.git] / FS / FS / part_event / Action / cust_bill_fee_percent.pm
1 package FS::part_event::Action::cust_bill_fee_percent;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description {
7   'Late fee (percentage of invoice)';
8 }
9
10 sub eventtable_hashref {
11   { 'cust_bill' => 1 };
12 }
13
14 sub option_fields {
15   ( 
16     'percent' => { label=>'Percent', size=>2, },
17     'reason'  => 'Reason',
18   );
19 }
20
21 sub default_weight {
22   10;
23 }
24
25 sub do_action {
26   my( $self, $cust_bill ) = @_;
27
28   #my $cust_main = $self->cust_main($cust_bill);
29   my $cust_main = $cust_bill->cust_main;
30
31   my $error = $cust_main->charge(
32     sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 ),
33     $self->option('reason')
34   );
35   die $error if $error;
36
37   '';
38 }
39
40 1;