scinote-web/app/serializers/api/v1/task_inventory_item_serializer.rb
artoscinote 229a27750f
Implement stock consumption via the API [SCI-6642] (#3964)
* Implement stock consumption via the API [SCI-6642]

* Remove unnecessary attribute from InventoryItemSerializer [SCI-6642]

* Amend permission check, add nested transaction support to consume_stock method [SCI-6642]
2022-03-30 14:33:26 +02:00

15 lines
398 B
Ruby

# frozen_string_literal: true
module Api
module V1
class TaskInventoryItemSerializer < InventoryItemSerializer
attribute :stock_consumption, if: -> { object.repository_stock_cell.present? }
def stock_consumption
object.my_module_repository_rows
.find_by(my_module: instance_options[:my_module])
.stock_consumption
end
end
end
end