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
24 25 26 27 28 |
# File 'app/models/concerns/customer_display.rb', line 24 def customer_is_real?(customer) return false unless customer&.account customer.account.login != 'www_warmlyyours_com' end |
.options_for_terms_select ⇒ Object
:reek:UtilityFunction
31 32 33 34 |
# File 'app/models/concerns/customer_display.rb', line 31 def [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
41 42 43 |
# File 'app/models/concerns/customer_display.rb', line 41 def select_number_of_offices [%w[Unknown unknown]] + CustomerConstants::NUMBER_OF_OFFICES.map { |range| [range, range] } end |
.select_projects ⇒ Object
:reek:UtilityFunction
37 38 39 |
# File 'app/models/concerns/customer_display.rb', line 37 def select_projects [%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
74 75 76 77 78 |
# File 'app/models/concerns/customer_display.rb', line 74 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
54 55 56 |
# File 'app/models/concerns/customer_display.rb', line 54 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
50 51 52 |
# File 'app/models/concerns/customer_display.rb', line 50 def locale Catalog.catalog_id_to_locale(catalog_id) || super end |
#main_address ⇒ Object
46 47 48 |
# File 'app/models/concerns/customer_display.rb', line 46 def main_address mailing_address || shipping_address || billing_address || super end |
#online? ⇒ Boolean
66 67 68 |
# File 'app/models/concerns/customer_display.rb', line 66 def online? account.present? end |
#product_review_delay_months ⇒ Object
80 81 82 83 84 85 86 |
# File 'app/models/concerns/customer_display.rb', line 80 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
70 71 72 |
# File 'app/models/concerns/customer_display.rb', line 70 def reference_number "CN#{id}" end |
#to_label ⇒ Object
62 63 64 |
# File 'app/models/concerns/customer_display.rb', line 62 def to_label "[CN#{id}] #{full_name}" end |
#to_s ⇒ Object
58 59 60 |
# File 'app/models/concerns/customer_display.rb', line 58 def to_s "#{full_name} [CN#{id}]" end |