Class: Principal

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/principal.rb

Instance Method Summary collapse

Instance Method Details

#field_orderObject



50
51
52
53
54
55
56
57
58
59
60
# File 'app/models/principal.rb', line 50

def field_order
  [
    :fca_number,
    :first_name,
    :last_name,
    :job_title,
    :email_address,
    :telephone_number,
    :confirmed_disclaimer
  ]
end

#find_or_create_subsidiary(id) ⇒ Object



62
63
64
65
66
67
68
# File 'app/models/principal.rb', line 62

def find_or_create_subsidiary(id)
  subsidiary = lookup_firm.subsidiaries.find(id)

  find_subsidiary(subsidiary).tap do |firm|
    firm.save(validate: false) unless firm.persisted?
  end
end

#full_nameObject



70
71
72
# File 'app/models/principal.rb', line 70

def full_name
  "#{first_name} #{last_name}"
end

#lookup_firmObject



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

def lookup_firm
  @lookup_firm ||= Lookup::Firm.find_by(fca_number: fca_number)
end

#main_firm_with_trading_namesObject



36
37
38
# File 'app/models/principal.rb', line 36

def main_firm_with_trading_names
  Firm.where(fca_number: fca_number)
end

#onboarded?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'app/models/principal.rb', line 74

def onboarded?
  main_firm_with_trading_names.any?(&:publishable?)
end

#to_paramObject



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

def to_param
  token.parameterize
end