ecom_core 1.1.16 → 1.1.17
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_overtime.rb +21 -0
- data/app/models/ecom/core/overtime_sheet.rb +33 -0
- data/app/models/ecom/core/overtime_sheet_entry.rb +8 -0
- data/db/migrate/20200410090701_create_ecom_core_overtime_sheets.rb +12 -0
- data/db/migrate/20200410100035_create_ecom_core_overtime_sheet_entries.rb +14 -0
- data/db/migrate/20200410111827_create_ecom_core_crew_overtimes.rb +21 -0
- data/lib/ecom/core/version.rb +1 -1
- data/spec/factories/ecom/core/crew_overtimes.rb +12 -0
- data/spec/factories/ecom/core/overtime_sheet_entries.rb +7 -0
- data/spec/factories/ecom/core/overtime_sheets.rb +8 -0
- metadata +10 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bdf3745639577dacd60d41eb82831de69cd41040b71411628f17be1a8397b42
|
4
|
+
data.tar.gz: 21fd30d003500d6648d42eb6be7e5d073eff6b7810148cd00aed1fd2496363ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 769ccb1b054f0b6faf9421e323e562053d3fe7770fb3abed2af5e0535be3f61f39803deff27b4816d4b58efcb07419b46519c73906ff44c7480ee4b03e9ac099
|
7
|
+
data.tar.gz: 6d852af57207ad9cfbc6f30d7eaadf239c338b6c4796198e5ec8f833b69b16fba2d790d555b64b37279583e87edb8a517a7dfe0811e74b66fc21f1e0659c3b9c
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class CrewOvertime < ApplicationRecord
|
4
|
+
belongs_to :overtime_type
|
5
|
+
belongs_to :overtime_sheet_entry
|
6
|
+
belongs_to :revision_to, class_name: 'Ecom::Core::CrewOvertime', optional: true
|
7
|
+
belongs_to :created_by, class_name: 'Ecom::Core::User'
|
8
|
+
|
9
|
+
has_one :revision, class_name: 'Ecom::Core::CrewOvertime'
|
10
|
+
|
11
|
+
validates :hours, :converted_hours, presence: true
|
12
|
+
|
13
|
+
before_save :calculate_converted_hours
|
14
|
+
|
15
|
+
def calculate_converted_hours
|
16
|
+
rate = OvertimeType.find(overtime_type_id).rate
|
17
|
+
self.converted_hours = hours * rate
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class OvertimeSheet < ApplicationRecord
|
4
|
+
OPEN = 'Open'.freeze
|
5
|
+
SUBMITTED = 'Submitted'.freeze
|
6
|
+
APPROVED = 'Approved'.freeze
|
7
|
+
|
8
|
+
validates :date, :opened_at, presence: true, uniqueness: true
|
9
|
+
validates :status, inclusion: [OPEN, SUBMITTED, APPROVED]
|
10
|
+
|
11
|
+
has_many :overtime_sheet_entries
|
12
|
+
|
13
|
+
scope :open, -> { find_by(status: OPEN) }
|
14
|
+
|
15
|
+
def self.open_exists?
|
16
|
+
OvertimeSheet.where(status: OPEN).exists?
|
17
|
+
end
|
18
|
+
|
19
|
+
# Overtime sheet should be created using the
|
20
|
+
# method below only. This is because we need to
|
21
|
+
# check if there is an open overtime already,
|
22
|
+
# and also that we have only one open overtime
|
23
|
+
# sheet at a time.
|
24
|
+
def self.create_new(date)
|
25
|
+
if OvertimeSheet.open_exists?
|
26
|
+
raise 'There is already an open overtime sheet. It has to be submitted before creating a new one.'
|
27
|
+
end
|
28
|
+
|
29
|
+
OvertimeSheet.create(date: date, opened_at: Time.now, status: OPEN)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateEcomCoreOvertimeSheets < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_core_overtime_sheets do |t|
|
4
|
+
t.date :date, null: false, unique: true
|
5
|
+
t.time :opened_at, null: false
|
6
|
+
t.time :submitted_at
|
7
|
+
t.string :status, null: false, default: 'Open'
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateEcomCoreOvertimeSheetEntries < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_core_overtime_sheet_entries do |t|
|
4
|
+
t.references :overtime_sheet, null: false, index: { name: 'ose_on_os_indx' }
|
5
|
+
t.references :crew, null: false, index: { name: 'ose_on_crew_indx' }
|
6
|
+
t.float :total_overtime
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
add_foreign_key :ecom_core_overtime_sheet_entries, :ecom_core_overtime_sheets,
|
11
|
+
column: :overtime_sheet_id
|
12
|
+
add_foreign_key :ecom_core_overtime_sheet_entries, :ecom_core_crews, column: :crew_id
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateEcomCoreCrewOvertimes < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_core_crew_overtimes do |t|
|
4
|
+
t.float :hours, null: false
|
5
|
+
t.float :converted_hours, null: false, default: 0
|
6
|
+
t.string :remark
|
7
|
+
t.references :overtime_type, null: false, index: { name: 'ot_on_co_indx' }
|
8
|
+
t.references :overtime_sheet_entry, null: false, index: { name: 'ose_on_co_indx' }
|
9
|
+
t.boolean :revised, null: false, default: false
|
10
|
+
t.references :revision_to, null: true
|
11
|
+
t.references :created_by, null: false, index: { name: 'cb_on_co_indx' }
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
add_foreign_key :ecom_core_crew_overtimes, :ecom_core_overtime_types, column: :overtime_type_id
|
16
|
+
add_foreign_key :ecom_core_crew_overtimes, :ecom_core_overtime_sheet_entries,
|
17
|
+
column: :overtime_sheet_entry_id
|
18
|
+
add_foreign_key :ecom_core_crew_overtimes, :ecom_core_crew_overtimes, column: :revision_to_id
|
19
|
+
add_foreign_key :ecom_core_crew_overtimes, :ecom_core_users, column: :created_by_id
|
20
|
+
end
|
21
|
+
end
|
data/lib/ecom/core/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :crew_overtime, class: 'Ecom::Core::CrewOvertime' do
|
3
|
+
hours { 2 }
|
4
|
+
converted_hours { 2 }
|
5
|
+
remark { FFaker::Name.name }
|
6
|
+
association :overtime_type
|
7
|
+
association :overtime_sheet_entry
|
8
|
+
revised { false }
|
9
|
+
revision_to { nil }
|
10
|
+
association :created_by, factory: :user
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
@@ -219,6 +219,7 @@ files:
|
|
219
219
|
- app/models/ecom/core/attendance_sheet.rb
|
220
220
|
- app/models/ecom/core/attendance_sheet_entry.rb
|
221
221
|
- app/models/ecom/core/crew.rb
|
222
|
+
- app/models/ecom/core/crew_overtime.rb
|
222
223
|
- app/models/ecom/core/crew_time.rb
|
223
224
|
- app/models/ecom/core/crew_type.rb
|
224
225
|
- app/models/ecom/core/currency.rb
|
@@ -234,6 +235,8 @@ files:
|
|
234
235
|
- app/models/ecom/core/lookup.rb
|
235
236
|
- app/models/ecom/core/material_type.rb
|
236
237
|
- app/models/ecom/core/menu.rb
|
238
|
+
- app/models/ecom/core/overtime_sheet.rb
|
239
|
+
- app/models/ecom/core/overtime_sheet_entry.rb
|
237
240
|
- app/models/ecom/core/overtime_type.rb
|
238
241
|
- app/models/ecom/core/payment.rb
|
239
242
|
- app/models/ecom/core/payment_detail.rb
|
@@ -303,6 +306,9 @@ files:
|
|
303
306
|
- db/migrate/20200401122539_create_ecom_core_attendance_sheet_entries.rb
|
304
307
|
- db/migrate/20200401142959_relate_crew_time_with_attendance_sheet_entry.rb
|
305
308
|
- db/migrate/20200401144137_remove_crew_time_id_from_crew.rb
|
309
|
+
- db/migrate/20200410090701_create_ecom_core_overtime_sheets.rb
|
310
|
+
- db/migrate/20200410100035_create_ecom_core_overtime_sheet_entries.rb
|
311
|
+
- db/migrate/20200410111827_create_ecom_core_crew_overtimes.rb
|
306
312
|
- lib/ecom/core.rb
|
307
313
|
- lib/ecom/core/engine.rb
|
308
314
|
- lib/ecom/core/version.rb
|
@@ -311,6 +317,7 @@ files:
|
|
311
317
|
- spec/factories/ecom/core/application_modules.rb
|
312
318
|
- spec/factories/ecom/core/attendance_sheet_entries.rb
|
313
319
|
- spec/factories/ecom/core/attendance_sheets.rb
|
320
|
+
- spec/factories/ecom/core/crew_overtimes.rb
|
314
321
|
- spec/factories/ecom/core/crew_times.rb
|
315
322
|
- spec/factories/ecom/core/crew_types.rb
|
316
323
|
- spec/factories/ecom/core/crews.rb
|
@@ -327,6 +334,8 @@ files:
|
|
327
334
|
- spec/factories/ecom/core/lookups.rb
|
328
335
|
- spec/factories/ecom/core/material_types.rb
|
329
336
|
- spec/factories/ecom/core/menus.rb
|
337
|
+
- spec/factories/ecom/core/overtime_sheet_entries.rb
|
338
|
+
- spec/factories/ecom/core/overtime_sheets.rb
|
330
339
|
- spec/factories/ecom/core/overtime_types.rb
|
331
340
|
- spec/factories/ecom/core/payment_details.rb
|
332
341
|
- spec/factories/ecom/core/payments.rb
|