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 =
Closing conditions.
%w[disconnected_number no_longer_in_business fraud].freeze
- REASON_CODES =
Reason codes.
(CLOSING_CONDITIONS + %w[no_potential not_related_to_our_business reassign_account]).freeze
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Constants included from Models::Schedulable
Models::Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
- #reason_code ⇒ String(255) readonly
Belongs to collapse
Methods included from Models::Auditable
Class Method Summary collapse
- .closing_condition?(reason_code) ⇒ Boolean
- .human_reason_name(reason) ⇒ void
- .options_for_select ⇒ void
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::Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#reason_code ⇒ String(255) (readonly)
Validations:
- Inclusion ({ in: REASON_CODES })
37 |
# File 'app/models/customer_drop_event.rb', line 37 validates :reason_code, presence: true |
Class Method Details
.closing_condition?(reason_code) ⇒ Boolean
54 55 56 |
# File 'app/models/customer_drop_event.rb', line 54 def self.closing_condition?(reason_code) CLOSING_CONDITIONS.include?(reason_code) end |
.human_reason_name(reason) ⇒ void
67 68 69 70 71 |
# File 'app/models/customer_drop_event.rb', line 67 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 ⇒ void
This method returns an undefined value.
74 75 76 |
# File 'app/models/customer_drop_event.rb', line 74 def self. REASON_CODES.map { |r| [human_reason_name(r), r] } end |
Instance Method Details
#closing_condition? ⇒ Boolean
41 42 43 |
# File 'app/models/customer_drop_event.rb', line 41 def closing_condition? self.class.closing_condition?(reason_code) end |
#customer ⇒ Object
30 |
# File 'app/models/customer_drop_event.rb', line 30 belongs_to :customer, optional: true |
#reassign_rep? ⇒ Boolean
46 47 48 |
# File 'app/models/customer_drop_event.rb', line 46 def reassign_rep? reason_code == 'reassign_account' end |
#sales_rep ⇒ Employee?
32 |
# File 'app/models/customer_drop_event.rb', line 32 belongs_to :sales_rep, class_name: 'Employee', optional: true |
#spam_condition? ⇒ Boolean
59 60 61 |
# File 'app/models/customer_drop_event.rb', line 59 def spam_condition? reason_code == 'fraud' end |