next_sgad 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/next_sgad/activity.rb +15 -0
- data/app/models/next_sgad/assessment.rb +19 -1
- data/app/models/next_sgad/attendance.rb +2 -2
- data/app/models/next_sgad/department.rb +1 -0
- data/app/models/next_sgad/employee_assessment.rb +7 -7
- data/app/models/next_sgad/goal.rb +41 -5
- data/app/models/next_sgad/justification.rb +29 -4
- data/app/models/next_sgad/position.rb +22 -0
- data/lib/next_sgad/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8696abf88369d8545e21b3b7c2da8670f796b615
|
4
|
+
data.tar.gz: 88fb5d46e63f86adb4a53afe02ea4175ea9d4a12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3342688775504d4a1020213675f1e6ed7cd29db6bf1b2f8d930f0a713f52f96bb58404f0161ca6588902dd4a53d96ccc72849e50b6c9d84ff4b6a5f5874523a
|
7
|
+
data.tar.gz: e5aaeb113fe5eabb200fdd8f34007de3aa02c0ac9dbfd2556808ee58c618e0aa37f19f8ced5338f03503a8f1b4923763ef202d103d62786a201229401d241f2a
|
@@ -1,4 +1,19 @@
|
|
1
1
|
module NextSgad
|
2
2
|
class Activity < ApplicationRecord
|
3
|
+
def self.notification_result_validate(current_user, result)
|
4
|
+
NextSgad::Activity.create(created_by: "#{current_user.first_name} #{current_user.last_name}", description: "Validou resultado")
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.notification_result_invalidate(current_user, result)
|
8
|
+
NextSgad::Activity.create(created_by: "#{current_user.first_name} #{current_user.last_name}", description: "Invalidou resultado")
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.notification_new_result(current_user, result)
|
12
|
+
NextSgad::Activity.create(created_by: "#{current_user.first_name} #{current_user.last_name}", description: "Adicionou novo resultado")
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.notification_destroy_result(current_user, result)
|
16
|
+
NextSgad::Activity.create(created_by: "#{current_user.first_name} #{current_user.last_name}", description: "Removido resultado")
|
17
|
+
end
|
3
18
|
end
|
4
19
|
end
|
@@ -15,6 +15,25 @@ module NextSgad
|
|
15
15
|
|
16
16
|
after_create :create_employees_assessments
|
17
17
|
|
18
|
+
# get the last years assessment
|
19
|
+
def get_last_assessment
|
20
|
+
NextSgad::Assessment.find_by(year: year - 1)
|
21
|
+
end
|
22
|
+
|
23
|
+
# check if last year assessments can be copied
|
24
|
+
def can_copy_last_years_skills?
|
25
|
+
last_years_skills= get_last_assessment
|
26
|
+
return false if last_years_skills.nil?
|
27
|
+
last_years_skills.goals.skill.where.not(name: goals.skill.map(&:name)).exists?
|
28
|
+
end
|
29
|
+
|
30
|
+
# get last years skills
|
31
|
+
def dup_last_year_skills
|
32
|
+
last_years_skills= get_last_assessment
|
33
|
+
return NextSgad::Goal.none if last_years_skills.nil?
|
34
|
+
last_years_skills.goals.skill.where.not(name: goals.skill.map(&:name)).map {|g| d = g.dup; d.function_ids = g.function_ids; d}
|
35
|
+
end
|
36
|
+
|
18
37
|
def employee_assessment(employee)
|
19
38
|
(skills_assessment(employee) + objectives_assessment(employee) + attendance_assessment(employee)).round(1)
|
20
39
|
end
|
@@ -114,7 +133,6 @@ module NextSgad
|
|
114
133
|
|
115
134
|
data[month] = [attendances_array_by_month.size, attendances_array_by_month.select(&:has_justification?).size, (attendance_percentage/100) * attendance_assessment_value]
|
116
135
|
end
|
117
|
-
p data
|
118
136
|
return data
|
119
137
|
end
|
120
138
|
|
@@ -6,7 +6,7 @@ module NextSgad
|
|
6
6
|
belongs_to :department, optional: true
|
7
7
|
has_and_belongs_to_many :justifications, association_foreign_key: :next_sgad_justification_id, foreign_key: :next_sgad_attendance_id
|
8
8
|
enum status: {four_hours_late: -4, three_hours_late: -3, two_hours_late: -2, one_hour_late: -1, presence: 0, absence: 1, vacation: 2, authorized_leave: 3}
|
9
|
-
enum justification_status: {unjustified: -1, pending: 0, approved: 1,
|
9
|
+
enum justification_status: {unjustified: -1, pending: 0, approved: 1, disapproved: 2, in_progress: 3}
|
10
10
|
validates :status, :date ,:employee_id, presence: true
|
11
11
|
validate :assessment_date
|
12
12
|
before_create :check_employee_data
|
@@ -27,7 +27,7 @@ module NextSgad
|
|
27
27
|
|
28
28
|
# true if an attendace has justification
|
29
29
|
def has_justification?
|
30
|
-
pending? || approved? ||
|
30
|
+
pending? || approved? || disapproved? || in_progress?
|
31
31
|
end
|
32
32
|
|
33
33
|
def justification
|
@@ -15,7 +15,7 @@ module NextSgad
|
|
15
15
|
NextSgad::EmployeeGoal.where(assessment_id: assessment_id, employee_id: employee_id)
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
private
|
19
19
|
def update_statuses
|
20
20
|
goals = employee_goals()
|
21
21
|
hash = {}
|
@@ -24,10 +24,10 @@ module NextSgad
|
|
24
24
|
hash[:self_assessment_status] = 0
|
25
25
|
# pending
|
26
26
|
elsif goals.where(self_assessment: 0).exists?
|
27
|
-
hash[:
|
27
|
+
hash[:self_assessment_status] = 1
|
28
28
|
# in_progress
|
29
29
|
else
|
30
|
-
hash[:
|
30
|
+
hash[:self_assessment_status] = 2
|
31
31
|
# completed
|
32
32
|
end
|
33
33
|
|
@@ -35,10 +35,10 @@ module NextSgad
|
|
35
35
|
hash[:supervisor_assessment_status] = 0
|
36
36
|
# pending
|
37
37
|
elsif goals.where(supervisor_assessment: 0).exists?
|
38
|
-
hash[:
|
38
|
+
hash[:supervisor_assessment_status] = 1
|
39
39
|
# in_progress
|
40
40
|
else
|
41
|
-
hash[:
|
41
|
+
hash[:supervisor_assessment_status] = 2
|
42
42
|
# completed
|
43
43
|
end
|
44
44
|
|
@@ -46,10 +46,10 @@ module NextSgad
|
|
46
46
|
hash[:final_assessment_status] = 0
|
47
47
|
# pending
|
48
48
|
elsif goals.where(final_assessment: 0).exists?
|
49
|
-
hash[:
|
49
|
+
hash[:final_assessment_status] = 1
|
50
50
|
# in_progress
|
51
51
|
else
|
52
|
-
hash[:
|
52
|
+
hash[:final_assessment_status] = 2
|
53
53
|
# completed
|
54
54
|
end
|
55
55
|
|
@@ -15,10 +15,10 @@ module NextSgad
|
|
15
15
|
#validates :name, uniqueness: {scope: [:assessment_id]}
|
16
16
|
after_save :create_employee_goals
|
17
17
|
|
18
|
-
|
18
|
+
|
19
19
|
def create_employee_goals
|
20
|
-
|
21
|
-
|
20
|
+
# Update existing
|
21
|
+
employee_goals.each do |employee_goal|
|
22
22
|
eg = NextSgad::EmployeeGoal.new
|
23
23
|
eg.status = status
|
24
24
|
eg.goal_type = goal_type
|
@@ -28,10 +28,46 @@ module NextSgad
|
|
28
28
|
eg.target = target
|
29
29
|
eg.assessment_id = assessment_id
|
30
30
|
eg.goal_id = id
|
31
|
-
eg.employee_id = position.efective_id
|
32
|
-
eg.position_id = position.id
|
33
31
|
eg.save
|
34
32
|
end
|
33
|
+
if skill?
|
34
|
+
# create new
|
35
|
+
positions_to = for_everyone ? NextSgad::Position.all.where.not(efective_id: nil) : NextSgad::Position.where(function_id: function_ids).where.not(efective_id: nil)
|
36
|
+
positions_to.each do |position|
|
37
|
+
next if position.efective_id.nil?
|
38
|
+
eg = NextSgad::EmployeeGoal.new
|
39
|
+
eg.status = status
|
40
|
+
eg.goal_type = goal_type
|
41
|
+
eg.name = name
|
42
|
+
eg.unit = unit
|
43
|
+
eg.nature = nature
|
44
|
+
eg.target = target
|
45
|
+
eg.assessment_id = assessment_id
|
46
|
+
eg.goal_id = id
|
47
|
+
eg.employee_id = position.efective_id
|
48
|
+
eg.position_id = position.id
|
49
|
+
eg.save
|
50
|
+
end
|
51
|
+
|
52
|
+
elsif objective?
|
53
|
+
positions_to = for_everyone ? NextSgad::Position.all.where.not(efective_id: nil) : positions
|
54
|
+
positions_to.each do |position|
|
55
|
+
next if position.efective_id.nil?
|
56
|
+
eg = NextSgad::EmployeeGoal.new
|
57
|
+
eg.status = status
|
58
|
+
eg.goal_type = goal_type
|
59
|
+
eg.name = name
|
60
|
+
eg.unit = unit
|
61
|
+
eg.nature = nature
|
62
|
+
eg.target = target
|
63
|
+
eg.assessment_id = assessment_id
|
64
|
+
eg.goal_id = id
|
65
|
+
eg.employee_id = position.efective_id
|
66
|
+
eg.position_id = position.id
|
67
|
+
eg.save
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
35
71
|
end
|
36
72
|
|
37
73
|
end
|
@@ -6,14 +6,39 @@ module NextSgad
|
|
6
6
|
# belongs_to :department
|
7
7
|
has_and_belongs_to_many :attendances, association_foreign_key: :next_sgad_attendance_id, foreign_key: :next_sgad_justification_id
|
8
8
|
enum status: {pending: 0, approved: 1, disapproved: 2, in_progress: 3}
|
9
|
-
enum first_approval_status: {
|
10
|
-
enum second_approval_status: {
|
9
|
+
enum first_approval_status: {pending: 0, approved: 1, disapproved: 2}, _prefix: :first
|
10
|
+
enum second_approval_status: {pending: 0, approved: 1, disapproved: 2}, _prefix: :second
|
11
11
|
# disapproved if both disapproved
|
12
12
|
# approved if both approved
|
13
13
|
# pending if both pending
|
14
14
|
# in_progress if not first, second nor third
|
15
15
|
attr_accessor :dates
|
16
16
|
|
17
|
+
# gives first approval
|
18
|
+
def first_approve
|
19
|
+
update(first_approval_status: 1)
|
20
|
+
end
|
21
|
+
|
22
|
+
# gives second approval
|
23
|
+
def second_approve
|
24
|
+
update(second_approval_status: 1)
|
25
|
+
end
|
26
|
+
|
27
|
+
# gives first approval
|
28
|
+
def first_disapprove
|
29
|
+
update(first_approval_status: 2)
|
30
|
+
end
|
31
|
+
|
32
|
+
# gives second disapproval
|
33
|
+
def second_disapprove
|
34
|
+
update(second_approval_status: 2)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Return an arrays of dates associated to this justification
|
38
|
+
def days
|
39
|
+
attendances.order(date: :asc).map(&:date)
|
40
|
+
end
|
41
|
+
|
17
42
|
validates_presence_of :employee_id, :attendance_ids
|
18
43
|
validate :validate_attendances_uniqueness, on: :create
|
19
44
|
before_destroy :change_attendances_status_before_destroy
|
@@ -46,9 +71,9 @@ module NextSgad
|
|
46
71
|
|
47
72
|
else
|
48
73
|
update_columns(status: 3)
|
49
|
-
|
74
|
+
|
50
75
|
end
|
51
|
-
attendances.where.not(justification_status: status).update_all(justification_status: status)
|
76
|
+
attendances.where.not(justification_status: status).update_all(justification_status: NextSgad::Justification.statuses[status])
|
52
77
|
end
|
53
78
|
end
|
54
79
|
end
|
@@ -25,6 +25,9 @@ module NextSgad
|
|
25
25
|
validates_uniqueness_of :efective_id
|
26
26
|
before_save :create_number, on: :create
|
27
27
|
before_save :saves_employees
|
28
|
+
after_create :create_goals_after_create
|
29
|
+
validates_presence_of :function_id
|
30
|
+
validates_uniqueness_of :number, if: -> (f) {f.number.present?}, on: :create
|
28
31
|
|
29
32
|
private
|
30
33
|
def saves_employees
|
@@ -32,5 +35,24 @@ module NextSgad
|
|
32
35
|
self.employee_ids = self.employee_ids.compact.uniq
|
33
36
|
end
|
34
37
|
|
38
|
+
def create_goals_after_create
|
39
|
+
assessm = NextSgad::Assessment.active.last
|
40
|
+
return if assessm.nil? || function_id.nil? || efective_id.nil?
|
41
|
+
function.goals.where(assessment_id: assessm.id).each do |goal|
|
42
|
+
eg = NextSgad::EmployeeGoal.new
|
43
|
+
eg.status = goal.status
|
44
|
+
eg.goal_type = goal.goal_type
|
45
|
+
eg.name = goal.name
|
46
|
+
eg.unit = goal.unit
|
47
|
+
eg.nature = goal.nature
|
48
|
+
eg.target = goal.target
|
49
|
+
eg.assessment_id = goal.assessment_id
|
50
|
+
eg.goal_id = goal.id
|
51
|
+
eg.employee_id = efective_id
|
52
|
+
eg.position_id = id
|
53
|
+
eg.save
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
35
57
|
end
|
36
58
|
end
|
data/lib/next_sgad/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: next_sgad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Maziano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -266,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
266
|
version: '0'
|
267
267
|
requirements: []
|
268
268
|
rubyforge_project:
|
269
|
-
rubygems_version: 2.6.
|
269
|
+
rubygems_version: 2.6.10
|
270
270
|
signing_key:
|
271
271
|
specification_version: 4
|
272
272
|
summary: SGAD
|