Class: CustomerDropEvent
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- CustomerDropEvent
- Includes:
- Models::Auditable
- Defined in:
- app/models/customer_drop_event.rb
Overview
== Schema Information
Table name: customer_drop_events
Database name: primary
id :integer not null, primary key
comment :text
reason_code :string(255)
created_at :datetime
updated_at :datetime
creator_id :integer
customer_id :integer not null
sales_rep_id :integer
updater_id :integer
Indexes
index_customer_drop_events_on_customer_id (customer_id)
Constant Summary collapse
- CLOSING_CONDITIONS =
%w[disconnected_number no_longer_in_business fraud].freeze
- REASON_CODES =
(CLOSING_CONDITIONS + %w[no_potential not_related_to_our_business reassign_account]).freeze
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Instance Attribute Summary collapse
- #reason_code ⇒ Object readonly
Belongs to collapse
Methods included from Models::Auditable
Class Method Summary collapse
- .closing_condition?(reason_code) ⇒ Boolean
- .human_reason_name(reason) ⇒ Object
- .options_for_select ⇒ Object
Instance Method Summary collapse
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Instance Attribute Details
#reason_code ⇒ Object (readonly)
29 |
# File 'app/models/customer_drop_event.rb', line 29 validates :customer, :reason_code, presence: true |
Class Method Details
.closing_condition?(reason_code) ⇒ Boolean
40 41 42 |
# File 'app/models/customer_drop_event.rb', line 40 def self.closing_condition?(reason_code) CLOSING_CONDITIONS.include?(reason_code) end |
.human_reason_name(reason) ⇒ Object
48 49 50 51 52 |
# File 'app/models/customer_drop_event.rb', line 48 def self.human_reason_name(reason) r = { 'fraud' => 'Fraud or Spam' }[reason] || reason.dup.humanize.titleize r << ' (Close Account)' if reason.in?(CLOSING_CONDITIONS) r end |
.options_for_select ⇒ Object
54 55 56 |
# File 'app/models/customer_drop_event.rb', line 54 def self. REASON_CODES.map { |r| [human_reason_name(r), r] } end |
Instance Method Details
#closing_condition? ⇒ Boolean
32 33 34 |
# File 'app/models/customer_drop_event.rb', line 32 def closing_condition? self.class.closing_condition?(reason_code) end |
#customer ⇒ Customer
Validations:
26 |
# File 'app/models/customer_drop_event.rb', line 26 belongs_to :customer, optional: true |
#reassign_rep? ⇒ Boolean
36 37 38 |
# File 'app/models/customer_drop_event.rb', line 36 def reassign_rep? reason_code == 'reassign_account' end |
#sales_rep ⇒ Employee
27 |
# File 'app/models/customer_drop_event.rb', line 27 belongs_to :sales_rep, class_name: 'Employee', optional: true |
#spam_condition? ⇒ Boolean
44 45 46 |
# File 'app/models/customer_drop_event.rb', line 44 def spam_condition? reason_code == 'fraud' end |