ecom_core 1.2.18 → 1.2.19
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/ecom/core/crew_time.rb +3 -3
- data/app/models/ecom/core/overtime_sheet.rb +6 -2
- data/lib/ecom/core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dec564e431b435c4775432757843f7d46c2c98d0c3858bb783e8325b630ba84f
|
4
|
+
data.tar.gz: 6831882fb350c6d92d1324a7f6d3fcf6a95ec334af3b551b11b6e24c93c29c75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9043260a84f6ad95cb2e3ba02329f50bb60a98159b143e58db19c5273bacc1d15d6df538ee460ded92e519071741ac32e6003ec29ae659548109d806ea50d36
|
7
|
+
data.tar.gz: 0e280d833e3b19ce2c87ec29f3d7880e20d015e712c289c027785c885bb8b3b601e8347ecf1290ac26bd14c5b7ccc8cae7fbbc2ecb911b3ef0f2cd97d03f87ba
|
@@ -52,7 +52,7 @@ module Ecom
|
|
52
52
|
# the parsing should be done at the exact moment we are about
|
53
53
|
# to do time range calculations to avoid errors caused by date
|
54
54
|
# mismatches
|
55
|
-
def
|
55
|
+
def define_range
|
56
56
|
morning = {
|
57
57
|
start: Time.zone.parse('5:00 AM'),
|
58
58
|
finish: Time.zone.parse('9:00 AM')
|
@@ -76,7 +76,7 @@ module Ecom
|
|
76
76
|
# A method to check if checkin and checkout range falls in the morning,
|
77
77
|
# afternoon, or both.
|
78
78
|
def find_range(start, finish)
|
79
|
-
range =
|
79
|
+
range = define_range
|
80
80
|
if start.before?(range[:morning][:finish]) && finish.before?(range[:afternoon][:start])
|
81
81
|
:morning
|
82
82
|
elsif start.after?(range[:morning][:finish]) && finish.after?(range[:afternoon][:start])
|
@@ -90,7 +90,7 @@ module Ecom
|
|
90
90
|
# of the defined morning and afternoon ranges
|
91
91
|
def compute_hours
|
92
92
|
# Reparse time to avoid errors caused by date differences
|
93
|
-
range =
|
93
|
+
range = define_range
|
94
94
|
start = Time.zone.parse(checkin_time.strftime('%I:%M%p'))
|
95
95
|
finish = Time.zone.parse(checkout_time.strftime('%I:%M%p'))
|
96
96
|
day_part = find_range(start, finish)
|
@@ -24,14 +24,18 @@ module Ecom
|
|
24
24
|
OvertimeSheet.open(project_id).where(date: date).exists?
|
25
25
|
end
|
26
26
|
|
27
|
+
def self.exists_for_date?(date, project_id)
|
28
|
+
OvertimeSheet.by_project(project_id).by_date(date).exists?
|
29
|
+
end
|
30
|
+
|
27
31
|
# Overtime sheet should be created using the
|
28
32
|
# method below only. This is because we need to
|
29
33
|
# check if there is an open overtime already,
|
30
34
|
# and also that we have only one open overtime
|
31
35
|
# sheet at a time.
|
32
36
|
def self.create_new(date, project_id)
|
33
|
-
if OvertimeSheet.
|
34
|
-
raise 'There is already an
|
37
|
+
if OvertimeSheet.exists_for_date?(date, project_id)
|
38
|
+
raise 'There is already an overtime sheet for the selected date.'
|
35
39
|
end
|
36
40
|
|
37
41
|
if OvertimeSheet.open_exists?(project_id)
|
data/lib/ecom/core/version.rb
CHANGED