Sha256: d2b38d7ef2b46e59fccdd253cb007e163e698ffa9fb60ad26126e076d291541a

Contents?: true

Size: 988 Bytes

Versions: 66

Compression:

Stored size: 988 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_action :load_resource, only: [:toggle_state, :edit, :update, :destroy]

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

      def index
        @adjustments = @order.all_adjustments.eligible.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_with_updater!
      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

66 entries across 66 versions & 1 rubygems

Version Path
spree_backend-4.0.9 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.1.15 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.1.14 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.0.8 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-3.7.14.1 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.1.13.1 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.0.7.1 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.0.7 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-3.7.14 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.1.13 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.0.6 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-3.7.13 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.0.5 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.1.12 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-3.7.12 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.0.4 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-3.7.11 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.1.11 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.1.10 app/controllers/spree/admin/adjustments_controller.rb
spree_backend-4.2.0.beta app/controllers/spree/admin/adjustments_controller.rb