Sha256: 3de5c48b69e65bb2c8ceca196cecf9d4b21eff2858da97e14d84d3aeb0a27d34

Contents?: true

Size: 639 Bytes

Versions: 38

Compression:

Stored size: 639 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[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

38 entries across 38 versions & 1 rubygems

Version Path
comee_core-0.1.90 app/models/comee/core/quotation_request.rb
comee_core-0.1.89 app/models/comee/core/quotation_request.rb
comee_core-0.1.88 app/models/comee/core/quotation_request.rb
comee_core-0.1.87 app/models/comee/core/quotation_request.rb
comee_core-0.1.86 app/models/comee/core/quotation_request.rb
comee_core-0.1.85 app/models/comee/core/quotation_request.rb
comee_core-0.1.84 app/models/comee/core/quotation_request.rb
comee_core-0.1.83 app/models/comee/core/quotation_request.rb
comee_core-0.1.82 app/models/comee/core/quotation_request.rb
comee_core-0.1.81 app/models/comee/core/quotation_request.rb
comee_core-0.1.80 app/models/comee/core/quotation_request.rb
comee_core-0.1.79 app/models/comee/core/quotation_request.rb
comee_core-0.1.78 app/models/comee/core/quotation_request.rb
comee_core-0.1.77 app/models/comee/core/quotation_request.rb
comee_core-0.1.76 app/models/comee/core/quotation_request.rb
comee_core-0.1.75 app/models/comee/core/quotation_request.rb
comee_core-0.1.74 app/models/comee/core/quotation_request.rb
comee_core-0.1.73 app/models/comee/core/quotation_request.rb
comee_core-0.1.72 app/models/comee/core/quotation_request.rb
comee_core-0.1.71 app/models/comee/core/quotation_request.rb