Class: ViewPurchaseOrder

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

Overview

== Schema Information

Table name: view_purchase_orders
Database name: primary

id :integer primary key
carrier_full_name :string(255)
company_short_name :string(255)
currency :string(255)
description :string(255)
drop_ship :boolean
item_count :bigint
items_report :string is an Array
order_date :date
po_type :string(255)
promised_delivery_date :date
reference_number :string(20)
request_date :date
state :string(255)
store_name :string(255)
supplier_full_name :string(255)
terms :string(255)
total_cost :decimal(8, 2)
total_weight :float
created_at :datetime
updated_at :datetime
company_id :integer
store_id :integer
supplier_id :integer

Class Method Summary collapse

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_tracking_numberActiveRecord::Relation<ViewPurchaseOrder>

A relation of ViewPurchaseOrders that are contains tracking number. Active Record Scope

Returns:

See Also:



36
37
38
39
40
41
42
43
44
# File 'app/models/view_purchase_order.rb', line 36

scope :contains_tracking_number, ->(tracking_number) {
  where(
    'EXISTS(select 1 from shipment_items si
       INNER JOIN purchase_order_shipments pos ON pos.id = si.purchase_order_shipment_id
       WHERE si.purchase_order_id = view_purchase_orders.id
         AND pos.tracking_number ILIKE ?)',
    tracking_number
  )
}

.ransackable_scopes(_auth_object = nil) ⇒ Object



48
49
50
# File 'app/models/view_purchase_order.rb', line 48

def self.ransackable_scopes(_auth_object = nil)
  super + %i[reference_number_search description_search contains_tracking_number]
end