1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/app/models/product_stock_movement.rb

19 lines
654 B
Ruby
Raw Normal View History

2022-08-05 15:25:51 +02:00
# frozen_string_literal: true
# ProductStockMovement is a model for record the movements of product's stock
class ProductStockMovement < ApplicationRecord
belongs_to :product
ALL_STOCK_TYPES = %w[internal external].freeze
enum stock_type: ALL_STOCK_TYPES.zip(ALL_STOCK_TYPES).to_h
ALL_REASONS = %w[incoming_stock returned_by_customer cancelled_by_customer sold missing_from_inventory damaged].freeze
enum reason: ALL_REASONS.zip(ALL_REASONS).to_h
validates :stock_type, presence: true
validates :stock_type, inclusion: { in: ALL_STOCK_TYPES }
validates :reason, presence: true
validates :reason, inclusion: { in: ALL_REASONS }
end