ecom_core 1.2.30 → 1.2.31

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af96604702a7c0a83f0567e1a444bc4fa80b8714f7af4da402d2868937f3e2db
4
- data.tar.gz: dc7848bedb34f4e898f90f8f0aa5cdc1c2485172332578af2cb748ca3e14fa3e
3
+ metadata.gz: 1e0b7beafc5d7b2e1a7385f1a01db93b9d3279c41434a3e104a76e58aa0b48ac
4
+ data.tar.gz: 766cbcb8b998e4725c1afe43f0c28a2a3901d8ce2e9a84fd308c5c88623ef392
5
5
  SHA512:
6
- metadata.gz: dbe2542e2087c03011bb0e370eba3da5c2c5b2e40b01e0990750f8964f8aac0510d2ae1a71bee8ec107130dc7fed3e8ec04ab4f96a99d61921f56024beeab259
7
- data.tar.gz: cd9546c5d8b5796d3f50688dbf202127f942dd838bff0cbcd3a096943efb5037df103d87256f1d6b1cab71b9e7dafcc3b41572b50d185c390990d81a789f5ffa
6
+ metadata.gz: 6590ea1a50bdc293aa807ed135287cb6c89ecdd83e902898801f758d1d187b5003b31c77117f7d02ab8367e13b06bac4fb0054726c9e1934e8aa4279d6a36f43
7
+ data.tar.gz: ead89e3cd5136806c9e1ea45fb91c46249604aad30ab6040f902b119307f34c0a34940c491866d04ff8eab5a99b33350dcdbc9a7399a8ce73155ff086d43c802
@@ -12,7 +12,7 @@ module Ecom
12
12
  has_one :revision, class_name: 'Ecom::Core::CrewTime', foreign_key: :revision_to_id
13
13
 
14
14
  validates :checkin_time, presence: true, if: :checkout_time
15
- validate :checkout_is_greater_than_checkin
15
+ validate :time_range_validation, :total_time_validation
16
16
 
17
17
  scope :by_attendance, lambda { |id|
18
18
  joins(:attendance_sheet_entry).where(ecom_core_attendance_sheet_entries: { attendance_sheet_id: id })
@@ -22,12 +22,20 @@ module Ecom
22
22
  before_save :calculate_hours
23
23
  after_save :calculate_total
24
24
 
25
- def checkout_is_greater_than_checkin
25
+ def time_range_validation
26
26
  return unless checkin_time && checkout_time && checkout_time <= checkin_time
27
27
 
28
28
  errors.add(:checkout_time, "can't be less than checkin time.")
29
29
  end
30
30
 
31
+ def total_time_validation
32
+ return if checkout_time.nil? || checkin_time.nil?
33
+
34
+ return unless attendance_sheet_entry.total_hours + compute_hours > 8
35
+
36
+ errors.add(:attendance_sheet_entry, 'has more than 8 hours')
37
+ end
38
+
31
39
  def calculate_hours
32
40
  self.hours = if checkout_time.nil? || checkin_time.nil?
33
41
  0
@@ -1,5 +1,5 @@
1
1
  module Ecom
2
2
  module Core
3
- VERSION = '1.2.30'.freeze
3
+ VERSION = '1.2.31'.freeze
4
4
  end
5
5
  end
@@ -2,6 +2,6 @@ FactoryBot.define do
2
2
  factory :attendance_sheet_entry, class: Ecom::Core::AttendanceSheetEntry do
3
3
  association :attendance_sheet
4
4
  association :crew
5
- total_hours { FFaker::Random.rand(0..8) }
5
+ total_hours { 0 }
6
6
  end
7
7
  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.2.30
4
+ version: 1.2.31
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-09-22 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm