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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 716e8bc10325532735dcdd438b66d8d37929de349af86e8c59b30097b9360116
4
- data.tar.gz: 98610a46e22f8defefff9f18be57b45a70187755af5a6eb557c407bba5018de1
3
+ metadata.gz: 53e6b8c84820dca6b1121f9f33ffdffc3f421c2a7aced743a21bac89c25b7580
4
+ data.tar.gz: 557e5da2ed61cca47e0e80002469f9798d9eb96f26a8357f897beea42c4a0062
5
5
  SHA512:
6
- metadata.gz: 42969fb77b55640d97e26f7b673c6b6e5c88109b294778cec2a7a21ac87e4870327b8c2d33d75ed46b8958b4a96039cd9ed8ecdcb5589d8ca0fc0afcabb48021
7
- data.tar.gz: d9e39437dfee8379d4b1823fd950ccca8ddd56ecb92bf5d485c99c6b31365aad08e956240b27d4b0c67cb8e670be9aa4bb59e8e18b3f5dbe22438386c7c38d04
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
@@ -0,0 +1,6 @@
1
+ module Ecom
2
+ module Core
3
+ class ComponentType < Lookup
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Ecom
2
+ module Core
3
+ class Country < Lookup
4
+ end
5
+ end
6
+ end
@@ -2,6 +2,7 @@ module Ecom
2
2
  module Core
3
3
  class EquipmentComponent < ApplicationRecord
4
4
  belongs_to :equipment_item
5
+ belongs_to :component_type
5
6
 
6
7
  validates :name, presence: true
7
8
  end
@@ -1,13 +1,25 @@
1
1
  module Ecom
2
2
  module Core
3
3
  class EquipmentItem < ApplicationRecord
4
- READY = 'Ready'
5
- UNDER_MAINTENANCE = 'Under Maintenance'
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
@@ -1,5 +1,5 @@
1
1
  module Ecom
2
2
  module Core
3
- VERSION = '1.2.11'.freeze
3
+ VERSION = '1.2.12'.freeze
4
4
  end
5
5
  end
@@ -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
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :component_type, class: Ecom::Core::ComponentType, parent: :lookup do
3
+ type { 'Ecom::Core::ComponentType' }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :country, class: Ecom::Core::Country, parent: :lookup do
3
+ type { 'Ecom::Core::Country' }
4
+ end
5
+ 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,6 +2,8 @@ FactoryBot.define do
2
2
  factory :equipment_component, class: Ecom::Core::EquipmentComponent do
3
3
  serial_number { FFaker::Name.name }
4
4
  name { FFaker::Name.name }
5
+ remark { FFaker::Name.name }
5
6
  association :equipment_item
7
+ association :component_type
6
8
  end
7
9
  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 { FFaker::Name.name }
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
@@ -1,6 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :work_product, class: Ecom::Core::WorkProduct do
3
- code { FFaker::Name.unique.name }
3
+ code { FFaker::Name.name }
4
4
  name { FFaker::Name.unique.name }
5
5
  description { FFaker::Name.name }
6
6
  design_reference_no { FFaker::Name.name }
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.11
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-01 00:00:00.000000000 Z
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