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.
Delegated Instance Attributes collapse
-
#company ⇒ Object
Alias for Catalog#company.
-
#customer_service_manager ⇒ Object
Alias for Catalog#customer_service_manager.
Class Method Summary collapse
- .affiliations_for_select ⇒ Object
-
.customer_is_real?(customer) ⇒ Boolean
:reek:UtilityFunction.
-
.options_for_terms_select ⇒ Object
:reek:UtilityFunction.
- .select_number_of_offices ⇒ Object
-
.select_projects ⇒ Object
:reek:UtilityFunction.
- .states_for_select ⇒ Object
Instance Method Summary collapse
- #billing_address_attributes ⇒ Object
- #country ⇒ Object
- #locale ⇒ Object
- #main_address ⇒ Object
- #online? ⇒ Boolean
- #product_review_delay_months ⇒ Object
- #reference_number ⇒ Object
- #to_label ⇒ Object
- #to_s ⇒ Object
Class Method Details
.affiliations_for_select ⇒ Object
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
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&.account customer.account.login != 'www_warmlyyours_com' end |
.options_for_terms_select ⇒ Object
:reek:UtilityFunction
29 30 31 32 |
# File 'app/models/concerns/customer_display.rb', line 29 def # :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_offices ⇒ Object
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_projects ⇒ Object
: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_select ⇒ Object
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_attributes ⇒ Object
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 |
#company ⇒ Object
Alias for Catalog#company
10 |
# File 'app/models/concerns/customer_display.rb', line 10 delegate :company, to: :catalog |
#country ⇒ Object
51 52 53 |
# File 'app/models/concerns/customer_display.rb', line 51 def country super || catalog&.store&.country end |
#customer_service_manager ⇒ Object
Alias for Catalog#customer_service_manager
11 |
# File 'app/models/concerns/customer_display.rb', line 11 delegate :customer_service_manager, to: :catalog |
#locale ⇒ Object
47 48 49 |
# File 'app/models/concerns/customer_display.rb', line 47 def locale Catalog.catalog_id_to_locale(catalog_id) || super end |
#main_address ⇒ Object
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
63 64 65 |
# File 'app/models/concerns/customer_display.rb', line 63 def online? account.present? end |
#product_review_delay_months ⇒ Object
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_number ⇒ Object
67 68 69 |
# File 'app/models/concerns/customer_display.rb', line 67 def reference_number "CN#{id}" end |
#to_label ⇒ Object
59 60 61 |
# File 'app/models/concerns/customer_display.rb', line 59 def to_label "[CN#{id}] #{full_name}" end |
#to_s ⇒ Object
55 56 57 |
# File 'app/models/concerns/customer_display.rb', line 55 def to_s "#{full_name} [CN#{id}]" end |