next_sgad 0.1.9 → 0.2.1
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/assessment.rb +2 -0
- data/app/models/next_sgad/attendance.rb +2 -2
- data/app/models/next_sgad/justification.rb +20 -13
- data/db/migrate/20171125001559_add_aproved_by_supervisor_to_next_sgad_justifications.rb +7 -0
- data/lib/next_sgad/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 050bec2ed2ca3a8f135e5614983eb925f702320e
|
4
|
+
data.tar.gz: ad3428de43ae1ed39b2123cc9c2ac4597bc5de3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43b5825ced92095011d4b4a4e8aaa962b02ef77a4f8a2299ac22635d9d184c58b3a186b76bc7db0acef329f347863eda79c428776e3f5fc3fe2b47d03f2aa345
|
7
|
+
data.tar.gz: 4dcefc85db33601f622c556c1c7e1a5db499ef3c41edd566222bc1153b77409d86d0c823373847a68a43f187df78637f03fd60df2134620a29d5454d448b2830
|
@@ -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,
|
9
|
+
enum justification_status: {unjustified: -1, pending: 0, approved: 1, disaproved: 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? ||
|
30
|
+
pending? || approved? || disaproved? || in_progress?
|
31
31
|
end
|
32
32
|
|
33
33
|
def justification
|
@@ -5,21 +5,15 @@ module NextSgad
|
|
5
5
|
belongs_to :employee
|
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
|
-
enum status: {pending: 0,
|
8
|
+
enum status: {pending: 0, approved: 1, disapproved: 2, in_progress: 3}
|
9
|
+
enum first_approval_status: {first_pending: 0, first_approved: 1, first_disapproved: 2}
|
10
|
+
enum second_approval_status: {second_pending: 0, second_approved: 1, second_disapproved: 2}
|
11
|
+
# disapproved if both disapproved
|
12
|
+
# approved if both approved
|
13
|
+
# pending if both pending
|
14
|
+
# in_progress if not first, second nor third
|
9
15
|
attr_accessor :dates
|
10
16
|
|
11
|
-
# Aproves the justification
|
12
|
-
def aprove
|
13
|
-
# 1 stands for aproved therefore justified
|
14
|
-
update(status: 1)
|
15
|
-
end
|
16
|
-
|
17
|
-
# Disaproves the justification
|
18
|
-
def disaprove
|
19
|
-
# 2 stands for unjustified or disaproved
|
20
|
-
update(status: 2)
|
21
|
-
end
|
22
|
-
|
23
17
|
validates_presence_of :employee_id, :attendance_ids
|
24
18
|
validate :validate_attendances_uniqueness, on: :create
|
25
19
|
before_destroy :change_attendances_status_before_destroy
|
@@ -41,6 +35,19 @@ module NextSgad
|
|
41
35
|
end
|
42
36
|
|
43
37
|
def after_save_update_justifications
|
38
|
+
if first_pending? && second_pending?
|
39
|
+
update_columns(status: 0)
|
40
|
+
|
41
|
+
elsif first_approved? && second_approved?
|
42
|
+
update_columns(status: 1)
|
43
|
+
|
44
|
+
elsif first_disapproved? && second_disapproved?
|
45
|
+
update_columns(status: 2)
|
46
|
+
|
47
|
+
else
|
48
|
+
update_columns(status: 3)
|
49
|
+
|
50
|
+
end
|
44
51
|
attendances.where.not(justification_status: status).update_all(justification_status: status)
|
45
52
|
end
|
46
53
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class AddAprovedBySupervisorToNextSgadJustifications < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
add_column :next_sgad_justifications, :first_approval_status, :integer, default: 0, null: false
|
4
|
+
add_column :next_sgad_justifications, :second_approval_status, :integer, default: 0, null: false
|
5
|
+
add_column :next_sgad_employees, :can_approve_justifications, :boolean, default: false, null: false
|
6
|
+
end
|
7
|
+
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.1
|
4
|
+
version: 0.2.1
|
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-
|
11
|
+
date: 2017-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -232,6 +232,7 @@ files:
|
|
232
232
|
- db/migrate/20171115161157_migrate_fill_justification_columns.rb
|
233
233
|
- db/migrate/20171119122339_add_for_everyone_to_next_sgad_goals.rb
|
234
234
|
- db/migrate/20171119152032_create_join_table_goal_function.rb
|
235
|
+
- db/migrate/20171125001559_add_aproved_by_supervisor_to_next_sgad_justifications.rb
|
235
236
|
- lib/concerns/models/employee.rb
|
236
237
|
- lib/generators/initializer/USAGE
|
237
238
|
- lib/generators/initializer/initializer_generator.rb
|