import torrus 1.0.9
[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::fee );
5 use Tie::IxHash;
6
7 sub description { 'Late fee (percentage of invoice)'; }
8
9 sub eventtable_hashref {
10   { 'cust_bill' => 1 };
11 }
12
13 sub option_fields {
14   my $class = shift;
15
16   my $t = tie my %option_fields, 'Tie::IxHash', $class->SUPER::option_fields();
17   $t->Shift; #assumes charge is first
18   $t->Unshift( 'percent'  => { label=>'Percent', size=>2, } );
19
20   %option_fields;
21 }
22
23 sub _calc_fee {
24   my( $self, $cust_bill ) = @_;
25   sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 );
26 }
27
28 1;