Class: Models::Employee
- Inherits:
-
Base
- Object
- Base
- Models::Employee
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_pay ⇒ Object
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)
payroll.salary.payment.sub(currency, '').to_f
end
|
#city ⇒ Object
45
46
47
|
# File 'lib/bob/models/employee.rb', line 45
def city
address.city
end
|
#cost_center ⇒ Object
97
98
99
|
# File 'lib/bob/models/employee.rb', line 97
def cost_center
dig_custom_field('COST_CENTER')
end
|
#country ⇒ Object
49
50
51
|
# File 'lib/bob/models/employee.rb', line 49
def country
address&.country
end
|
#currency ⇒ Object
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
|
#department ⇒ Object
29
30
31
|
# File 'lib/bob/models/employee.rb', line 29
def department
work.try(:department)
end
|
#division ⇒ Object
33
34
35
|
# File 'lib/bob/models/employee.rb', line 33
def division
dig_custom_field('DIVISION')
end
|
#entity ⇒ Object
41
42
43
|
# File 'lib/bob/models/employee.rb', line 41
def entity
dig_custom_field('EMPLOYER')
end
|
#fourth_level_manager ⇒ Object
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
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
53
54
55
|
# File 'lib/bob/models/employee.rb', line 53
def has_manager?
manager.present?
end
|
#has_second_level_manager? ⇒ 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
77
78
79
|
# File 'lib/bob/models/employee.rb', line 77
def has_third_level_manager?
third_level_manager.present?
end
|
#job_grade ⇒ Object
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_id ⇒ Object
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_row ⇒ Object
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_title ⇒ Object
21
22
23
|
# File 'lib/bob/models/employee.rb', line 21
def job_title
work.title
end
|
#linkedin_profile ⇒ Object
105
106
107
|
# File 'lib/bob/models/employee.rb', line 105
def linkedin_profile
about.social_data&.linkedin
end
|
#manager ⇒ Object
57
58
59
60
61
|
# File 'lib/bob/models/employee.rb', line 57
def manager
return unless manager_email
@manager ||= Bob::Employees.find(manager_email)
end
|
#manager? ⇒ Boolean
17
18
19
|
# File 'lib/bob/models/employee.rb', line 17
def manager?
work.is_manager
end
|
#manager_email ⇒ Object
63
64
65
|
# File 'lib/bob/models/employee.rb', line 63
def manager_email
try(:work).try(:reports_to).try(:email)
end
|
#personal_email ⇒ Object
101
102
103
|
# File 'lib/bob/models/employee.rb', line 101
def personal_email
home.private_email
end
|
#preferred_first_name ⇒ Object
9
10
11
|
# File 'lib/bob/models/employee.rb', line 9
def preferred_first_name
dig_custom_field('PREFERRED_FIRST_NAME')
end
|
#preferred_full_name ⇒ Object
13
14
15
|
# File 'lib/bob/models/employee.rb', line 13
def preferred_full_name
"#{preferred_first_name} #{preferred_last_name}"
end
|
#preferred_last_name ⇒ Object
5
6
7
|
# File 'lib/bob/models/employee.rb', line 5
def preferred_last_name
dig_custom_field('PREFERRED_LAST_NAME')
end
|
#second_level_manager ⇒ Object
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_date ⇒ Object
25
26
27
|
# File 'lib/bob/models/employee.rb', line 25
def start_date
work.start_date
end
|
#team ⇒ Object
37
38
39
|
# File 'lib/bob/models/employee.rb', line 37
def team
dig_custom_field('SUB_DIVISION')
end
|
#third_level_manager ⇒ Object
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_pay ⇒ Object
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
|