Sha256: 9db4ed5576b34df7cf419de3f533a4d370b0c446abaec4170a473f175261e5e8

Contents?: true

Size: 968 Bytes

Versions: 9

Compression:

Stored size: 968 Bytes

Contents

module Spree
  module Admin
    class AdjustmentsController < ResourceController

      belongs_to 'spree/order', find_by: :number

      create.after :update_totals
      destroy.after :update_totals
      update.after :update_totals

      skip_before_filter :load_resource, only: [:toggle_state, :edit, :update, :destroy]

      before_action :find_adjustment, only: [:destroy, :edit, :update]

      def index
        @adjustments = @order.all_adjustments.order("created_at ASC")
      end

      private

      def find_adjustment
        # Need to assign to @object here to keep ResourceController happy
        @adjustment = @object = parent.all_adjustments.find(params[:id])
      end

      def update_totals
        @order.reload.update!
      end

      # Override method used to create a new instance to correctly
      # associate adjustment with order
      def build_resource
        parent.adjustments.build(order: parent)
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spree_backend-2.3.13 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-2.3.12 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-2.3.11 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-2.3.10 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-2.3.9 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-2.3.8 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-2.3.7 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-2.3.6 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-2.3.5 app/controllers/spree/admin/adjustments_controller.rb