Class: ViewRma

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

Overview

== Schema Information

Table name: view_rmas
Database name: primary

id :integer primary key
actual_rma_credit :decimal(, )
arrival_date :date
awaiting_return :boolean
company_name :string(255)
contact_name :string(255)
creator_full_name :string(255)
credited_date :date
customer_full_name :string(255)
customer_reference :string(255)
description :text
estimated_rma_credit :decimal(, )
original_invoice_reference_number :string(255)
original_order_reference_number :string(255)
original_po_number :string(255)
primary_sales_rep_full_name :string(255)
returned_date :date
returned_reasons :string(255) is an Array
rma_number :string(255)
state :string(255)
tracking_numbers :string is an Array
transmission_state :string(255)
created_at :datetime
updated_at :datetime
company_id :integer
creator_id :integer
customer_id :integer
original_invoice_id :integer
original_order_id :integer
primary_sales_rep_id :integer
return_delivery_id :integer

Constant Summary

Constants included from Schedulable

Schedulable::SIMPLE_FORM_OPTIONS

Belongs to collapse

Has many collapse

Class Method Summary collapse

Methods included from Models::SearchableViewWithRmaItems

contains_rma_item_ids

Methods included from Models::SearchableView

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

Methods inherited from ApplicationViewRecord

create, create!, #readonly?

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransortable_attributes, #to_relation

Methods included from Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.contains_tracking_numberActiveRecord::Relation<ViewRma>

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

Returns:

  • (ActiveRecord::Relation<ViewRma>)

See Also:



52
53
54
55
56
57
# File 'app/models/view_rma.rb', line 52

scope :contains_tracking_number, ->(tracking_number) {
  joins(:return_shipments).where.any_of(
    where.overlap(tracking_numbers: [tracking_number]),
    { shipments: { tracking_number: tracking_number } }
  )
}

.ransackable_scopes(_auth_object = nil) ⇒ Object



62
63
64
65
# File 'app/models/view_rma.rb', line 62

def self.ransackable_scopes(_auth_object = nil)
  super + %i[customer_full_name_search customer_reference_search original_po_search
             contains_tracking_number returned_reasons]
end

.returned_reasonsActiveRecord::Relation<ViewRma>

A relation of ViewRmas that are returned reasons. Active Record Scope

Returns:

  • (ActiveRecord::Relation<ViewRma>)

See Also:



58
59
60
# File 'app/models/view_rma.rb', line 58

scope :returned_reasons, ->(reasons) {
  joins(:rma_items).where(rma_items: { returned_reason: Array(reasons) }).distinct
}

Instance Method Details

#return_deliveryDelivery

Returns:

See Also:



44
# File 'app/models/view_rma.rb', line 44

belongs_to :return_delivery, class_name: 'Delivery', optional: true

#return_shipmentsActiveRecord::Relation<Shipment>

Returns:

See Also:



46
# File 'app/models/view_rma.rb', line 46

has_many :return_shipments, -> { label_complete }, source: :shipments, class_name: 'Shipment', through: :return_delivery

#rma_itemsActiveRecord::Relation<RmaItem>

Returns:

  • (ActiveRecord::Relation<RmaItem>)

See Also:



45
# File 'app/models/view_rma.rb', line 45

has_many :rma_items, foreign_key: :rma_id