Sha256: 660a7c7fe4ec10e285fcceb532e93056387fd38c41d422021a1c5755deea8bfd

Contents?: true

Size: 642 Bytes

Versions: 131

Compression:

Stored size: 642 Bytes

Contents

module Comee
  module Core
    class QuotationRequest < ApplicationRecord
      before_validation :set_reference_no, if: proc { |rfq| rfq.reference_no.nil? }

      belongs_to :client
      has_many :quotation_request_items

      enum :status, {draft: 0, submitted: 1, awaiting_confirmation: 2, confirmed: 3, converted: 4}

      validates :status, presence: true

      def self.ransackable_attributes(_auth_object = nil)
        %w[id client_id reference_no status]
      end

      private

      def set_reference_no
        stamp = DateTime.now.to_i
        self.reference_no = "RFQ-#{client.code}-#{stamp}"
      end
    end
  end
end

Version data entries

131 entries across 131 versions & 1 rubygems

Version Path
comee_core-0.2.21 app/models/comee/core/quotation_request.rb
comee_core-0.2.20 app/models/comee/core/quotation_request.rb
comee_core-0.2.19 app/models/comee/core/quotation_request.rb
comee_core-0.2.18 app/models/comee/core/quotation_request.rb
comee_core-0.2.17 app/models/comee/core/quotation_request.rb
comee_core-0.2.16 app/models/comee/core/quotation_request.rb
comee_core-0.2.15 app/models/comee/core/quotation_request.rb
comee_core-0.2.14 app/models/comee/core/quotation_request.rb
comee_core-0.2.13 app/models/comee/core/quotation_request.rb
comee_core-0.2.12 app/models/comee/core/quotation_request.rb
comee_core-0.2.11 app/models/comee/core/quotation_request.rb
comee_core-0.2.10 app/models/comee/core/quotation_request.rb
comee_core-0.2.9 app/models/comee/core/quotation_request.rb
comee_core-0.2.8 app/models/comee/core/quotation_request.rb
comee_core-0.2.7 app/models/comee/core/quotation_request.rb
comee_core-0.2.6 app/models/comee/core/quotation_request.rb
comee_core-0.2.5 app/models/comee/core/quotation_request.rb
comee_core-0.2.4 app/models/comee/core/quotation_request.rb
comee_core-0.2.3 app/models/comee/core/quotation_request.rb
comee_core-0.2.2 app/models/comee/core/quotation_request.rb