Sha256: 2bd9af63465525a1317c9dad2cbcdc248e345f114d458a4d4f09671dbf99fbf0
Contents?: true
Size: 685 Bytes
Versions: 5
Compression:
Stored size: 685 Bytes
Contents
module Comee module Core class ReorderReport < ApplicationRecord before_create :set_reference_number belongs_to :store has_many :reorder_report_items validates :report_date, presence: true validates :reference_number, uniqueness: true private def set_reference_number self.reference_number = generate_reference_number end def generate_reference_number loop do number = SecureRandom.random_number(10000000) reference_number = "RR-#{number}" break reference_number unless ReorderReport.where(reference_number: reference_number).exists? end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems