ecom_core 1.2.11 → 1.2.12
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/booked_equipment.rb +19 -0
- data/app/models/ecom/core/booking_request.rb +26 -0
- data/app/models/ecom/core/component_type.rb +6 -0
- data/app/models/ecom/core/country.rb +6 -0
- data/app/models/ecom/core/equipment_component.rb +1 -0
- data/app/models/ecom/core/equipment_item.rb +14 -2
- data/app/validators/ecom/core/date_range_validator.rb +11 -0
- data/db/migrate/20200315152143_create_ecom_core_equipment.rb +2 -0
- data/db/migrate/20200315153640_create_ecom_core_equipment_items.rb +6 -1
- data/db/migrate/20200316125323_create_ecom_core_equipment_components.rb +5 -0
- data/db/migrate/20200602130247_create_ecom_core_booking_requests.rb +31 -0
- data/db/migrate/20200603115317_create_ecom_core_booked_equipments.rb +24 -0
- data/lib/ecom/core/version.rb +1 -1
- data/spec/factories/ecom/core/booked_equipments.rb +10 -0
- data/spec/factories/ecom/core/booking_requests.rb +15 -0
- data/spec/factories/ecom/core/component_types.rb +5 -0
- data/spec/factories/ecom/core/countries.rb +5 -0
- data/spec/factories/ecom/core/equipment.rb +2 -0
- data/spec/factories/ecom/core/equipment_components.rb +2 -0
- data/spec/factories/ecom/core/equipment_items.rb +3 -1
- data/spec/factories/ecom/core/work_products.rb +1 -1
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e6b8c84820dca6b1121f9f33ffdffc3f421c2a7aced743a21bac89c25b7580
|
4
|
+
data.tar.gz: 557e5da2ed61cca47e0e80002469f9798d9eb96f26a8357f897beea42c4a0062
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23b9c88cb223aa6afec885e5937089695952810e383121f9511a94b58fa5c8fe86787aad5573a61d382511d31bb643a40ba1fe0b50dafe1ea9e4ba7bbf82060f
|
7
|
+
data.tar.gz: d35a3ede79f6735372668c8812e2b49f3b6653bdd577f6b95b936f2a23177c2f8467c3d307a42b07363d6d36189e0374e351305c8908bcdc20ccc3ce1453d666
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class BookedEquipment < ApplicationRecord
|
4
|
+
BOOKED = 'Booked'.freeze
|
5
|
+
ON_SITE = 'On Site'.freeze
|
6
|
+
RETURNED = 'Returned'.freeze
|
7
|
+
|
8
|
+
STATUSES = [BOOKED, ON_SITE, RETURNED].freeze
|
9
|
+
|
10
|
+
belongs_to :booking_request
|
11
|
+
belongs_to :equipment_item
|
12
|
+
belongs_to :booked_to, class_name: 'Ecom::Core::User'
|
13
|
+
|
14
|
+
validates :start_date, :end_date, :status, presence: true
|
15
|
+
validates :status, inclusion: STATUSES
|
16
|
+
validates_with DateRangeValidator
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class BookingRequest < ApplicationRecord
|
4
|
+
DRAFT = 'Draft'.freeze
|
5
|
+
UNDER_REVIEW = 'Under Review'.freeze
|
6
|
+
APPROVED = 'Approved'.freeze
|
7
|
+
REJECTED = 'Rejected'.freeze
|
8
|
+
|
9
|
+
STATUSES = [DRAFT, UNDER_REVIEW, APPROVED, REJECTED].freeze
|
10
|
+
belongs_to :equipment
|
11
|
+
belongs_to :country, optional: true
|
12
|
+
belongs_to :requested_by, class_name: 'Ecom::Core::User'
|
13
|
+
belongs_to :approved_by, class_name: 'Ecom::Core::User', optional: true
|
14
|
+
|
15
|
+
validates :start_date, :end_date, :quantity, :status, presence: true
|
16
|
+
validates :status, inclusion: STATUSES
|
17
|
+
validates_with DateRangeValidator
|
18
|
+
|
19
|
+
scope :by_status, ->(status) { where(status: status) }
|
20
|
+
|
21
|
+
def validate_date_range
|
22
|
+
errors.add(:end_date, 'cannot be before start date') if start_date && end_date && start_date > end_date
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,13 +1,25 @@
|
|
1
1
|
module Ecom
|
2
2
|
module Core
|
3
3
|
class EquipmentItem < ApplicationRecord
|
4
|
-
|
5
|
-
|
4
|
+
# Equipment Statuses
|
5
|
+
READY = 'Ready'.freeze
|
6
|
+
UNDER_MAINTENANCE = 'Under Maintenance'.freeze
|
7
|
+
EQUIPMENT_STATUSES = [READY, UNDER_MAINTENANCE].freeze
|
8
|
+
|
9
|
+
# Duty Statuses
|
10
|
+
AVAILABLE = 'Available'.freeze
|
11
|
+
BOOKED = 'Booked'.freeze
|
12
|
+
ON_DUTY = 'On Duty'.freeze
|
13
|
+
DUTY_STATUSES = [AVAILABLE, BOOKED, ON_DUTY].freeze
|
6
14
|
|
7
15
|
belongs_to :equipment
|
16
|
+
belongs_to :country
|
8
17
|
belongs_to :current_location, class_name: 'Ecom::Core::EquipmentLocation'
|
9
18
|
|
10
19
|
validates :name, :status, :serial_number, :purchase_date, :purchase_price, presence: true
|
20
|
+
validates :status, inclusion: EQUIPMENT_STATUSES
|
21
|
+
validates :duty_status, inclusion: DUTY_STATUSES
|
22
|
+
|
11
23
|
validates :serial_number, uniqueness: true
|
12
24
|
|
13
25
|
def self.search(param)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class DateRangeValidator < ActiveModel::Validator
|
4
|
+
def validate(record)
|
5
|
+
return unless record.start_date && record.end_date && record.start_date > record.end_date
|
6
|
+
|
7
|
+
record.errors.add(:base, 'End date cannot be before start date')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -4,6 +4,8 @@ class CreateEcomCoreEquipment < ActiveRecord::Migration[6.0]
|
|
4
4
|
t.string :name, null: false
|
5
5
|
t.string :description
|
6
6
|
t.float :minimum_acquisition_time, null: false, default: 0
|
7
|
+
t.string :brands, array: true, default: []
|
8
|
+
t.string :components, array: true, default: []
|
7
9
|
t.references :equipment_category,
|
8
10
|
null: false,
|
9
11
|
index: { name: 'ec_on_ece_indx' },
|
@@ -3,7 +3,8 @@ class CreateEcomCoreEquipmentItems < ActiveRecord::Migration[6.0]
|
|
3
3
|
create_table :ecom_core_equipment_items do |t|
|
4
4
|
t.string :name, null: false
|
5
5
|
t.string :description
|
6
|
-
t.string :status, null: false
|
6
|
+
t.string :status, null: false, default: 'Ready'
|
7
|
+
t.string :duty_status, null: false, default: 'Available'
|
7
8
|
t.string :serial_number, unique: true
|
8
9
|
t.string :brand
|
9
10
|
t.string :item_model
|
@@ -11,6 +12,10 @@ class CreateEcomCoreEquipmentItems < ActiveRecord::Migration[6.0]
|
|
11
12
|
t.date :purchase_date, null: false
|
12
13
|
t.float :license_fee
|
13
14
|
t.float :tax
|
15
|
+
t.references :country,
|
16
|
+
null: false,
|
17
|
+
index: { name: 'equipment_on_country_indx' },
|
18
|
+
foreign_key: { to_table: :ecom_core_lookups }
|
14
19
|
t.references :equipment,
|
15
20
|
null: false,
|
16
21
|
index: { name: 'equipment_on_ei_indx' },
|
@@ -3,10 +3,15 @@ class CreateEcomCoreEquipmentComponents < ActiveRecord::Migration[6.0]
|
|
3
3
|
create_table :ecom_core_equipment_components do |t|
|
4
4
|
t.string :serial_number
|
5
5
|
t.string :name, null: false
|
6
|
+
t.references :component_type,
|
7
|
+
null: false,
|
8
|
+
index: { name: 'ei_on_ct_indx' },
|
9
|
+
foreign_key: { to_table: :ecom_core_lookups }
|
6
10
|
t.references :equipment_item,
|
7
11
|
null: false,
|
8
12
|
index: { name: 'ei_on_ec_indx' },
|
9
13
|
foreign_key: { to_table: :ecom_core_equipment_items }
|
14
|
+
t.string :remark
|
10
15
|
|
11
16
|
t.timestamps
|
12
17
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class CreateEcomCoreBookingRequests < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_core_booking_requests do |t|
|
4
|
+
t.date :start_date, null: false
|
5
|
+
t.date :end_date, null: false
|
6
|
+
t.references :equipment,
|
7
|
+
null: false,
|
8
|
+
index: { name: 'br_on_equipment_indx' },
|
9
|
+
foreign_key: { to_table: :ecom_core_equipment }
|
10
|
+
t.integer :quantity, null: false
|
11
|
+
t.string :brand
|
12
|
+
t.references :country,
|
13
|
+
null: true,
|
14
|
+
index: { name: 'br_on_country_indx' },
|
15
|
+
foreign_key: { to_table: :ecom_core_lookups }
|
16
|
+
t.string :components, array: true, default: []
|
17
|
+
t.string :status, null: false
|
18
|
+
t.references :requested_by,
|
19
|
+
null: false,
|
20
|
+
index: { name: 'br_on_rb_indx' },
|
21
|
+
foreign_key: { to_table: :ecom_core_users }
|
22
|
+
t.references :approved_by,
|
23
|
+
null: true,
|
24
|
+
index: { name: 'br_on_ab_indx' },
|
25
|
+
foreign_key: { to_table: :ecom_core_users }
|
26
|
+
t.string :remark
|
27
|
+
|
28
|
+
t.timestamps
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class CreateEcomCoreBookedEquipments < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_core_booked_equipments do |t|
|
4
|
+
t.references :booking_request,
|
5
|
+
null: false,
|
6
|
+
index: { name: 'be_on_br_indx' },
|
7
|
+
foreign_key: { to_table: :ecom_core_booking_requests }
|
8
|
+
t.references :equipment_item,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'be_on_ei_indx' },
|
11
|
+
foreign_key: { to_table: :ecom_core_equipment_items }
|
12
|
+
t.date :start_date, null: false
|
13
|
+
t.date :end_date, null: false
|
14
|
+
t.string :status, null: false, default: 'Booked'
|
15
|
+
t.references :booked_to,
|
16
|
+
null: false,
|
17
|
+
index: { name: 'be_on_bt_indx' },
|
18
|
+
foreign_key: { to_table: :ecom_core_users }
|
19
|
+
t.string :remark
|
20
|
+
|
21
|
+
t.timestamps
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/ecom/core/version.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :booked_equipment, class: Ecom::Core::BookedEquipment do
|
3
|
+
association :booking_request
|
4
|
+
association :equipment_item
|
5
|
+
start_date { Date.yesterday }
|
6
|
+
end_date { Date.today }
|
7
|
+
association :booked_to, factory: :user
|
8
|
+
remark { FFaker::Name.name }
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :booking_request, class: Ecom::Core::BookingRequest do
|
3
|
+
start_date { Date.yesterday }
|
4
|
+
end_date { Date.today }
|
5
|
+
association :equipment
|
6
|
+
quantity { 1 }
|
7
|
+
brand { FFaker::Name.name }
|
8
|
+
association :country
|
9
|
+
association :requested_by, factory: :user
|
10
|
+
association :approved_by, factory: :user
|
11
|
+
components { [FFaker::Name.name, FFaker::Name.name] }
|
12
|
+
status { Ecom::Core::BookingRequest::DRAFT }
|
13
|
+
remark { FFaker::Name.name }
|
14
|
+
end
|
15
|
+
end
|
@@ -3,6 +3,8 @@ FactoryBot.define do
|
|
3
3
|
name { FFaker::Name.name }
|
4
4
|
description { FFaker::Name.name }
|
5
5
|
minimum_acquisition_time { 10 }
|
6
|
+
brands { ['Brand I', 'Brand II', 'Brand III'] }
|
7
|
+
components { ['Component I', 'Component II', 'Component III'] }
|
6
8
|
association :equipment_category
|
7
9
|
end
|
8
10
|
end
|
@@ -2,7 +2,8 @@ FactoryBot.define do
|
|
2
2
|
factory :equipment_item, class: Ecom::Core::EquipmentItem do
|
3
3
|
name { FFaker::Name.name }
|
4
4
|
description { FFaker::Name.name }
|
5
|
-
status {
|
5
|
+
status { Ecom::Core::EquipmentItem::READY }
|
6
|
+
duty_status { Ecom::Core::EquipmentItem::AVAILABLE }
|
6
7
|
serial_number { FFaker::Name.name }
|
7
8
|
brand { FFaker::Name.name }
|
8
9
|
item_model { FFaker::Name.name }
|
@@ -11,6 +12,7 @@ FactoryBot.define do
|
|
11
12
|
license_fee { 200 }
|
12
13
|
tax { 500 }
|
13
14
|
association :equipment
|
15
|
+
association :country
|
14
16
|
association :current_location, factory: :equipment_location
|
15
17
|
end
|
16
18
|
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.
|
4
|
+
version: 1.2.12
|
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-06-
|
11
|
+
date: 2020-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|
@@ -205,7 +205,11 @@ files:
|
|
205
205
|
- app/models/ecom/core/application_record.rb
|
206
206
|
- app/models/ecom/core/attendance_sheet.rb
|
207
207
|
- app/models/ecom/core/attendance_sheet_entry.rb
|
208
|
+
- app/models/ecom/core/booked_equipment.rb
|
209
|
+
- app/models/ecom/core/booking_request.rb
|
208
210
|
- app/models/ecom/core/company.rb
|
211
|
+
- app/models/ecom/core/component_type.rb
|
212
|
+
- app/models/ecom/core/country.rb
|
209
213
|
- app/models/ecom/core/crew.rb
|
210
214
|
- app/models/ecom/core/crew_overtime.rb
|
211
215
|
- app/models/ecom/core/crew_time.rb
|
@@ -251,6 +255,7 @@ files:
|
|
251
255
|
- app/serializers/ecom/core/user_serializer.rb
|
252
256
|
- app/services/ecom/core/menu_service.rb
|
253
257
|
- app/services/ecom/core/token_auth_service.rb
|
258
|
+
- app/validators/ecom/core/date_range_validator.rb
|
254
259
|
- config/database.ci.yml
|
255
260
|
- config/routes.rb
|
256
261
|
- db/migrate/20190101085530_create_ecom_core_companies.rb
|
@@ -292,6 +297,8 @@ files:
|
|
292
297
|
- db/migrate/20200410090701_create_ecom_core_overtime_sheets.rb
|
293
298
|
- db/migrate/20200410100035_create_ecom_core_overtime_sheet_entries.rb
|
294
299
|
- db/migrate/20200410111827_create_ecom_core_crew_overtimes.rb
|
300
|
+
- db/migrate/20200602130247_create_ecom_core_booking_requests.rb
|
301
|
+
- db/migrate/20200603115317_create_ecom_core_booked_equipments.rb
|
295
302
|
- lib/ecom/core.rb
|
296
303
|
- lib/ecom/core/engine.rb
|
297
304
|
- lib/ecom/core/version.rb
|
@@ -300,7 +307,11 @@ files:
|
|
300
307
|
- spec/factories/ecom/core/application_modules.rb
|
301
308
|
- spec/factories/ecom/core/attendance_sheet_entries.rb
|
302
309
|
- spec/factories/ecom/core/attendance_sheets.rb
|
310
|
+
- spec/factories/ecom/core/booked_equipments.rb
|
311
|
+
- spec/factories/ecom/core/booking_requests.rb
|
303
312
|
- spec/factories/ecom/core/companies.rb
|
313
|
+
- spec/factories/ecom/core/component_types.rb
|
314
|
+
- spec/factories/ecom/core/countries.rb
|
304
315
|
- spec/factories/ecom/core/crew_overtimes.rb
|
305
316
|
- spec/factories/ecom/core/crew_times.rb
|
306
317
|
- spec/factories/ecom/core/crew_types.rb
|