fix late fees, RT#5665
authorivan <ivan>
Thu, 2 Jul 2009 02:02:46 +0000 (02:02 +0000)
committerivan <ivan>
Thu, 2 Jul 2009 02:02:46 +0000 (02:02 +0000)
FS/FS/cust_main.pm
FS/FS/part_event/Action/cust_bill_fee_percent.pm
FS/FS/part_event/Action/fee.pm

index 1e43519..a1b8912 100644 (file)
@@ -6790,7 +6790,7 @@ sub charge {
     $setuptax   = exists($_[0]->{setuptax}) ? $_[0]->{setuptax} : '';
     $taxclass   = exists($_[0]->{taxclass}) ? $_[0]->{taxclass} : '';
     $classnum   = exists($_[0]->{classnum}) ? $_[0]->{classnum} : '';
-    $additional = $_[0]->{additional};
+    $additional = $_[0]->{additional} || [];
     $taxproduct = $_[0]->{taxproductnum};
     $override   = { '' => $_[0]->{tax_override} };
   } else {
index c6f3726..354778f 100644 (file)
@@ -14,6 +14,7 @@ sub option_fields {
     'percent'  => { label=>'Percent', size=>2, },
     'reason'   => 'Reason',
     'taxclass' => { label=>'Tax class', type=>'select-taxclass', },
+    'nextbill' => { label=>'Hold late fee until next invoice', type=>'checkbox', value=>'Y' },
   );
 }
 
@@ -28,12 +29,16 @@ sub do_action {
   my $amount =
     sprintf('%.2f', $cust_bill->owed * $self->option('percent') / 100 );
 
-  my $error = $cust_main->charge( {
+  my %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?
-  } );
+  );
+
+  $charge{'start_date'} = $cust_main->next_bill_date #unless its more than N months away?
+    if $self->option('nextbill');
+
+  my $error = $cust_main->charge( \%charge );
 
   die $error if $error;
 
index 7d07df5..6ea7103 100644 (file)
@@ -10,6 +10,7 @@ sub option_fields {
     'charge'   => { label=>'Amount', type=>'money', }, # size=>7, },
     'reason'   => 'Reason',
     'taxclass' => { label=>'Tax class', type=>'select-taxclass', },
+    'nextbill' => { label=>'Hold late fee until next invoice', type=>'checkbox', value=>'Y' },
   );
 }
 
@@ -20,12 +21,16 @@ sub do_action {
 
   my $cust_main = $self->cust_main($cust_object);
 
-  my $error = $cust_main->charge( {
+  my %charge = (
     'amount'   => $self->option('charge'),
     'pkg'      => $self->option('reason'),
     'taxclass' => $self->option('taxclass')
-    #'start_date' => $cust_main->next_bill_date, #unless its more than N months away?
-  } );
+  );
+
+  $charge{'start_date'} = $cust_main->next_bill_date #unless its more than N months away?
+    if $self->option('nextbill');
+
+  my $error = $cust_main->charge( \%charge );
 
   die $error if $error;