ecom_core 1.3.13 → 1.3.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/ecom/core/crew_contract.rb +11 -1
- data/app/models/ecom/core/crew_time.rb +6 -6
- data/app/models/ecom/core/measurement_unit.rb +1 -1
- data/app/services/ecom/core/crew_contract_transaction_service.rb +14 -3
- data/db/migrate/20200813165553_create_ecom_core_measurement_units.rb +1 -1
- data/db/migrate/20201013072924_create_ecom_core_crew_contract_transactions.rb +1 -1
- data/lib/ecom/core/version.rb +1 -1
- data/spec/factories/ecom/core/measurement_units.rb +1 -1
- metadata +2 -5
- data/app/models/ecom/core/unit_of_measure.rb +0 -8
- data/db/migrate/20191118052213_create_ecom_core_unit_of_measures.rb +0 -11
- data/spec/factories/ecom/core/unit_of_measures.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ab0c6a8f72737d10832fea25871db88c0bf73fb77d64ff9cb0daff2b17e1db4
|
4
|
+
data.tar.gz: 66794ac216ecde16a14605908bb6aa1d1122f4da9afc2492ff706cf7990f89e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d105dfc24a2258093e5ad7b69e67c85ce9ba9d7210f39d5b7cd380b9a44450a0f56de7f11879084975ef1049ca4fdb2fc2d6f85fe89c235211cf31fab1636e3b
|
7
|
+
data.tar.gz: d6152ee67ea533f0ad926843502d5b25d7f9429cffac6a982db9e126dd09f17c9118ee93167cccf15b84304726c84473a89174a4857c7e5e1b79baa9ac04506e
|
@@ -5,6 +5,7 @@ module Ecom
|
|
5
5
|
|
6
6
|
belongs_to :crew
|
7
7
|
belongs_to :crew_type
|
8
|
+
has_many :crew_contract_transactions
|
8
9
|
|
9
10
|
validates :status, :contract_no, :from, :to, :place_of_work, :probation_period,
|
10
11
|
:contract_type, :wage, :wage_in_words, :crew_type_id, :crew_type, presence: true
|
@@ -14,10 +15,19 @@ module Ecom
|
|
14
15
|
validates :wage, presence: true, numericality: { greater_than: 0 }
|
15
16
|
|
16
17
|
validates_uniqueness_of :crew_id,
|
17
|
-
|
18
|
+
scope: :status,
|
19
|
+
if: :contract_in_effect_exists?,
|
18
20
|
message: 'There can only be one contract' \
|
19
21
|
' with status `In effect` for a given crew at a time'
|
20
22
|
|
23
|
+
def contract_in_effect_exists?
|
24
|
+
contracts_in_effect = Ecom::Core::CrewContract.where(crew_id: crew_id, status: 'in_effect')
|
25
|
+
|
26
|
+
return true unless contracts_in_effect.empty?
|
27
|
+
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
21
31
|
def validate_date_range
|
22
32
|
return unless from && to
|
23
33
|
|
@@ -13,7 +13,7 @@ module Ecom
|
|
13
13
|
|
14
14
|
validates :checkin_time, presence: true, if: :checkout_time
|
15
15
|
validate :time_range_validation, :total_time_validation
|
16
|
-
validates :hours,
|
16
|
+
validates :hours, numericality: { greater_than_or_equal_to: 0 }, allow_nil: true
|
17
17
|
|
18
18
|
scope :by_attendance, lambda { |id|
|
19
19
|
joins(:attendance_sheet_entry).where(ecom_core_attendance_sheet_entries: { attendance_sheet_id: id })
|
@@ -32,11 +32,8 @@ module Ecom
|
|
32
32
|
def total_time_validation
|
33
33
|
return if checkout_time.nil? || checkin_time.nil?
|
34
34
|
|
35
|
-
if new_record? & !persisted?
|
36
|
-
|
37
|
-
errors.add(:attendance_sheet_entry, 'has more than 8 hours')
|
38
|
-
end
|
39
|
-
elsif attendance_sheet_entry.total_hours + compute_hours - computed_hour > 8
|
35
|
+
if new_record? & !persisted? & (attendance_sheet_entry.total_hours + compute_hours > 8) ||
|
36
|
+
(attendance_sheet_entry.total_hours + compute_hours - computed_hour > 8)
|
40
37
|
errors.add(:attendance_sheet_entry, 'has more than 8 hours')
|
41
38
|
end
|
42
39
|
end
|
@@ -119,6 +116,9 @@ module Ecom
|
|
119
116
|
# the the currently presisted checkin_time and checkout_time
|
120
117
|
def computed_hour
|
121
118
|
# Reparse time to avoid errors caused by date differences
|
119
|
+
|
120
|
+
return 0 if checkin_time_was.nil? || checkout_time_was.nil?
|
121
|
+
|
122
122
|
range = define_range
|
123
123
|
start = Time.zone.parse(checkin_time_was.strftime('%I:%M%p'))
|
124
124
|
finish = Time.zone.parse(checkout_time_was.strftime('%I:%M%p'))
|
@@ -19,7 +19,7 @@ module Ecom
|
|
19
19
|
|
20
20
|
PHYSICAL_QUANTITIES = [LENGTH, MASS, TIME, CURRENT, TEMPRATURE, AREA, VOLUME, ENERGY, DENSITY].freeze
|
21
21
|
|
22
|
-
validates :name, :
|
22
|
+
validates :name, :abbreviation, :physical_quantity,
|
23
23
|
:conversion_factor, :system_of_measurement, presence: true
|
24
24
|
|
25
25
|
validates :is_si_unit, inclusion: { in: [true, false] }
|
@@ -1,25 +1,28 @@
|
|
1
1
|
module Ecom
|
2
2
|
module Core
|
3
3
|
class CrewContractTransactionService
|
4
|
-
def execute(
|
4
|
+
def execute(crew_contract_transaction, crew_contract)
|
5
5
|
Ecom::Core::CrewContractTransaction.transaction do
|
6
|
-
case transaction_type
|
6
|
+
case crew_contract_transaction.transaction_type
|
7
7
|
when Ecom::Core::CrewContractTransaction::TXN_UPDATE_CREW_TYPE
|
8
8
|
|
9
9
|
create_new_id_card(crew_contract.crew, crew_contract.to)
|
10
10
|
# update crew type
|
11
11
|
crew = crew_contract.crew
|
12
12
|
crew.update(crew_type_id: crew_contract.crew_type_id)
|
13
|
+
crew_contract_transaction.update(status: Ecom::Core::CrewContractTransaction::EXECUTED)
|
13
14
|
|
14
15
|
when Ecom::Core::CrewContractTransaction::TXN_UPDATE_PLACE_OF_WORK
|
15
16
|
|
16
17
|
create_new_id_card(crew_contract.crew, crew_contract.to)
|
18
|
+
crew_contract_transaction.update(status: Ecom::Core::CrewContractTransaction::EXECUTED)
|
17
19
|
|
18
20
|
when Ecom::Core::CrewContractTransaction::TXN_UPDATE_WAGE
|
19
21
|
|
20
22
|
crew = crew_contract.crew
|
21
23
|
# update wage
|
22
24
|
crew.update(wage: crew_contract.wage, wage_in_words: crew_contract.wage_in_words)
|
25
|
+
crew_contract_transaction.update(status: Ecom::Core::CrewContractTransaction::EXECUTED)
|
23
26
|
|
24
27
|
when Ecom::Core::CrewContractTransaction::TXN_UPDATE_VALIDITY
|
25
28
|
|
@@ -27,18 +30,22 @@ module Ecom
|
|
27
30
|
create_new_id_card(crew_contract.crew, crew_contract.to)
|
28
31
|
make_crew_active(crew_contract.crew)
|
29
32
|
activate_contract(crew_contract)
|
33
|
+
crew_contract_transaction.update(status: Ecom::Core::CrewContractTransaction::EXECUTED)
|
30
34
|
|
31
35
|
when Ecom::Core::CrewContractTransaction::TXN_TERMINATE_CONTRACT
|
32
36
|
|
33
37
|
# make crew inactive
|
34
38
|
make_crew_inactive(crew_contract.crew)
|
35
39
|
|
36
|
-
# make ID card invalid
|
40
|
+
# make ID card and gate pass invalid
|
37
41
|
invalidate_id_card(crew_contract.crew)
|
42
|
+
invalidate_gate_pass(crew_contract.crew)
|
38
43
|
|
39
44
|
# make the contract void
|
40
45
|
deactivate_contract(crew_contract)
|
41
46
|
|
47
|
+
crew_contract_transaction.update(status: Ecom::Core::CrewContractTransaction::EXECUTED)
|
48
|
+
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
@@ -84,6 +91,10 @@ module Ecom
|
|
84
91
|
current_id_card = Ecom::Core::CrewIdCard.where(crew_id: crew.id).last
|
85
92
|
current_id_card.update(status: 'Invalid')
|
86
93
|
end
|
94
|
+
|
95
|
+
def invalidate_gate_pass(crew)
|
96
|
+
Ecom::Core::SiteCrew.where(crew_id: crew.id).update(status: Ecom::Core::SiteCrew::INACTIVE)
|
97
|
+
end
|
87
98
|
end
|
88
99
|
end
|
89
100
|
end
|
@@ -2,7 +2,7 @@ class CreateEcomCoreMeasurementUnits < ActiveRecord::Migration[6.0]
|
|
2
2
|
def change
|
3
3
|
create_table :ecom_core_measurement_units do |t|
|
4
4
|
t.string :name, null: false
|
5
|
-
t.string :
|
5
|
+
t.string :abbreviation, null: false
|
6
6
|
t.string :physical_quantity, null: false
|
7
7
|
t.boolean :is_si_unit, null: false, default: false
|
8
8
|
t.float :conversion_factor, null: false
|
@@ -3,7 +3,7 @@ class CreateEcomCoreCrewContractTransactions < ActiveRecord::Migration[6.0]
|
|
3
3
|
create_table :ecom_core_crew_contract_transactions do |t|
|
4
4
|
t.string :transaction_type, null: false
|
5
5
|
t.string :status, null: false, default: 'Pending'
|
6
|
-
t.
|
6
|
+
t.date :effective_date, null: false
|
7
7
|
|
8
8
|
t.references :crew_contract,
|
9
9
|
null: false,
|
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.3.
|
4
|
+
version: 1.3.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|
@@ -284,7 +284,6 @@ files:
|
|
284
284
|
- app/models/ecom/core/task_template_inspection_checklist.rb
|
285
285
|
- app/models/ecom/core/task_template_type.rb
|
286
286
|
- app/models/ecom/core/unit_cost.rb
|
287
|
-
- app/models/ecom/core/unit_of_measure.rb
|
288
287
|
- app/models/ecom/core/user.rb
|
289
288
|
- app/models/ecom/core/user_role.rb
|
290
289
|
- app/models/ecom/core/work_item_resource_requirement_template.rb
|
@@ -310,7 +309,6 @@ files:
|
|
310
309
|
- db/migrate/20190101085530_create_ecom_core_companies.rb
|
311
310
|
- db/migrate/20190101112620_create_ecom_core_lookups.rb
|
312
311
|
- db/migrate/20190101112625_create_ecom_core_overtime_types.rb
|
313
|
-
- db/migrate/20191118052213_create_ecom_core_unit_of_measures.rb
|
314
312
|
- db/migrate/20191119010518_create_ecom_core_task_template_types.rb
|
315
313
|
- db/migrate/20191119012030_create_ecom_core_task_templates.rb
|
316
314
|
- db/migrate/20191119013236_create_ecom_core_work_product_templates.rb
|
@@ -469,7 +467,6 @@ files:
|
|
469
467
|
- spec/factories/ecom/core/task_templates.rb
|
470
468
|
- spec/factories/ecom/core/tasks.rb
|
471
469
|
- spec/factories/ecom/core/unit_costs.rb
|
472
|
-
- spec/factories/ecom/core/unit_of_measures.rb
|
473
470
|
- spec/factories/ecom/core/user_roles.rb
|
474
471
|
- spec/factories/ecom/core/users.rb
|
475
472
|
- spec/factories/ecom/core/work_item_resource_requirement_templates.rb
|