Class: Cats::Core::InventoryAdjustment

Inherits:
ApplicationRecord show all
Defined in:
app/models/cats/core/inventory_adjustment.rb

Constant Summary collapse

DRAFT =

adjustment statuses

"Draft".freeze
COMMITTED =
"Committed".freeze
STATUSES =
[DRAFT, COMMITTED].freeze

Instance Method Summary collapse

Instance Method Details

#commitObject



19
20
21
22
23
24
25
26
27
# File 'app/models/cats/core/inventory_adjustment.rb', line 19

def commit
  adjusted_quantity = UnitConversion.convert(stack.unit, Cats::Core::UnitOfMeasure.find(unit_id), quantity)

  stack.quantity += adjusted_quantity
  stack.save

  self.status = COMMITTED
  save
end