add waive setup fee upon package order feature, RT12568
[freeside.git] / FS / FS / cust_main / Billing.pm
index 64dd8e4..1bf7b02 100644 (file)
@@ -846,13 +846,16 @@ sub _make_lines {
   {
     
     warn "    bill setup\n" if $DEBUG > 1;
-    $lineitems++;
 
-    $setup = eval { $cust_pkg->calc_setup( $time, \@details ) };
-    return "$@ running calc_setup for $cust_pkg\n"
-      if $@;
+    unless ( $cust_pkg->waive_setup ) {
+        $lineitems++;
+
+        $setup = eval { $cust_pkg->calc_setup( $time, \@details ) };
+        return "$@ running calc_setup for $cust_pkg\n"
+          if $@;
 
-    $unitsetup = $cust_pkg->part_pkg->unit_setup || $setup; #XXX uuh
+        $unitsetup = $cust_pkg->part_pkg->unit_setup || $setup; #XXX uuh
+    }
 
     $cust_pkg->setfield('setup', $time)
       unless $cust_pkg->setup;
@@ -897,13 +900,6 @@ sub _make_lines {
              || $cust_pkg->setup
              || $time;
 
-    if ( $DEBUG > 2 ) {
-      warn 'part_pkg.freq: '. $part_pkg->freq. "\n";
-      warn 'cust_pkg.bill: '. $cust_pkg->getfield('bill'). "\n";
-      warn "time: $time\n";
-      warn "options{cancel}: $options{cancel}\n";
-    }
-
     #over two params!  lets at least switch to a hashref for the rest...
     my $increment_next_bill = ( $part_pkg->freq ne '0'
                                 && ( $cust_pkg->getfield('bill') || 0 ) <= $time
@@ -925,7 +921,7 @@ sub _make_lines {
 
     warn "calling $method on cust_pkg ". $cust_pkg->pkgnum.
          " for pkgpart ". $cust_pkg->pkgpart.
-         " with params ". join(' / ', map "$_=>$params{$_}", keys %param). "\n"
+         " with params ". join(' / ', map "$_=>$param{$_}", keys %param). "\n"
       if $DEBUG > 2;
            
     $recur = eval { $cust_pkg->$method( \$sdate, \@details, \%param ) };
@@ -1026,11 +1022,11 @@ sub _make_lines {
         'freq'      => $part_pkg->freq,
       };
 
-      if ( $part_pkg->option('recur_temporality', 1) eq 'preceding' ) {
+      if ( $part_pkg->recur_temporality eq 'preceding' ) {
         $cust_bill_pkg->sdate( $hash{last_bill} );
         $cust_bill_pkg->edate( $sdate - 86399   ); #60s*60m*24h-1
         $cust_bill_pkg->edate( $time ) if $options{cancel};
-      } else { #if ( $part_pkg->option('recur_temporality', 1) eq 'upcoming' ) {
+      } else { #if ( $part_pkg->recur_temporality eq 'upcoming' ) {
         $cust_bill_pkg->sdate( $sdate );
         $cust_bill_pkg->edate( $cust_pkg->bill );
         #$cust_bill_pkg->edate( $time ) if $options{cancel};