Class: Dscf::Marketplace::RequestForQuotation
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Dscf::Marketplace::RequestForQuotation
- Defined in:
- app/models/dscf/marketplace/request_for_quotation.rb
Class Method Summary collapse
- .ransackable_associations(_auth_object = nil) ⇒ Object
-
.ransackable_attributes(_auth_object = nil) ⇒ Object
Ransack configuration for secure filtering.
Instance Method Summary collapse
- #accepted_quotations ⇒ Object
- #can_select_quotation? ⇒ Boolean
- #closed? ⇒ Boolean
- #draft? ⇒ Boolean
- #has_responses? ⇒ Boolean
- #responded? ⇒ Boolean
- #select_quotation!(quotation) ⇒ Object
- #selected? ⇒ Boolean
- #sent? ⇒ Boolean
- #total_items ⇒ Object
Class Method Details
.ransackable_associations(_auth_object = nil) ⇒ Object
22 23 24 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 22 def self.ransackable_associations(_auth_object = nil) %w[user selected_quotation rfq_items quotations] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
Ransack configuration for secure filtering
18 19 20 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 18 def self.ransackable_attributes(_auth_object = nil) %w[id user_id selected_quotation_id status notes created_at updated_at] end |
Instance Method Details
#accepted_quotations ⇒ Object
65 66 67 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 65 def accepted_quotations quotations.where(status: "accepted") end |
#can_select_quotation? ⇒ Boolean
46 47 48 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 46 def can_select_quotation? sent? || responded? end |
#closed? ⇒ Boolean
42 43 44 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 42 def closed? status == "closed" end |
#draft? ⇒ Boolean
26 27 28 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 26 def draft? status == "draft" end |
#has_responses? ⇒ Boolean
61 62 63 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 61 def has_responses? quotations.where.not(status: "draft").exists? end |
#responded? ⇒ Boolean
34 35 36 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 34 def responded? status == "responded" end |
#select_quotation!(quotation) ⇒ Object
50 51 52 53 54 55 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 50 def select_quotation!(quotation) return false unless can_select_quotation? return false unless quotations.include?(quotation) update!(selected_quotation: quotation, status: "selected") end |
#selected? ⇒ Boolean
38 39 40 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 38 def selected? status == "selected" end |
#sent? ⇒ Boolean
30 31 32 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 30 def sent? status == "sent" end |
#total_items ⇒ Object
57 58 59 |
# File 'app/models/dscf/marketplace/request_for_quotation.rb', line 57 def total_items rfq_items.count end |