add option _not_ to apply a lineitem credit, RT#18676
authorIvan Kohler <ivan@freeside.biz>
Fri, 21 Dec 2012 08:07:41 +0000 (00:07 -0800)
committerIvan Kohler <ivan@freeside.biz>
Fri, 21 Dec 2012 08:07:41 +0000 (00:07 -0800)
FS/FS/cust_credit.pm
httemplate/edit/credit-cust_bill_pkg.html
httemplate/edit/process/credit-cust_bill_pkg.html

index 18d8bed..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 = ();
index f5c4eef..e0ca04b 100644 (file)
   </TD>
 </TR>
 
+% if ( $conf->exists('credits-auto-apply-disable') ) {
+        <INPUT TYPE="HIDDEN" NAME="apply" VALUE="no">
+% } else {
+  <TR>
+    <TD ALIGN="right"><% mt('Apply to selected line items') |h %></TD>
+    <TD><SELECT NAME="apply"><OPTION VALUE="yes" SELECTED><% mt('yes') |h %><OPTION><% mt('no') |h %></SELECT></TD>
+  </TR>
+% }
+
 </table>
 
 <BR>
index 1b61997..cbcf619 100644 (file)
@@ -32,6 +32,7 @@ my $error = FS::cust_credit->credit_lineitems(
   'billpkgnums'       => \@billpkgnums,
   'setuprecurs'       => \@setuprecurs,
   'amounts'           => \@amounts,
+  'apply'             => ( $cgi->param('apply') eq 'yes' ),
 
   #the credit
   'newreasonnum'      => scalar($cgi->param('newreasonnum')),