class SaleOrder < ApplicationRecord
  self.primary_key = "sale_order_id"

  #primary key - need to be unique generated for multiple shops
  before_create :generate_sale_order_id

  belongs_to :sale
  belongs_to :order

  def create_sale_order(sale, order)
    self.sale_id = sale
    self.order_id = order
    self.save

  end

  private
  def generate_sale_order_id
    self.class.name
    saleOrderId = SeedGenerator.generate_id(self.class.name, "SOI")
    self.sale_order_id = saleOrderId
  end
end
