Class: ViewQuote

Inherits:
ApplicationViewRecord show all
Includes:
Models::SearchableView, Models::SearchableViewWithLineItems, PgSearch::Model
Defined in:
app/models/view_quote.rb

Overview

== Schema Information

Table name: view_quotes
Database name: primary

id :integer primary key
catalog_name :string(255)
contact_full_name :string(255)
currency :string(255)
customer_full_name :string(255)
hold_for_transmission :boolean
last_revision :boolean
line_total :decimal(10, 2)
local_sales_rep_full_name :string(255)
notes :text
opportunity_name :string(80)
primary_sales_rep_full_name :string(255)
recipient :string(255)
reference_number :string(255)
sales_priority_index :integer
secondary_sales_rep_full_name :string(255)
source_full_name :string(500)
state :string(255)
total :decimal(10, 2)
created_at :datetime
updated_at :datetime
catalog_id :integer
contact_id :integer
customer_id :integer
local_sales_rep_id :integer
opportunity_id :integer
primary_sales_rep_id :integer
secondary_sales_rep_id :integer
source_id :integer
store_id :integer

Class Method Summary collapse

Methods included from Models::SearchableViewWithLineItems

contains_item_ids, contains_product_category_ids, contains_product_line_ids, not_contains_item_ids, not_contains_product_category_ids, not_contains_product_line_ids

Methods included from Models::SearchableView

#crm_link, #crm_link_subtitle, #has_columns?, #main_resource, #readonly?

Methods inherited from ApplicationViewRecord

create, create!, #readonly?

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.contains_coupon_idsActiveRecord::Relation<ViewQuote>

A relation of ViewQuotes that are contains coupon ids. Active Record Scope

Returns:

See Also:



43
# File 'app/models/view_quote.rb', line 43

scope :contains_coupon_ids, ->(coupon_ids) { where("EXISTS (select discounts.id from discounts where discounts.coupon_id IN (?) and discounts.itemizable_type = 'Quote' and discounts.itemizable_id = view_quotes.id)", coupon_ids) }

.ransackable_scopes(_auth_object = nil) ⇒ Object



54
55
56
# File 'app/models/view_quote.rb', line 54

def self.ransackable_scopes(_auth_object = nil)
  super + %i[source_id contains_coupon_ids customer_full_name_search]
end

.source_idActiveRecord::Relation<ViewQuote>

A relation of ViewQuotes that are source id. Active Record Scope

Returns:

See Also:



45
46
47
48
49
50
# File 'app/models/view_quote.rb', line 45

scope :source_id, ->(*sids) {
  sids = sids.flatten.compact
  next all if sids.blank?

  where(source_id: Source.self_and_descendants_ids(sids))
}