Sha256: cfa0e69858f8a8a7dda0bfcb157f6238df995b588c89903d0d6535745a28fb37

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

module Spree
  module Admin
    class ReimbursementsController < ResourceController
      belongs_to 'spree/order', find_by: :number

      before_action :load_simulated_refunds, only: :edit

      def perform
        @reimbursement.perform!
        redirect_to location_after_save
      end

      private

      def build_resource
        if params[:build_from_customer_return_id].present?
          customer_return = CustomerReturn.find(params[:build_from_customer_return_id])

          Reimbursement.build_from_customer_return(customer_return)
        else
          super
        end
      end

      def location_after_save
        if @reimbursement.reimbursed?
          admin_order_reimbursement_path(parent, @reimbursement)
        else
          edit_admin_order_reimbursement_path(parent, @reimbursement)
        end
      end

      def load_simulated_refunds
        @reimbursement_objects = @reimbursement.simulate
      end

      # TODO: Remove this when https://github.com/spree/spree/pull/5158 gets merged in
      def permitted_resource_params
        params[object_name].present? ? super : ActionController::Parameters.new
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_backend-2.4.0.rc3 app/controllers/spree/admin/reimbursements_controller.rb
spree_backend-2.4.0.rc2 app/controllers/spree/admin/reimbursements_controller.rb
spree_backend-2.4.0.rc1 app/controllers/spree/admin/reimbursements_controller.rb