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