class Dscf::Marketplace::RequestForQuotation
def self.ransackable_associations(_auth_object = nil)
def self.ransackable_associations(_auth_object = nil) %w[user selected_quotation rfq_items quotations] end
def self.ransackable_attributes(_auth_object = nil)
def self.ransackable_attributes(_auth_object = nil) %w[id user_id selected_quotation_id status notes created_at updated_at] end
def accepted_quotations
def accepted_quotations quotations.where(status: "accepted") end
def can_select_quotation?
def can_select_quotation? sent? || responded? end
def closed?
def closed? status == "closed" end
def draft?
def draft? status == "draft" end
def has_responses?
def has_responses? quotations.where.not(status: "draft").exists? end
def responded?
def responded? status == "responded" end
def select_quotation!(quotation)
def select_quotation!(quotation) return false unless can_select_quotation? return false unless quotations.include?(quotation) update!(selected_quotation: quotation, status: "selected") end
def selected?
def selected? status == "selected" end
def selected_quotation_belongs_to_this_rfq
def selected_quotation_belongs_to_this_rfq return unless selected_quotation_id unless quotations.where(id: selected_quotation_id).exists? errors.add(:selected_quotation_id, "must belong to this RFQ") end end
def sent?
def sent? status == "sent" end
def total_items
def total_items rfq_items.count end