if (count($rid_arr) > 0) {
             foreach ($rid_arr as $return_id) {
                 if ($return_id > 0) {
                     $class_o->updateReturnDetail($return_id, 'return_status', '1');
                 }
             }
         }
     } elseif ($class_pi->detail['invoice_order_type'] == 'S') {
         //CLOSED RETURN (REMOVE FROM Return List on SP Orders Management on Tab "Cancel & Return")
         //if(count($rid_arr)>0) {
         //    foreach($rid_arr as $return_id) if($return_id>0) $class_jo->returnItemUpdate($return_id, 'confirm_return', '1');
         //}
         //Don't do this, the returns in SP Orders Management will be removed when the returns are reported to SP
         //By doing this here we prevent the returns to be reported to our SP which is very important
     }
     $class_payone->payoneReturnItemHistory($return_hist);
     if ($return_hist['amount_return_submitted'] == 0) {
         //REFUND >> $returns['amount_return'] is negative
         //$class_pi->overPaymentAmount($return_hist['amount_return']/100);
         $class_pi->overPaymentAmount($amount_return_total / 100);
     } else {
         $class_pi->debitAmount($request['amount'] / 100 * -1);
         //$request['amount'] = round($return_hist['amount_return_submitted']);
         $last_balance = $class_pi->getBalance();
         if ($last_balance < 0) {
             $class_pi->overPaymentAmount($last_balance);
             $class_pi->updateCompleteStatus('F');
             //F = REFUND SUBMITTED
         }
     }
 } else {