ecom_core 1.1.28 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21ff3e5fd4fd9cccdf472a8b779a62617a627f1d7f5bd5ae394f0f2d36b94aa3
4
- data.tar.gz: 501972e9b2abcf95aa11ad02c341cc3cdca42c71d248667ebb35834eceb588f1
3
+ metadata.gz: 7c880918c195007a5c24b11ac57b0160a2cb0f4004b14b859c393865537e484a
4
+ data.tar.gz: 5cd617cb086e5eced01b34ee17744562ebd09a6b292cd87b04539fd991c23a8d
5
5
  SHA512:
6
- metadata.gz: 40e7462b2ebf07a06465f3b19c20389c3a4c8198c045f83bc153875b38270969d4bdad0fccf19581d93ccd9ea4472ae208f0edb73251114ada294c51329dfdc0
7
- data.tar.gz: 56720e59765d12b7c12c219f0b13ca942c82122b32abf573ee3c040444b458e5a3ce18c91813779665a02fdff0c9d8642bc5ddf6233d252db15864a948c3c49c
6
+ metadata.gz: 7dce9a7cad7872a933db194376bf18f827b250db066125b4806e17078136263e9870cb1cac44f9569304317cfcd615de4f75c7cae642c5df1cfa664f013f2cc5
7
+ data.tar.gz: feec5c565c568e36611345e6c672dd5c730f236ee1b4d732856c072e6e1afb7b6bdd7d4ac8776608298348c74e1b41a126eb7300020a92b4db01e70af4c6d9e4
@@ -5,7 +5,7 @@ module Ecom
5
5
  SUBMITTED = 'Submitted'.freeze
6
6
  APPROVED = 'Approved'.freeze
7
7
 
8
- validates :date, :opened_at, presence: true, uniqueness: true
8
+ validates :date, presence: true, uniqueness: true
9
9
  validates :status, inclusion: [OPEN, SUBMITTED, APPROVED]
10
10
 
11
11
  has_many :attendance_sheet_entries
@@ -27,10 +27,10 @@ module Ecom
27
27
 
28
28
  # A method to check if checkin and checkout range falls in the morning,
29
29
  # afternoon, or both.
30
- def find_range
31
- if checkin_time.before?(TIME_RANGE[MORNING][:end]) && checkout_time.before?(TIME_RANGE[AFTERNOON][:start])
30
+ def find_range(start, finish)
31
+ if start.before?(TIME_RANGE[MORNING][:end]) && finish.before?(TIME_RANGE[AFTERNOON][:start])
32
32
  MORNING
33
- elsif checkin_time.after?(TIME_RANGE[MORNING][:end]) && checkout_time.after?(TIME_RANGE[AFTERNOON][:start])
33
+ elsif start.after?(TIME_RANGE[MORNING][:end]) && finish.after?(TIME_RANGE[AFTERNOON][:start])
34
34
  AFTERNOON
35
35
  else
36
36
  BOTH
@@ -40,9 +40,12 @@ module Ecom
40
40
  # A method to adjust time ranges by trimming any time value outside
41
41
  # of the defined morning and afternoon ranges
42
42
  def compute_hours
43
- range = find_range
44
- left = checkin_time.before?(TIME_RANGE[range][:start]) ? TIME_RANGE[range][:start] : checkin_time
45
- right = checkout_time.after?(TIME_RANGE[range][:end]) ? TIME_RANGE[range][:end] : checkout_time
43
+ # Reparse time to avoid errors caused by date differences
44
+ start = Time.zone.parse(checkin_time.strftime('%I:%M%p'))
45
+ finish = Time.zone.parse(checkout_time.strftime('%I:%M%p'))
46
+ range = find_range(start, finish)
47
+ left = start.before?(TIME_RANGE[range][:start]) ? TIME_RANGE[range][:start] : start
48
+ right = finish.after?(TIME_RANGE[range][:end]) ? TIME_RANGE[range][:end] : finish
46
49
  time = (right - left) / 1.hour
47
50
  time -= 1 if range == BOTH
48
51
  time
@@ -1,5 +1,5 @@
1
1
  module Ecom
2
2
  module Core
3
- VERSION = '1.1.28'.freeze
3
+ VERSION = '1.2.0'.freeze
4
4
  end
5
5
  end
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.28
4
+ version: 1.2.0
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-24 00:00:00.000000000 Z
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm