madetech/solidus_wms

View on GitHub
app/controllers/concerns/solidus_wms/additional_shipments_api_actions.rb

Summary

Maintainability
A
0 mins
Test Coverage
module SolidusWms
  module AdditionalShipmentsApiActions
    extend ActiveSupport::Concern

    included do
      alias_method :wms_lock_order, :lock_order

      skip_around_action :lock_order, only: [:pick, :receive]
      before_action :wms_find_shipment, only: [:pick, :receive]
      around_action :wms_lock_order, only: [:pick, :receive]
    end

    def pick
      authorize! :ship, @shipment
      unless @shipment.picked?
        @shipment.pick!
      end
      respond_with(@shipment, default_template: :show)
    end

    def receive
      authorize! :ship, @shipment
      unless @shipment.received?
        @shipment.receive!
      end
      respond_with(@shipment, default_template: :show)
    end

    private

    def wms_find_shipment
      find_shipment
    end
  end
end