add tax class selection back for late charges w/1.9 events, RT#5665
[freeside.git] / FS / FS / part_event / Action / cust_bill_fee_percent.pm
index 100fc8b..c6f3726 100644 (file)
@@ -3,9 +3,7 @@ package FS::part_event::Action::cust_bill_fee_percent;
 use strict;
 use base qw( FS::part_event::Action );
 
-sub description {
-  'Late fee (percentage of invoice)';
-}
+sub description { 'Late fee (percentage of invoice)'; }
 
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
@@ -13,14 +11,13 @@ sub eventtable_hashref {
 
 sub option_fields {
   ( 
-    'percent' => { label=>'Percent', size=>2, },
-    'reason'  => 'Reason',
+    'percent'  => { label=>'Percent', size=>2, },
+    'reason'   => 'Reason',
+    'taxclass' => { label=>'Tax class', type=>'select-taxclass', },
   );
 }
 
-sub default_weight {
-  10;
-}
+sub default_weight { 10; }
 
 sub do_action {
   my( $self, $cust_bill ) = @_;
@@ -28,10 +25,16 @@ sub do_action {
   #my $cust_main = $self->cust_main($cust_bill);
   my $cust_main = $cust_bill->cust_main;
 
-  my $error = $cust_main->charge(
-    sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 ),
-    $self->option('reason')
-  );
+  my $amount =
+    sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 );
+
+  my $error = $cust_main->charge( {
+    'amount'     => $amount,
+    'pkg'        => $self->option('reason'),
+    'taxclass'   => $self->option('taxclass'),
+    #'start_date' => $cust_main->next_bill_date, #unless its more than N months away?
+  } );
+
   die $error if $error;
 
   '';