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 Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
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 Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#reason_code ⇒ Object (readonly)
32 |
# File 'app/models/customer_drop_event.rb', line 32 validates :customer, :reason_code, presence: true |
Class Method Details
.closing_condition?(reason_code) ⇒ Boolean
43 44 45 |
# File 'app/models/customer_drop_event.rb', line 43 def self.closing_condition?(reason_code) CLOSING_CONDITIONS.include?(reason_code) end |
.human_reason_name(reason) ⇒ Object
51 52 53 54 55 |
# File 'app/models/customer_drop_event.rb', line 51 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
57 58 59 |
# File 'app/models/customer_drop_event.rb', line 57 def self. REASON_CODES.map { |r| [human_reason_name(r), r] } end |
Instance Method Details
#closing_condition? ⇒ Boolean
35 36 37 |
# File 'app/models/customer_drop_event.rb', line 35 def closing_condition? self.class.closing_condition?(reason_code) end |
#customer ⇒ Customer
Validations:
29 |
# File 'app/models/customer_drop_event.rb', line 29 belongs_to :customer, optional: true |
#reassign_rep? ⇒ Boolean
39 40 41 |
# File 'app/models/customer_drop_event.rb', line 39 def reassign_rep? reason_code == 'reassign_account' end |
#sales_rep ⇒ Employee
30 |
# File 'app/models/customer_drop_event.rb', line 30 belongs_to :sales_rep, class_name: 'Employee', optional: true |
#spam_condition? ⇒ Boolean
47 48 49 |
# File 'app/models/customer_drop_event.rb', line 47 def spam_condition? reason_code == 'fraud' end |