570fd63165c1322bc9583b70526f3a4c28e6fe03
[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 { 'Late fee (percentage of invoice)'; }
7
8 sub eventtable_hashref {
9   { 'cust_bill' => 1 };
10 }
11
12 sub option_fields {
13   ( 
14     'percent' => { label=>'Percent', size=>2, },
15     'reason'  => 'Reason',
16   );
17 }
18
19 sub default_weight { 10; }
20
21 sub do_action {
22   my( $self, $cust_bill ) = @_;
23
24   #my $cust_main = $self->cust_main($cust_bill);
25   my $cust_main = $cust_bill->cust_main;
26
27   my $error = $cust_main->charge(
28     sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 ),
29     $self->option('reason')
30   );
31   die $error if $error;
32
33   '';
34 }
35
36 1;