class AssignedOrderItem < ApplicationRecord
  before_create :generate_custom_id

  #primary key - need to be unique
  self.primary_key = "assigned_order_item_id"

  belongs_to :order
  belongs_to :order_queue_station

  def self.assigned_order_item (order, item_code, order_queue_station )
    assigned_order_item = AssignedOrderItem.new()
    assigned_order_item.order = order
    assigned_order_item.item_code = item_code
    assigned_order_item.order_queue_station = order_queue_station
    assigned_order_item.print_status = false
    assigned_order_item.delivery_status = false
    assigned_order_item.save
  end

  private
  def generate_custom_id
    self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI")
  end
end
