[freeside-commits] branch FREESIDE_3_BRANCH updated. 9c8ee335eed13794665715919acc344e47e4504f

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


The branch, FREESIDE_3_BRANCH has been updated
       via  9c8ee335eed13794665715919acc344e47e4504f (commit)
      from  c9c9577203f43da9b851132c9c120bdf3de1fa47 (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 9c8ee335eed13794665715919acc344e47e4504f
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Nov 19 22:30:14 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 db9ae5a..b7ac0ea 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -2331,7 +2331,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;
@@ -2403,25 +2403,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