ecom_core 1.2.7 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/constants/ecom/core/status_constants.rb +11 -0
- data/app/models/ecom/core/attendance_sheet.rb +24 -18
- data/app/models/ecom/core/crew_overtime.rb +5 -0
- data/app/models/ecom/core/crew_time.rb +7 -2
- data/app/models/ecom/core/overtime_sheet.rb +9 -9
- data/app/models/ecom/core/payroll.rb +4 -0
- data/db/migrate/20191225140433_create_ecom_core_attendance_sheets.rb +2 -1
- data/db/migrate/20200410090701_create_ecom_core_overtime_sheets.rb +3 -1
- data/lib/ecom/core/version.rb +1 -1
- data/spec/factories/ecom/core/attendance_sheets.rb +1 -1
- data/spec/factories/ecom/core/overtime_sheets.rb +1 -1
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec4b0205003456f436aa5ec2ffc99f73d9f9dae97b5038f95b598fa259b6c66
|
4
|
+
data.tar.gz: 818efd4bff74c94646dd9fc96f99ee60f2e932e42183fbbdf240e277d9beacac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98e9f053543924c0b852c263d6185f5e09e8e7d5557a17835fc7e99b3d3b5f33eb26e2f4f1a4b01bad8195da0d950db9e924bb9ad4899e258c8a9393dac4fd73
|
7
|
+
data.tar.gz: ab3f72029a9386058701711220ac5884eb093385c292596d6cd4c0f34d31d71e5431b06e93df294e7e97de53db68afea0896032c0fd10ba8632d194b98532ea3
|
@@ -1,37 +1,43 @@
|
|
1
1
|
module Ecom
|
2
2
|
module Core
|
3
3
|
class AttendanceSheet < ApplicationRecord
|
4
|
-
|
5
|
-
|
6
|
-
APPROVED = 'Approved'.freeze
|
7
|
-
|
8
|
-
validates :date, presence: true, uniqueness: true
|
9
|
-
validates :status, inclusion: [OPEN, SUBMITTED, APPROVED]
|
4
|
+
validates :date, presence: true, uniqueness: { scope: :project_id }
|
5
|
+
validates :status, inclusion: StatusConstants::STATUSES
|
10
6
|
|
11
7
|
belongs_to :project
|
12
8
|
|
13
9
|
has_many :attendance_sheet_entries
|
14
10
|
has_many :crew_times, through: :attendance_sheet_entries
|
15
11
|
|
16
|
-
scope :
|
17
|
-
scope :
|
18
|
-
scope :
|
19
|
-
scope :
|
12
|
+
scope :by_project, ->(id) { where(project_id: id) }
|
13
|
+
scope :by_date, ->(date) { where(date: date) }
|
14
|
+
scope :by_status, ->(status) { where(status: status) }
|
15
|
+
scope :by_date_between, ->(from, to) { where('date BETWEEN ? AND ?', from, to) }
|
20
16
|
|
21
17
|
def self.open_for_date(date, project_id)
|
22
|
-
AttendanceSheet.find_by(status: OPEN, date: date, project_id: project_id)
|
18
|
+
AttendanceSheet.find_by(status: StatusConstants::OPEN, date: date, project_id: project_id)
|
23
19
|
end
|
24
20
|
|
25
21
|
def self.open_exists?(project_id)
|
26
|
-
AttendanceSheet
|
22
|
+
AttendanceSheet
|
23
|
+
.by_project(project_id)
|
24
|
+
.by_status(StatusConstants::OPEN)
|
25
|
+
.exists?
|
27
26
|
end
|
28
27
|
|
29
28
|
def self.exists_for_today?(project_id)
|
30
|
-
AttendanceSheet
|
29
|
+
AttendanceSheet
|
30
|
+
.by_project(project_id)
|
31
|
+
.by_date(Date.today)
|
32
|
+
.exists?
|
31
33
|
end
|
32
34
|
|
33
35
|
def self.open_exists_for_today?(project_id)
|
34
|
-
AttendanceSheet
|
36
|
+
AttendanceSheet
|
37
|
+
.by_project(project_id)
|
38
|
+
.by_date(Date.today)
|
39
|
+
.by_status(StatusConstants::OPEN)
|
40
|
+
.exists?
|
35
41
|
end
|
36
42
|
|
37
43
|
# Attendance sheet should be created using the
|
@@ -46,16 +52,16 @@ module Ecom
|
|
46
52
|
raise 'There is an open attendance sheet which needs to be submitted before creating a new one.'
|
47
53
|
end
|
48
54
|
|
49
|
-
AttendanceSheet.create(date: Date.today, opened_at: Time.now, status: OPEN, project_id: project_id)
|
55
|
+
AttendanceSheet.create(date: Date.today, opened_at: Time.now, status: StatusConstants::OPEN, project_id: project_id)
|
50
56
|
end
|
51
57
|
|
52
58
|
def self.submit_current(project_id)
|
53
|
-
sheet = AttendanceSheet.find_by(date: Date.today, status: OPEN, project_id: project_id)
|
59
|
+
sheet = AttendanceSheet.find_by(date: Date.today, status: StatusConstants::OPEN, project_id: project_id)
|
54
60
|
|
55
61
|
raise 'There is no open attendance sheet to submit.' if sheet.nil?
|
56
62
|
|
57
63
|
sheet.closed_at = Time.now
|
58
|
-
sheet.status = SUBMITTED
|
64
|
+
sheet.status = StatusConstants::SUBMITTED
|
59
65
|
sheet.save
|
60
66
|
sheet
|
61
67
|
end
|
@@ -69,7 +75,7 @@ module Ecom
|
|
69
75
|
raise 'There is no open attendance sheet to submit for the selected day.' unless sheet
|
70
76
|
|
71
77
|
sheet.closed_at = Time.now
|
72
|
-
sheet.status = SUBMITTED
|
78
|
+
sheet.status = StatusConstants::SUBMITTED
|
73
79
|
sheet.save
|
74
80
|
sheet
|
75
81
|
end
|
@@ -10,6 +10,11 @@ module Ecom
|
|
10
10
|
|
11
11
|
validates :hours, :raw_hours, presence: true
|
12
12
|
|
13
|
+
scope :by_overtime, lambda { |id|
|
14
|
+
joins(:overtime_sheet_entry).where(ecom_core_overtime_sheet_entries: { overtime_sheet_id: id })
|
15
|
+
}
|
16
|
+
scope :revised, ->(revised) { where(revised: revised) }
|
17
|
+
|
13
18
|
before_save :calculate_hours
|
14
19
|
|
15
20
|
def calculate_hours
|
@@ -7,8 +7,8 @@ module Ecom
|
|
7
7
|
BOTH = 'Both'.freeze
|
8
8
|
|
9
9
|
TIME_RANGE = {
|
10
|
-
MORNING => {start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('9:00 AM')},
|
11
|
-
AFTERNOON => {start: Time.zone.parse('10:00 AM'), end: Time.zone.parse('2:00 PM')},
|
10
|
+
MORNING => { start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('9:00 AM') },
|
11
|
+
AFTERNOON => { start: Time.zone.parse('10:00 AM'), end: Time.zone.parse('2:00 PM') },
|
12
12
|
BOTH => {start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('2:00 PM')}
|
13
13
|
}.freeze
|
14
14
|
|
@@ -19,6 +19,11 @@ module Ecom
|
|
19
19
|
|
20
20
|
validates :checkin_time, presence: true, if: :checkout_time
|
21
21
|
|
22
|
+
scope :by_attendance, lambda { |id|
|
23
|
+
joins(:attendance_sheet_entry).where(ecom_core_attendance_sheet_entries: { attendance_sheet_id: id })
|
24
|
+
}
|
25
|
+
scope :revised, ->(revised) { where(revised: revised) }
|
26
|
+
|
22
27
|
before_save :calculate_hours
|
23
28
|
after_save :calculate_total
|
24
29
|
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module Ecom
|
2
2
|
module Core
|
3
3
|
class OvertimeSheet < ApplicationRecord
|
4
|
-
|
5
|
-
|
6
|
-
APPROVED = 'Approved'.freeze
|
7
|
-
|
8
|
-
validates :date, :opened_at, presence: true, uniqueness: true
|
9
|
-
validates :status, inclusion: [OPEN, SUBMITTED, APPROVED]
|
4
|
+
validates :date, :opened_at, presence: true, uniqueness: { scope: :project_id }
|
5
|
+
validates :status, inclusion: StatusConstants::STATUSES
|
10
6
|
|
11
7
|
belongs_to :project
|
12
8
|
|
13
9
|
has_many :overtime_sheet_entries
|
14
10
|
has_many :crew_overtimes, through: :overtime_sheet_entries
|
15
11
|
|
16
|
-
scope :
|
17
|
-
scope :
|
12
|
+
scope :by_project, ->(id) { where(project_id: id) }
|
13
|
+
scope :by_date, ->(date) { where(date: date) }
|
14
|
+
scope :by_status, ->(status) { where(status: status) }
|
15
|
+
scope :by_date_between, ->(from, to) { where('date BETWEEN ? AND ?', from, to) }
|
16
|
+
scope :open, ->(id) { where(status: StatusConstants::OPEN, project_id: id) }
|
17
|
+
scope :submitted, ->(id) { where(status: StatusConstants::SUBMITTED, project_id: id) }
|
18
18
|
|
19
19
|
def self.open_exists?(project_id)
|
20
20
|
OvertimeSheet.open(project_id).exists?
|
@@ -38,7 +38,7 @@ module Ecom
|
|
38
38
|
raise 'There is already an open overtime sheet. It has to be submitted before creating a new one.'
|
39
39
|
end
|
40
40
|
|
41
|
-
OvertimeSheet.create(date: date, opened_at: Time.now, status: OPEN, project_id: project_id)
|
41
|
+
OvertimeSheet.create(date: date, opened_at: Time.now, status: StatusConstants::OPEN, project_id: project_id)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -5,6 +5,10 @@ module Ecom
|
|
5
5
|
|
6
6
|
has_many :payments, class_name: 'Ecom::Core::Payment'
|
7
7
|
belongs_to :project
|
8
|
+
|
9
|
+
scope :by_project, ->(id) { where(project_id: id) }
|
10
|
+
scope :by_month, ->(month) { where(month: month) }
|
11
|
+
scope :by_year, ->(year) { where(year: year) }
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CreateEcomCoreAttendanceSheets < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
create_table :ecom_core_attendance_sheets do |t|
|
4
|
-
t.date :date, null: false
|
4
|
+
t.date :date, null: false
|
5
5
|
t.time :opened_at, null: false
|
6
6
|
t.time :closed_at
|
7
7
|
t.string :remark
|
@@ -13,5 +13,6 @@ class CreateEcomCoreAttendanceSheets < ActiveRecord::Migration[6.0]
|
|
13
13
|
|
14
14
|
t.timestamps
|
15
15
|
end
|
16
|
+
add_index :ecom_core_attendance_sheets, %i[date project_id], unique: true
|
16
17
|
end
|
17
18
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class CreateEcomCoreOvertimeSheets < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
create_table :ecom_core_overtime_sheets do |t|
|
4
|
-
t.date :date, null: false
|
4
|
+
t.date :date, null: false
|
5
5
|
t.time :opened_at, null: false
|
6
6
|
t.time :submitted_at
|
7
|
+
t.string :remark
|
7
8
|
t.string :status, null: false, default: 'Open'
|
8
9
|
t.references :project,
|
9
10
|
null: false,
|
@@ -12,5 +13,6 @@ class CreateEcomCoreOvertimeSheets < ActiveRecord::Migration[6.0]
|
|
12
13
|
|
13
14
|
t.timestamps
|
14
15
|
end
|
16
|
+
add_index :ecom_core_overtime_sheets, %i[date project_id], unique: true
|
15
17
|
end
|
16
18
|
end
|
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.2.
|
4
|
+
version: 1.2.9
|
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-05-
|
11
|
+
date: 2020-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|
@@ -178,20 +178,6 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: solargraph
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
195
181
|
description: An engine which contains the core of a construction management app as
|
196
182
|
a layer.
|
197
183
|
email:
|
@@ -203,6 +189,7 @@ files:
|
|
203
189
|
- MIT-LICENSE
|
204
190
|
- README.md
|
205
191
|
- Rakefile
|
192
|
+
- app/constants/ecom/core/status_constants.rb
|
206
193
|
- app/controllers/concerns/ecom/core/lookupable.rb
|
207
194
|
- app/controllers/concerns/ecom/core/resource_typeable.rb
|
208
195
|
- app/controllers/ecom/core/access_controller.rb
|