<commit_before>class Spree::Admin::RefundController < Spree::Admin::BaseController
  layout 'spree/admin/layouts/refund'

  def select_order

  end

  def select_items
    @order = Spree::Order.find_by(number: params[:order_number])
    @order.return_authorizations.select(&:can_cancel?).map(&:cancel)
    @return_authorization = Spree::ReturnAuthorization.create(order: @order, reason: 'POS refund')
    if @order
      if @order.state == 'complete'
        @variants = @order.variants
      else
        flash[:error] = "This order can't be refund because is in state #{@order.state}"
        redirect_to action: :select_order
      end
    else
      flash[:error] = 'The order number is has not been found'
      redirect_to action: :select_order
    end
  end

  def create_refund
    @order = Spree::Order.find_by(number: params[:order_number])
    @return_authorization = Spree::ReturnAuthorization.find_by(number: params[:rma])<commit_msg>Bug when no passing a valid code<commit_after>class Spree::Admin::RefundController < Spree::Admin::BaseController
  layout 'spree/admin/layouts/refund'

  def select_order

  end

  def select_items
    @order = Spree::Order.find_by(number: params[:order_number])
    if @order
      @order.return_authorizations.select(&:can_cancel?).map(&:cancel) if @order.return_authorizations.count > 0
      @return_authorization = Spree::ReturnAuthorization.create(order: @order, reason: 'POS refund')
      if @order.state == 'complete'
        @variants = @order.variants
      else
        flash[:error] = "This order can't be refund because is in state #{@order.state}"
        redirect_to action: :select_order
      end
    else
      flash[:error] = 'The order number is has not been found'
      redirect_to action: :select_order
    end
  end

  def create_refund
    @order = Spree::Order.find_by(number: params[:order_number])
    @return_authorization = Spree::ReturnAuthorization.find_by(number: params[:rma])
{'fraction_non_alphanumeric': 0.11332312404287902, 'fraction_numerical': 0.0005104645227156713, 'mean_word_length': 3.962025316455696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4732640', 'n_tokens_mistral': 603, 'n_tokens_neox': 592, 'n_words': 140}