Module: CustomerDisplay

Extended by:
ActiveSupport::Concern
Included in:
Customer
Defined in:
app/models/concerns/customer_display.rb

Overview

Display, formatting, CRM links, locale, and select-option helpers for Customer.

See Also:

Delegated Instance Attributes collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.affiliations_for_selectObject



15
16
17
# File 'app/models/concerns/customer_display.rb', line 15

def affiliations_for_select
  CustomerConstants::AFFILIATIONS
end

.customer_is_real?(customer) ⇒ Boolean

:reek:UtilityFunction

Returns:

  • (Boolean)


23
24
25
26
27
# File 'app/models/concerns/customer_display.rb', line 23

def customer_is_real?(customer) # :reek:UtilityFunction
  return false unless customer&.

  customer.. != 'www_warmlyyours_com'
end

.options_for_terms_selectObject

:reek:UtilityFunction



29
30
31
32
# File 'app/models/concerns/customer_display.rb', line 29

def options_for_terms_select # :reek:UtilityFunction
  [Customer::TERM_DUE, Customer::TERM_NET15, Customer::TERM_NET30,
   Customer::TERM_NET37, Customer::TERM_NET45, Customer::TERM_NET60, Customer::TERM_NET90]
end

.select_number_of_officesObject



38
39
40
# File 'app/models/concerns/customer_display.rb', line 38

def select_number_of_offices
  [%w[Unknown unknown]] + CustomerConstants::NUMBER_OF_OFFICES.map { |range| [range, range] }
end

.select_projectsObject

:reek:UtilityFunction



34
35
36
# File 'app/models/concerns/customer_display.rb', line 34

def select_projects # :reek:UtilityFunction
  [%w[Unknown unknown]] + CustomerConstants::PROJECTS_PER_YEAR.map { |range| [range, range] }
end

.states_for_selectObject



19
20
21
# File 'app/models/concerns/customer_display.rb', line 19

def states_for_select
  state_machines[:state].states.map { |sm_state| [sm_state.human_name, sm_state.value] }
end

Instance Method Details

#billing_address_attributesObject



71
72
73
74
75
# File 'app/models/concerns/customer_display.rb', line 71

def billing_address_attributes
  billing_address.attributes
rescue StandardError
  nil
end

#companyObject

Alias for Catalog#company

Returns:

  • (Object)

    Catalog#company

See Also:



10
# File 'app/models/concerns/customer_display.rb', line 10

delegate :company, to: :catalog

#countryObject



51
52
53
# File 'app/models/concerns/customer_display.rb', line 51

def country
  super || catalog&.store&.country
end

#customer_service_managerObject

Alias for Catalog#customer_service_manager

Returns:

  • (Object)

    Catalog#customer_service_manager

See Also:



11
# File 'app/models/concerns/customer_display.rb', line 11

delegate :customer_service_manager, to: :catalog

#localeObject



47
48
49
# File 'app/models/concerns/customer_display.rb', line 47

def locale
  Catalog.catalog_id_to_locale(catalog_id) || super
end

#main_addressObject



43
44
45
# File 'app/models/concerns/customer_display.rb', line 43

def main_address
  mailing_address || shipping_address || billing_address || super
end

#online?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'app/models/concerns/customer_display.rb', line 63

def online?
  .present?
end

#product_review_delay_monthsObject



77
78
79
80
81
82
83
# File 'app/models/concerns/customer_display.rb', line 77

def product_review_delay_months
  if homeowner?
    Customer::HOMEOWNER_PRODUCT_REVIEW_DELAY_MONTHS
  else
    Customer::TRADE_PRO_PRODUCT_REVIEW_DELAY_MONTHS
  end
end

#reference_numberObject



67
68
69
# File 'app/models/concerns/customer_display.rb', line 67

def reference_number
  "CN#{id}"
end

#to_labelObject



59
60
61
# File 'app/models/concerns/customer_display.rb', line 59

def to_label
  "[CN#{id}] #{full_name}"
end

#to_sObject



55
56
57
# File 'app/models/concerns/customer_display.rb', line 55

def to_s
  "#{full_name} [CN#{id}]"
end