ecom_core 1.1.17 → 1.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/ecom/core/attendance_sheet.rb +17 -11
- data/app/models/ecom/core/crew_overtime.rb +1 -1
- data/app/models/ecom/core/overtime_sheet.rb +11 -2
- data/app/models/ecom/core/overtime_sheet_entry.rb +1 -0
- data/app/models/ecom/core/user.rb +1 -1
- data/lib/ecom/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbaba2b0f521af3d18d5636be2e3be40c6de15aa9f3951b5c3d8b57bdc634e83
|
4
|
+
data.tar.gz: 24ab07446617733ce416002684e0565f4bb04e66ad0a30d0b28d1f1cd79cf9a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88dc9269297366e77f415c768da3bb457414b57143f3aef34df98cbbc3923ac7a125f4bec6005f0f46ff071a64dfabb2295c91931b1033ad872f02cfc5100e04
|
7
|
+
data.tar.gz: cec52dafb2589e7711300bd0322425be7c670ee83bc440def6f26ee6663f10edf6fd1b4231327e28603e9e6bcea95e09e1635c6ce97dda774f69cdea736f58e7
|
@@ -10,19 +10,24 @@ module Ecom
|
|
10
10
|
|
11
11
|
has_many :attendance_sheet_entries
|
12
12
|
|
13
|
-
scope :open, -> {
|
14
|
-
scope :
|
13
|
+
scope :open, -> { where(status: OPEN) }
|
14
|
+
scope :current, -> { where(date: Date.today) }
|
15
|
+
scope :current_open, -> { open.current }
|
16
|
+
|
17
|
+
def self.open_for_date(date)
|
18
|
+
AttendanceSheet.find_by(status: OPEN, date: date)
|
19
|
+
end
|
15
20
|
|
16
21
|
def self.open_exists?
|
17
|
-
AttendanceSheet.
|
22
|
+
AttendanceSheet.open.exists?
|
18
23
|
end
|
19
24
|
|
20
25
|
def self.exists_for_today?
|
21
|
-
AttendanceSheet.
|
26
|
+
AttendanceSheet.current.exists?
|
22
27
|
end
|
23
28
|
|
24
29
|
def self.open_exists_for_today?
|
25
|
-
|
30
|
+
AttendanceSheet.current_open.exists?
|
26
31
|
end
|
27
32
|
|
28
33
|
# Attendance sheet should be created using the
|
@@ -53,13 +58,14 @@ module Ecom
|
|
53
58
|
# to submit the attendance sheet after the date has
|
54
59
|
# passed. Normally, timekeepers need to open and close
|
55
60
|
# an attendance sheet of a date on the specific date.
|
56
|
-
def submit
|
57
|
-
|
61
|
+
def self.submit(date)
|
62
|
+
sheet = AttendanceSheet.open_for_date(date)
|
63
|
+
raise 'There is no open attendance sheet to submit for the selected day.' unless sheet
|
58
64
|
|
59
|
-
|
60
|
-
|
61
|
-
save
|
62
|
-
|
65
|
+
sheet.closed_at = Time.now
|
66
|
+
sheet.status = SUBMITTED
|
67
|
+
sheet.save
|
68
|
+
sheet
|
63
69
|
end
|
64
70
|
end
|
65
71
|
end
|
@@ -6,7 +6,7 @@ module Ecom
|
|
6
6
|
belongs_to :revision_to, class_name: 'Ecom::Core::CrewOvertime', optional: true
|
7
7
|
belongs_to :created_by, class_name: 'Ecom::Core::User'
|
8
8
|
|
9
|
-
has_one :revision, class_name: 'Ecom::Core::CrewOvertime'
|
9
|
+
has_one :revision, class_name: 'Ecom::Core::CrewOvertime', foreign_key: :revision_to_id
|
10
10
|
|
11
11
|
validates :hours, :converted_hours, presence: true
|
12
12
|
|
@@ -10,10 +10,15 @@ module Ecom
|
|
10
10
|
|
11
11
|
has_many :overtime_sheet_entries
|
12
12
|
|
13
|
-
scope :open, -> {
|
13
|
+
scope :open, -> { where(status: OPEN) }
|
14
|
+
scope :for_date, ->(date) { where(date: date) }
|
14
15
|
|
15
16
|
def self.open_exists?
|
16
|
-
OvertimeSheet.
|
17
|
+
OvertimeSheet.open.exists?
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.open_for_date_exists?(date)
|
21
|
+
OvertimeSheet.open.for_date(date).exists?
|
17
22
|
end
|
18
23
|
|
19
24
|
# Overtime sheet should be created using the
|
@@ -22,6 +27,10 @@ module Ecom
|
|
22
27
|
# and also that we have only one open overtime
|
23
28
|
# sheet at a time.
|
24
29
|
def self.create_new(date)
|
30
|
+
if OvertimeSheet.open_for_date_exists?(date)
|
31
|
+
raise 'There is already an open overtime sheet for the selected date.'
|
32
|
+
end
|
33
|
+
|
25
34
|
if OvertimeSheet.open_exists?
|
26
35
|
raise 'There is already an open overtime sheet. It has to be submitted before creating a new one.'
|
27
36
|
end
|
@@ -6,7 +6,7 @@ module Ecom
|
|
6
6
|
has_and_belongs_to_many :user_roles, join_table: 'ecom_core_users_user_roles'
|
7
7
|
|
8
8
|
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i.freeze
|
9
|
-
validates :first_name, :last_name,
|
9
|
+
validates :first_name, :last_name, presence: true
|
10
10
|
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false }
|
11
11
|
validates :password, presence: true, length: { minimum: 6 }, confirmation: true, if: :password
|
12
12
|
|
data/lib/ecom/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecom_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|