add option _not_ to apply a lineitem credit, RT#18676
[freeside.git] / FS / FS / cust_credit.pm
index 9fd2d01..fe9572f 100644 (file)
@@ -629,6 +629,7 @@ Example:
     'billpkgnums'       => \@billpkgnums,
     'setuprecurs'       => \@setuprecurs,
     'amounts'           => \@amounts,
+    'apply'             => 1, #0 leaves the credit unapplied
 
     #the credit
     'newreasonnum'      => scalar($cgi->param('newreasonnum')),
@@ -706,6 +707,11 @@ sub credit_lineitems {
     return "Error inserting credit: $error";
   }
 
+  unless ( $arg{'apply'} ) {
+    $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+    return '';
+  }
+
   #my $subtotal = 0;
   my $taxlisthash = {};
   my %cust_credit_bill = ();
@@ -812,7 +818,6 @@ sub credit_lineitems {
           #  do so evenly...)
           my $loc_amount = min( $amount, $location->amount);
 
-          #$taxtotal += $loc_amount
           $amount -= $loc_amount;
 
           #push @taxlines,