Class: Adviser

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Geocodable
Defined in:
app/models/adviser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Geocodable

#coordinates, #coordinates=, #geocode, #geocoded?, included, #latitude=, #longitude=, #needs_to_be_geocoded?, #save_with_geocoding, #update_with_geocoding

Instance Attribute Details

#old_firm_idObject (readonly)

Returns the value of attribute old_firm_id.



4
5
6
# File 'app/models/adviser.rb', line 4

def old_firm_id
  @old_firm_id
end

Class Method Details

.move_all_to_firm(receiving_firm) ⇒ Object



49
50
51
52
53
54
55
# File 'app/models/adviser.rb', line 49

def self.move_all_to_firm(receiving_firm)
  transaction do
    current_scope.each do |adviser|
      adviser.update!(firm: receiving_firm)
    end
  end
end

.on_firms_with_fca_number(fca_number) ⇒ Object



44
45
46
47
# File 'app/models/adviser.rb', line 44

def self.on_firms_with_fca_number(fca_number)
  firms = Firm.where(fca_number: fca_number)
  where(firm: firms)
end

Instance Method Details

#add_geocoding_failed_errorObject



65
66
67
# File 'app/models/adviser.rb', line 65

def add_geocoding_failed_error
  errors.add(:geocoding, I18n.t("#{model_name.i18n_key}.geocoding.failure_message"))
end

#field_orderObject



69
70
71
72
73
74
75
# File 'app/models/adviser.rb', line 69

def field_order
  [
    :reference_number,
    :postcode,
    :travel_distance
  ]
end

#full_street_addressObject



57
58
59
# File 'app/models/adviser.rb', line 57

def full_street_address
  "#{postcode}, United Kingdom"
end

#has_address_changes?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/models/adviser.rb', line 61

def has_address_changes?
  changed_attributes.include? :postcode
end

#notify_indexerObject



40
41
42
# File 'app/models/adviser.rb', line 40

def notify_indexer
  FirmIndexer.handle_aggregate_changed(self)
end