[freeside-commits] branch master updated. 3cd4fcd5ba52826336c727b855ac12a6407a4b35

Ivan ivan at 420.am
Tue Nov 19 22:30:14 PST 2013


The branch, master has been updated
       via  3cd4fcd5ba52826336c727b855ac12a6407a4b35 (commit)
      from  7d259262bb97c5a911754e485a61a6ff7bed0104 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3cd4fcd5ba52826336c727b855ac12a6407a4b35
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Nov 19 22:30:12 2013 -0800

    fix self-service error on change package with BILL customers and selfservice-realtime, RT#26140

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 241963f..a580991 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -2318,7 +2318,7 @@ sub change_pkg {
   my $conf = new FS::Conf;
   if ( $conf->exists('signup_server-realtime') ) {
 
-    my $bill_error = _do_bop_realtime( $cust_main, $status );
+    my $bill_error = _do_bop_realtime( $cust_main, $status, 'no_credit'=>1 );
 
     if ($bill_error) {
       $newpkg[0]->suspend;
@@ -2390,25 +2390,32 @@ sub order_recharge {
 }
 
 sub _do_bop_realtime {
-  my ($cust_main, $status) = (shift, shift);
+  my ($cust_main, $status, %opt) = @_;
 
     my $old_balance = $cust_main->balance;
 
     my $bill_error =    $cust_main->bill
-                     || $cust_main->apply_payments_and_credits
-                     || $cust_main->realtime_collect('selfservice' => 1);
+                     || $cust_main->apply_payments_and_credits;
+
+    $bill_error ||= $cust_main->realtime_collect('selfservice' => 1)
+      if $cust_main->payby =~ /^(CARD|CHEK)$/;
 
     if (    $cust_main->balance > $old_balance
          && $cust_main->balance > 0
-         && ( $cust_main->payby !~ /^(BILL|DCRD|DCHK)$/ ?
-              1 : $status eq 'suspended' ) ) {
-      #this makes sense.  credit is "un-doing" the invoice
-      my $conf = new FS::Conf;
-      $cust_main->credit( sprintf("%.2f", $cust_main->balance - $old_balance ),
-                          'self-service decline',
-                          'reason_type' => $conf->config('signup_credit_type'),
-                        );
-      $cust_main->apply_credits( 'order' => 'newest' );
+         && ( $cust_main->payby !~ /^(BILL|DCRD|DCHK)$/
+                || $status eq 'suspended'
+            )
+       )
+    {
+      unless ( $opt{'no_credit'} ) {
+        #this makes sense.  credit is "un-doing" the invoice
+        my $conf = new FS::Conf;
+        $cust_main->credit( sprintf("%.2f", $cust_main->balance-$old_balance ),
+                            'self-service decline',
+                            reason_type=>$conf->config('signup_credit_type'),
+                          );
+        $cust_main->apply_credits( 'order' => 'newest' );
+      }
 
       return { 'error' => '_decline', 'bill_error' => $bill_error };
     }

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm |   33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)




More information about the freeside-commits mailing list