Sha256: 88502d19fe4d28cbd84d45125e3ed87276815858e23a6c378e4fc6560370c362

Contents?: true

Size: 1.03 KB

Versions: 17

Compression:

Stored size: 1.03 KB

Contents

class RefundsController < ArtfullyOseController
  def new
    @order = Order.find(params[:order_id])
    @items = params[:items].collect { |item_id| Item.find(item_id) }
  end

  def create
    @order = Order.find(params[:order_id])
    @items = params[:items].collect { |item_id| Item.find(item_id) }

    @refund = Refund.new(@order, @items)
    @refund.submit(:and_return => return_items?)

    if @refund.successful?
      if return_items?
        flash[:notice] = "Successfully refunded and returned #{@refund.items.size} items."
      else
        flash[:notice] = "Successfully refunded #{@refund.items.size} items."
      end
    else
      if @refund.message.nil?
        flash[:error] = "Unable to refund items.  Please contact support and we'll try to help!"
      else
        flash[:error] = "Unable to refund items: " + @refund.message
      end
    end

    redirect_to order_url(@order)
  end

  private

  def return_items?
    @return_items ||= (params[:commit] == "Issue Refund and Return" and @items.all?(&:returnable?))
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.15 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.12 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.11 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.10 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.9 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.8 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.7 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.6 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.5 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.4 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.3 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.2 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.1 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre app/controllers/refunds_controller.rb
artfully_ose-1.1.0 app/controllers/refunds_controller.rb
artfully_ose-1.1.0.rc2 app/controllers/refunds_controller.rb
artfully_ose-1.1.0.rc1 app/controllers/refunds_controller.rb