Sha256: 2a0693e7a6487463009e072d6e0ffa59c9d2391229f6c55cb8e7c598eb699dfc

Contents?: true

Size: 822 Bytes

Versions: 13

Compression:

Stored size: 822 Bytes

Contents

module Spree
  module Api
    class StockTransfersController < Spree::Api::BaseController
      def receive
        authorize! :update, TransferItem
        @stock_transfer = Spree::StockTransfer.accessible_by(current_ability, :update).find_by!(number: params[:id])
        variant = Spree::Variant.accessible_by(current_ability, :show).find(params[:variant_id])
        @transfer_item = @stock_transfer.transfer_items.find_by(variant: variant)
        if @transfer_item.nil?
          render "spree/api/errors/variant_not_in_stock_transfer", status: 422
        elsif @transfer_item.update_attributes(received_quantity: @transfer_item.received_quantity + 1)
          render 'spree/api/stock_transfers/receive', status: 200
        else
          invalid_resource!(@transfer_item)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
solidus_api-1.0.7 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.6 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.5 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.4 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.3 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.2 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.1 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.0 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.0.rc2 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.0.rc1 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.0.pre3 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.0.pre2 app/controllers/spree/api/stock_transfers_controller.rb
solidus_api-1.0.0.pre app/controllers/spree/api/stock_transfers_controller.rb