RT# 77964 - Placed waive setup fee check back to billing.pm, and added check for...
authorChristopher Burger <burgerc@freeside.biz>
Tue, 1 May 2018 14:07:54 +0000 (10:07 -0400)
committerChristopher Burger <burgerc@freeside.biz>
Tue, 1 May 2018 14:09:46 +0000 (10:09 -0400)
FS/FS/cust_main/Billing.pm
FS/FS/part_pkg/flat.pm

index 44a4dbb..a5a38fd 100644 (file)
@@ -1027,9 +1027,10 @@ sub _make_lines {
              || $cust_pkg->expire > $cmp_time )
      )
   {
-    
+
     warn "    bill setup\n" if $DEBUG > 1;
 
+    unless ($cust_pkg->waive_setup) {
         $lineitems++;
 
         $setup = eval { $cust_pkg->calc_setup( $time, \@details, \%setup_param ) };
@@ -1049,6 +1050,12 @@ sub _make_lines {
           $setup_billed_currency = delete $setup_param{'billed_currency'};
           $setup_billed_amount   = delete $setup_param{'billed_amount'};
         }
+    }
+
+    if ($cust_pkg->waive_setup && $part_pkg->plan eq "prorate") {
+      $lineitems++;
+      $setup = 0 if $part_pkg->prorate_setup($cust_pkg, $time);
+    }
 
     if ( $cust_pkg->get('setup') ) {
       # don't change it
index 0bc3860..cfee584 100644 (file)
@@ -118,26 +118,22 @@ sub calc_setup {
 
   return 0 if $self->prorate_setup($cust_pkg, $sdate);
 
-  if (!$cust_pkg->waive_setup) {
-    my $i = 0;
-    my $count = $self->option( 'additional_count', 'quiet' ) || 0;
-    while ($i < $count) {
-      push @$details, $self->option( 'additional_info' . $i++ );
-    }
+  my $i = 0;
+  my $count = $self->option( 'additional_count', 'quiet' ) || 0;
+  while ($i < $count) {
+    push @$details, $self->option( 'additional_info' . $i++ );
+  }
 
-    my $charge = $self->base_setup($cust_pkg, $sdate, $details);
+  my $charge = $self->base_setup($cust_pkg, $sdate, $details);
 
-    my $discount = 0;
-    if ( $charge > 0 ) {
-      $param->{'setup_charge'} = $charge;
-      $discount = $self->calc_discount($cust_pkg, $sdate, $details, $param);
-      delete $param->{'setup_charge'};
-    }
-
-    return sprintf( '%.2f', ($cust_pkg->quantity || 1) * ($charge - $discount) );
+  my $discount = 0;
+  if ( $charge > 0 ) {
+    $param->{'setup_charge'} = $charge;
+    $discount = $self->calc_discount($cust_pkg, $sdate, $details, $param);
+    delete $param->{'setup_charge'};
   }
 
-  return;
+  sprintf( '%.2f', ($cust_pkg->quantity || 1) * ($charge - $discount) );
 
 }