29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/models/unidom/inventory/inventory_item_variance.rb', line 29
def self.adjust!(inventory_item, quantity: nil, due_to: nil, at: Time.now, description: nil, instruction: nil)
if inventory_item.respond_to? :quantity
inventory_item.increment! :quantity, quantity
else
if quantity.nil?
quantity = -1
inventory_item.soft_destroy
else
raise ArgumentError.new('The quantity should be -1 when Inventory Item Variance adjusts a Serialized Inventory Item.')
end
end
create! inventory_item: inventory_item, reason: due_to, quantity: quantity, description: description, instruction: instruction, opened_at: at
end
|