Class: Models::Employee

Inherits:
Base
  • Object
show all
Defined in:
lib/bob/models/employee.rb

Instance Method Summary collapse

Methods inherited from Base

#dig_custom_field, #initialize

Constructor Details

This class inherits a constructor from Models::Base

Instance Method Details

#base_payObject



115
116
117
118
119
120
# File 'lib/bob/models/employee.rb', line 115

def base_pay
  return nil unless payroll.try(:salary).try(:payment)

  # split on first occurence of a digit
  payroll.salary.payment.sub(currency, '').to_f
end

#cityObject



45
46
47
# File 'lib/bob/models/employee.rb', line 45

def city
  address.city
end

#cost_centerObject



97
98
99
# File 'lib/bob/models/employee.rb', line 97

def cost_center
  dig_custom_field('COST_CENTER')
end

#countryObject



49
50
51
# File 'lib/bob/models/employee.rb', line 49

def country
  address&.country
end

#currencyObject



109
110
111
112
113
# File 'lib/bob/models/employee.rb', line 109

def currency
  return nil unless payroll.try(:salary).try(:payment)

  payroll.salary.payment.split(/\d/).first
end

#departmentObject



29
30
31
# File 'lib/bob/models/employee.rb', line 29

def department
  work.try(:department)
end

#divisionObject



33
34
35
# File 'lib/bob/models/employee.rb', line 33

def division
  dig_custom_field('DIVISION')
end

#entityObject



41
42
43
# File 'lib/bob/models/employee.rb', line 41

def entity
  dig_custom_field('EMPLOYER')
end

#fourth_level_managerObject



91
92
93
94
95
# File 'lib/bob/models/employee.rb', line 91

def fourth_level_manager
  return nil unless third_level_manager.manager_email

  Bob::Employees.find(third_level_manager.manager_email)
end

#has_fourth_level_manager?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/bob/models/employee.rb', line 87

def has_fourth_level_manager?
  second_level_manager.work&.second_level_manager.present?
end

#has_manager?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/bob/models/employee.rb', line 53

def has_manager?
  manager.present?
end

#has_second_level_manager?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/bob/models/employee.rb', line 67

def has_second_level_manager?
  work&.second_level_manager.present?
end

#has_third_level_manager?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/bob/models/employee.rb', line 77

def has_third_level_manager?
  third_level_manager.present?
end

#job_gradeObject



135
136
137
138
139
# File 'lib/bob/models/employee.rb', line 135

def job_grade
  return nil if job_role_row.nil?

  job_role_row.human_readable.column_1716393179800
end

#job_role_idObject



141
142
143
144
145
# File 'lib/bob/models/employee.rb', line 141

def job_role_id
  return nil if job_role_row.nil?

  job_role_row.human_readable.column_1716393584611
end

#job_role_rowObject



128
129
130
131
132
133
# File 'lib/bob/models/employee.rb', line 128

def job_role_row
  @job_role_row ||= Bob::Employee::CustomTables.rows(id,
                                                     'category_1645574919835__table_1716392607454').max_by do |row|
    Date.parse(row.column_1716392634939)
  end
end

#job_titleObject



21
22
23
# File 'lib/bob/models/employee.rb', line 21

def job_title
  work.title
end

#linkedin_profileObject



105
106
107
# File 'lib/bob/models/employee.rb', line 105

def linkedin_profile
  about.social_data&.linkedin
end

#managerObject



57
58
59
60
61
# File 'lib/bob/models/employee.rb', line 57

def manager
  return unless manager_email # has no manager, prob CEO

  @manager ||= Bob::Employees.find(manager_email)
end

#manager?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/bob/models/employee.rb', line 17

def manager?
  work.is_manager
end

#manager_emailObject



63
64
65
# File 'lib/bob/models/employee.rb', line 63

def manager_email
  try(:work).try(:reports_to).try(:email)
end

#personal_emailObject



101
102
103
# File 'lib/bob/models/employee.rb', line 101

def personal_email
  home.private_email
end

#preferred_first_nameObject



9
10
11
# File 'lib/bob/models/employee.rb', line 9

def preferred_first_name
  dig_custom_field('PREFERRED_FIRST_NAME')
end

#preferred_full_nameObject



13
14
15
# File 'lib/bob/models/employee.rb', line 13

def preferred_full_name
  "#{preferred_first_name} #{preferred_last_name}"
end

#preferred_last_nameObject



5
6
7
# File 'lib/bob/models/employee.rb', line 5

def preferred_last_name
  dig_custom_field('PREFERRED_LAST_NAME')
end

#second_level_managerObject



71
72
73
74
75
# File 'lib/bob/models/employee.rb', line 71

def second_level_manager
  return nil unless manager.manager_email

  @second_level_manager ||= Bob::Employees.find(manager.manager_email)
end

#start_dateObject



25
26
27
# File 'lib/bob/models/employee.rb', line 25

def start_date
  work.start_date
end

#teamObject



37
38
39
# File 'lib/bob/models/employee.rb', line 37

def team
  dig_custom_field('SUB_DIVISION')
end

#third_level_managerObject



81
82
83
84
85
# File 'lib/bob/models/employee.rb', line 81

def third_level_manager
  return nil unless second_level_manager.manager_email

  @third_level_manager ||= Bob::Employees.find(second_level_manager.manager_email)
end

#variable_payObject



122
123
124
125
126
# File 'lib/bob/models/employee.rb', line 122

def variable_pay
  return 0.0 unless payroll.try(:variable)&.field_255298499&.amount

  payroll.variable.field_255298499.amount.sub(currency, '').to_f
end