ecom_core 1.2.12 → 1.2.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/ecom/core/lookupable.rb +1 -2
  3. data/app/controllers/concerns/ecom/core/resource_typeable.rb +1 -1
  4. data/app/controllers/ecom/core/access_controller.rb +1 -2
  5. data/app/controllers/ecom/core/application_controller.rb +0 -1
  6. data/app/controllers/ecom/core/application_modules_controller.rb +1 -1
  7. data/app/controllers/ecom/core/menus_controller.rb +1 -1
  8. data/app/controllers/ecom/core/user_roles_controller.rb +1 -2
  9. data/app/controllers/ecom/core/users_controller.rb +1 -2
  10. data/app/models/ecom/core/attendance_sheet.rb +2 -1
  11. data/app/models/ecom/core/booked_equipment_item.rb +12 -0
  12. data/app/models/ecom/core/booking.rb +16 -0
  13. data/app/models/ecom/core/component_type.rb +1 -1
  14. data/app/models/ecom/core/crew_time.rb +1 -1
  15. data/app/models/ecom/core/equipment_item.rb +1 -0
  16. data/app/models/ecom/core/equipment_location.rb +2 -1
  17. data/app/models/ecom/core/equipment_request.rb +19 -0
  18. data/app/models/ecom/core/payment.rb +1 -1
  19. data/app/models/ecom/core/requested_item.rb +13 -0
  20. data/app/models/ecom/core/work_product.rb +0 -1
  21. data/app/serializers/ecom/core/lookup_serializer.rb +1 -1
  22. data/app/serializers/ecom/core/resource_type_serializer.rb +1 -1
  23. data/app/serializers/ecom/core/user_role_serializer.rb +1 -1
  24. data/app/services/ecom/core/menu_service.rb +1 -3
  25. data/app/services/ecom/core/token_auth_service.rb +2 -1
  26. data/db/migrate/20200315152143_create_ecom_core_equipment.rb +0 -1
  27. data/db/migrate/20200601104719_create_ecom_core_equipment_requests.rb +18 -0
  28. data/db/migrate/{20200602130247_create_ecom_core_booking_requests.rb → 20200602130247_create_ecom_core_requested_items.rb} +7 -12
  29. data/db/migrate/20200602830603_create_ecom_core_bookings.rb +22 -0
  30. data/db/migrate/20200603115317_create_ecom_core_booked_equipment_items.rb +23 -0
  31. data/lib/ecom/core/engine.rb +0 -1
  32. data/lib/ecom/core/version.rb +1 -1
  33. data/spec/factories/ecom/core/{booked_equipments.rb → booked_equipment_items.rb} +3 -3
  34. data/spec/factories/ecom/core/bookings.rb +9 -0
  35. data/spec/factories/ecom/core/equipment.rb +0 -1
  36. data/spec/factories/ecom/core/equipment_requests.rb +8 -0
  37. data/spec/factories/ecom/core/requested_items.rb +13 -0
  38. data/spec/factories/ecom/core/task_templates.rb +0 -1
  39. data/spec/factories/ecom/core/users.rb +1 -1
  40. metadata +13 -7
  41. data/app/models/ecom/core/booked_equipment.rb +0 -19
  42. data/app/models/ecom/core/booking_request.rb +0 -26
  43. data/db/migrate/20200603115317_create_ecom_core_booked_equipments.rb +0 -24
  44. data/spec/factories/ecom/core/booking_requests.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53e6b8c84820dca6b1121f9f33ffdffc3f421c2a7aced743a21bac89c25b7580
4
- data.tar.gz: 557e5da2ed61cca47e0e80002469f9798d9eb96f26a8357f897beea42c4a0062
3
+ metadata.gz: 785564a6c5e451baa829ed1114ec89b5fb0247a3894a09fd2683b2967e1ae49b
4
+ data.tar.gz: d0dbc33358d5759b276f0d92575efc6e2333f2bac15674deb81a40c6b5cb850a
5
5
  SHA512:
6
- metadata.gz: 23b9c88cb223aa6afec885e5937089695952810e383121f9511a94b58fa5c8fe86787aad5573a61d382511d31bb643a40ba1fe0b50dafe1ea9e4ba7bbf82060f
7
- data.tar.gz: d35a3ede79f6735372668c8812e2b49f3b6653bdd577f6b95b936f2a23177c2f8467c3d307a42b07363d6d36189e0374e351305c8908bcdc20ccc3ce1453d666
6
+ metadata.gz: be05151af2bb4f6117929e9a220ee1a466629464704ba24054f1be4da8ac1b67f03b8fb8affcea5958d8d6e6f18681f0783dce2744d2f01ef00be6af2479fa0d
7
+ data.tar.gz: 87f31a859e9e3c2aaa26af4ae2627a425883e4ab3a8c555bbf3a0ed80b30b754fd9ca0ecce920bee1a78fc69f8ab9f266c5878bea6f3fb6814595e8a0e28290c
@@ -29,7 +29,6 @@ module Ecom
29
29
  end
30
30
  end
31
31
 
32
-
33
32
  private
34
33
 
35
34
  def set_clazz
@@ -41,4 +40,4 @@ module Ecom
41
40
  end
42
41
  end
43
42
  end
44
- end
43
+ end
@@ -40,4 +40,4 @@ module Ecom
40
40
  end
41
41
  end
42
42
  end
43
- end
43
+ end
@@ -34,7 +34,6 @@ module Ecom
34
34
  def auth_params
35
35
  params.require(:auth).permit(:email, :password)
36
36
  end
37
-
38
37
  end
39
38
  end
40
- end
39
+ end
@@ -14,7 +14,6 @@ module Ecom
14
14
  @current_user ||= user if user
15
15
  end
16
16
 
17
-
18
17
  private
19
18
 
20
19
  def authenticate
@@ -30,4 +30,4 @@ module Ecom
30
30
  end
31
31
  end
32
32
  end
33
- end
33
+ end
@@ -7,4 +7,4 @@ module Ecom
7
7
  end
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -25,7 +25,6 @@ module Ecom
25
25
  end
26
26
  end
27
27
 
28
-
29
28
  private
30
29
 
31
30
  def set_user_role
@@ -37,4 +36,4 @@ module Ecom
37
36
  end
38
37
  end
39
38
  end
40
- end
39
+ end
@@ -28,7 +28,6 @@ module Ecom
28
28
  end
29
29
  end
30
30
 
31
-
32
31
  private
33
32
 
34
33
  def set_user
@@ -40,4 +39,4 @@ module Ecom
40
39
  end
41
40
  end
42
41
  end
43
- end
42
+ end
@@ -52,7 +52,8 @@ module Ecom
52
52
  raise 'There is an open attendance sheet which needs to be submitted before creating a new one.'
53
53
  end
54
54
 
55
- AttendanceSheet.create(date: Date.today, opened_at: Time.now, status: StatusConstants::OPEN, project_id: project_id)
55
+ AttendanceSheet.create(date: Date.today, opened_at: Time.now, status: StatusConstants::OPEN,
56
+ project_id: project_id)
56
57
  end
57
58
 
58
59
  def self.submit_current(project_id)
@@ -0,0 +1,12 @@
1
+ module Ecom
2
+ module Core
3
+ class BookedEquipmentItem < ApplicationRecord
4
+ belongs_to :booking
5
+ belongs_to :requested_item
6
+ belongs_to :equipment_item
7
+
8
+ validates :start_date, :end_date, presence: true
9
+ validates_with DateRangeValidator
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ module Ecom
2
+ module Core
3
+ class Booking < ApplicationRecord
4
+ APPROVED = 'Approved'.freeze
5
+ UNAPPROVED = 'Unapproved'.freeze
6
+
7
+ STATUSES = [APPROVED, UNAPPROVED].freeze
8
+
9
+ belongs_to :equipment_request
10
+ belongs_to :booked_by, class_name: 'Ecom::Core::User'
11
+ belongs_to :booked_for, class_name: 'Ecom::Core::User'
12
+
13
+ validates :status, presence: true, inclusion: STATUSES
14
+ end
15
+ end
16
+ end
@@ -3,4 +3,4 @@ module Ecom
3
3
  class ComponentType < Lookup
4
4
  end
5
5
  end
6
- end
6
+ end
@@ -9,7 +9,7 @@ module Ecom
9
9
  TIME_RANGE = {
10
10
  MORNING => { start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('9:00 AM') },
11
11
  AFTERNOON => { start: Time.zone.parse('10:00 AM'), end: Time.zone.parse('2:00 PM') },
12
- BOTH => {start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('2:00 PM')}
12
+ BOTH => { start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('2:00 PM') }
13
13
  }.freeze
14
14
 
15
15
  belongs_to :attendance_sheet_entry
@@ -15,6 +15,7 @@ module Ecom
15
15
  belongs_to :equipment
16
16
  belongs_to :country
17
17
  belongs_to :current_location, class_name: 'Ecom::Core::EquipmentLocation'
18
+ has_many :equipment_components
18
19
 
19
20
  validates :name, :status, :serial_number, :purchase_date, :purchase_price, presence: true
20
21
  validates :status, inclusion: EQUIPMENT_STATUSES
@@ -18,7 +18,8 @@ module Ecom
18
18
  joins(:location_type).where(
19
19
  'ecom_core_lookups.name = ? AND ecom_core_lookups.type = ?',
20
20
  LocationType::STORE,
21
- Ecom::Core::LocationType)
21
+ Ecom::Core::LocationType
22
+ )
22
23
  }
23
24
  end
24
25
  end
@@ -0,0 +1,19 @@
1
+ module Ecom
2
+ module Core
3
+ class EquipmentRequest < 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 :project
11
+ belongs_to :requested_by, class_name: 'Ecom::Core::User'
12
+ has_one :booking
13
+
14
+ validates :status, presence: true, inclusion: STATUSES
15
+
16
+ scope :by_status, ->(status) { where(status: status) }
17
+ end
18
+ end
19
+ end
@@ -17,4 +17,4 @@ module Ecom
17
17
  end
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -0,0 +1,13 @@
1
+ module Ecom
2
+ module Core
3
+ class RequestedItem < ApplicationRecord
4
+ belongs_to :equipment_request
5
+ belongs_to :equipment
6
+ belongs_to :country, optional: true
7
+
8
+ validates :start_date, :end_date, :quantity, presence: true
9
+ validates :quantity, numericality: { only_integer: true, greater_than: 0 }
10
+ validates_with DateRangeValidator
11
+ end
12
+ end
13
+ end
@@ -12,7 +12,6 @@
12
12
  # way as chart of accounts to identify parent and child relationships. Even then,
13
13
  # there needs to be a well defined coding scheme developed before using the column
14
14
  # field.
15
- #
16
15
  module Ecom
17
16
  module Core
18
17
  class WorkProduct < ApplicationRecord
@@ -4,4 +4,4 @@ module Ecom
4
4
  attributes :id, :name, :type
5
5
  end
6
6
  end
7
- end
7
+ end
@@ -4,4 +4,4 @@ module Ecom
4
4
  attributes :id, :code, :name, :base_unit, :type
5
5
  end
6
6
  end
7
- end
7
+ end
@@ -4,4 +4,4 @@ module Ecom
4
4
  attributes :id, :name
5
5
  end
6
6
  end
7
- end
7
+ end
@@ -14,9 +14,7 @@ module Ecom
14
14
 
15
15
  menu_list.each do |ml|
16
16
  ml[:items] = menu.reject { |m| m.parent.nil? }.each_with_object([]) do |item, list|
17
- if item.parent_id == ml[:id]
18
- list << { id: item.id, text: item.label, iconCss: item.icon, url: item.route }
19
- end
17
+ list << { id: item.id, text: item.label, iconCss: item.icon, url: item.route } if item.parent_id == ml[:id]
20
18
  end
21
19
  end
22
20
  { success: true, data: menu_list }
@@ -3,7 +3,8 @@ require 'jwt'
3
3
  module Ecom
4
4
  module Core
5
5
  class TokenAuthService
6
- AUTH_SECRET = '31a70abfaa57e5e77a3fc9f27aeaaf59b9a9f5355b5e16c842ee172035a8ed40bf82c1c971ecc176e4f0b4c9e6141db07fd4a5af3f7db9265e719fbe340b105a'
6
+ AUTH_SECRET = '31a70abfaa57e5e77a3fc9f27aeaaf59b9a9f5355b5e16c842ee172035a8ed40bf82c1c971ecc176e4f0b4c9e6141db07'\
7
+ 'fd4a5af3f7db9265e719fbe340b105a'.freeze
7
8
 
8
9
  def self.issue(payload)
9
10
  JWT.encode(payload, auth_secret, 'HS256')
@@ -5,7 +5,6 @@ class CreateEcomCoreEquipment < ActiveRecord::Migration[6.0]
5
5
  t.string :description
6
6
  t.float :minimum_acquisition_time, null: false, default: 0
7
7
  t.string :brands, array: true, default: []
8
- t.string :components, array: true, default: []
9
8
  t.references :equipment_category,
10
9
  null: false,
11
10
  index: { name: 'ec_on_ece_indx' },
@@ -0,0 +1,18 @@
1
+ class CreateEcomCoreEquipmentRequests < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_equipment_requests do |t|
4
+ t.references :requested_by,
5
+ null: false,
6
+ index: { name: 'er_on_rb_indx' },
7
+ foreign_key: { to_table: :ecom_core_users }
8
+ t.string :remark
9
+ t.string :status, null: false
10
+ t.references :project,
11
+ null: false,
12
+ index: { name: 'er_on_project_indx' },
13
+ foreign_key: { to_table: :ecom_core_projects }
14
+
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,10 @@
1
- class CreateEcomCoreBookingRequests < ActiveRecord::Migration[6.0]
1
+ class CreateEcomCoreRequestedItems < ActiveRecord::Migration[6.0]
2
2
  def change
3
- create_table :ecom_core_booking_requests do |t|
3
+ create_table :ecom_core_requested_items do |t|
4
+ t.references :equipment_request,
5
+ null: false,
6
+ index: { name: 'ri_on_er_indx' },
7
+ foreign_key: { to_table: :ecom_core_equipment_requests }
4
8
  t.date :start_date, null: false
5
9
  t.date :end_date, null: false
6
10
  t.references :equipment,
@@ -13,16 +17,7 @@ class CreateEcomCoreBookingRequests < ActiveRecord::Migration[6.0]
13
17
  null: true,
14
18
  index: { name: 'br_on_country_indx' },
15
19
  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 }
20
+ t.integer :components, array: true, default: []
26
21
  t.string :remark
27
22
 
28
23
  t.timestamps
@@ -0,0 +1,22 @@
1
+ class CreateEcomCoreBookings < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_bookings do |t|
4
+ t.references :equipment_request,
5
+ null: false,
6
+ index: { name: 'booking_on_er_indx' },
7
+ foreign_key: { to_table: :ecom_core_equipment_requests }
8
+ t.references :booked_by,
9
+ null: false,
10
+ index: { name: 'er_on_bb_indx' },
11
+ foreign_key: { to_table: :ecom_core_users }
12
+ t.references :booked_for,
13
+ null: false,
14
+ index: { name: 'booking_on_bf_indx' },
15
+ foreign_key: { to_table: :ecom_core_users }
16
+ t.string :remark
17
+ t.string :status, null: false
18
+
19
+ t.timestamps
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ class CreateEcomCoreBookedEquipmentItems < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_booked_equipment_items do |t|
4
+ t.references :booking,
5
+ null: false,
6
+ index: { name: 'bei_on_booking_indx' },
7
+ foreign_key: { to_table: :ecom_core_bookings }
8
+ t.references :requested_item,
9
+ null: false,
10
+ index: { name: 'bei_on_ri_indx' },
11
+ foreign_key: { to_table: :ecom_core_bookings }
12
+ t.references :equipment_item,
13
+ null: false,
14
+ index: { name: 'be_on_ei_indx' },
15
+ foreign_key: { to_table: :ecom_core_equipment_items }
16
+ t.date :start_date, null: false
17
+ t.date :end_date, null: false
18
+ t.string :remark
19
+
20
+ t.timestamps
21
+ end
22
+ end
23
+ end
@@ -19,7 +19,6 @@ module Ecom
19
19
  app.config.paths['db/migrate'].concat(config.paths['db/migrate'].expanded)
20
20
  end
21
21
  end
22
-
23
22
  end
24
23
  end
25
24
  end
@@ -1,5 +1,5 @@
1
1
  module Ecom
2
2
  module Core
3
- VERSION = '1.2.12'.freeze
3
+ VERSION = '1.2.13'.freeze
4
4
  end
5
5
  end
@@ -1,10 +1,10 @@
1
1
  FactoryBot.define do
2
- factory :booked_equipment, class: Ecom::Core::BookedEquipment do
3
- association :booking_request
2
+ factory :booked_equipment_item, class: Ecom::Core::BookedEquipmentItem do
3
+ association :booking
4
+ association :requested_item
4
5
  association :equipment_item
5
6
  start_date { Date.yesterday }
6
7
  end_date { Date.today }
7
- association :booked_to, factory: :user
8
8
  remark { FFaker::Name.name }
9
9
  end
10
10
  end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :booking, class: Ecom::Core::Booking do
3
+ association :equipment_request
4
+ association :booked_by, factory: :user
5
+ association :booked_for, factory: :user
6
+ remark { FFaker::Name.name }
7
+ status { Ecom::Core::Booking::UNAPPROVED }
8
+ end
9
+ end
@@ -4,7 +4,6 @@ FactoryBot.define do
4
4
  description { FFaker::Name.name }
5
5
  minimum_acquisition_time { 10 }
6
6
  brands { ['Brand I', 'Brand II', 'Brand III'] }
7
- components { ['Component I', 'Component II', 'Component III'] }
8
7
  association :equipment_category
9
8
  end
10
9
  end
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :equipment_request, class: Ecom::Core::EquipmentRequest do
3
+ association :requested_by, factory: :user
4
+ remark { FFaker::Name.name }
5
+ status { Ecom::Core::EquipmentRequest::DRAFT }
6
+ association :project
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ FactoryBot.define do
2
+ factory :requested_item, class: Ecom::Core::RequestedItem do
3
+ association :equipment_request
4
+ start_date { Date.yesterday }
5
+ end_date { Date.today }
6
+ association :equipment
7
+ quantity { 1 }
8
+ brand { FFaker::Name.name }
9
+ association :country
10
+ components { [] }
11
+ remark { FFaker::Name.name }
12
+ end
13
+ end
@@ -10,6 +10,5 @@ FactoryBot.define do
10
10
  create(:work_product_template, task_template: task_template)
11
11
  end
12
12
  end
13
-
14
13
  end
15
14
  end
@@ -5,6 +5,6 @@ FactoryBot.define do
5
5
  email { FFaker::Internet.email }
6
6
  active { true }
7
7
  password { FFaker::Internet.password }
8
- projects { [{ id: 1, name: 'Sample Project'}] }
8
+ projects { [{ id: 1, name: 'Sample Project' }] }
9
9
  end
10
10
  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.2.12
4
+ version: 1.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
@@ -205,8 +205,8 @@ 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
+ - app/models/ecom/core/booked_equipment_item.rb
209
+ - app/models/ecom/core/booking.rb
210
210
  - app/models/ecom/core/company.rb
211
211
  - app/models/ecom/core/component_type.rb
212
212
  - app/models/ecom/core/country.rb
@@ -221,6 +221,7 @@ files:
221
221
  - app/models/ecom/core/equipment_component.rb
222
222
  - app/models/ecom/core/equipment_item.rb
223
223
  - app/models/ecom/core/equipment_location.rb
224
+ - app/models/ecom/core/equipment_request.rb
224
225
  - app/models/ecom/core/equipment_type.rb
225
226
  - app/models/ecom/core/equipment_valuation.rb
226
227
  - app/models/ecom/core/location_type.rb
@@ -236,6 +237,7 @@ files:
236
237
  - app/models/ecom/core/product_type.rb
237
238
  - app/models/ecom/core/project.rb
238
239
  - app/models/ecom/core/project_crew.rb
240
+ - app/models/ecom/core/requested_item.rb
239
241
  - app/models/ecom/core/resource_type.rb
240
242
  - app/models/ecom/core/stakeholder.rb
241
243
  - app/models/ecom/core/stakeholder_type.rb
@@ -297,8 +299,10 @@ files:
297
299
  - db/migrate/20200410090701_create_ecom_core_overtime_sheets.rb
298
300
  - db/migrate/20200410100035_create_ecom_core_overtime_sheet_entries.rb
299
301
  - 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
302
+ - db/migrate/20200601104719_create_ecom_core_equipment_requests.rb
303
+ - db/migrate/20200602130247_create_ecom_core_requested_items.rb
304
+ - db/migrate/20200602830603_create_ecom_core_bookings.rb
305
+ - db/migrate/20200603115317_create_ecom_core_booked_equipment_items.rb
302
306
  - lib/ecom/core.rb
303
307
  - lib/ecom/core/engine.rb
304
308
  - lib/ecom/core/version.rb
@@ -307,8 +311,8 @@ files:
307
311
  - spec/factories/ecom/core/application_modules.rb
308
312
  - spec/factories/ecom/core/attendance_sheet_entries.rb
309
313
  - spec/factories/ecom/core/attendance_sheets.rb
310
- - spec/factories/ecom/core/booked_equipments.rb
311
- - spec/factories/ecom/core/booking_requests.rb
314
+ - spec/factories/ecom/core/booked_equipment_items.rb
315
+ - spec/factories/ecom/core/bookings.rb
312
316
  - spec/factories/ecom/core/companies.rb
313
317
  - spec/factories/ecom/core/component_types.rb
314
318
  - spec/factories/ecom/core/countries.rb
@@ -323,6 +327,7 @@ files:
323
327
  - spec/factories/ecom/core/equipment_components.rb
324
328
  - spec/factories/ecom/core/equipment_items.rb
325
329
  - spec/factories/ecom/core/equipment_locations.rb
330
+ - spec/factories/ecom/core/equipment_requests.rb
326
331
  - spec/factories/ecom/core/equipment_types.rb
327
332
  - spec/factories/ecom/core/equipment_valuations.rb
328
333
  - spec/factories/ecom/core/location_types.rb
@@ -338,6 +343,7 @@ files:
338
343
  - spec/factories/ecom/core/product_types.rb
339
344
  - spec/factories/ecom/core/project_crews.rb
340
345
  - spec/factories/ecom/core/projects.rb
346
+ - spec/factories/ecom/core/requested_items.rb
341
347
  - spec/factories/ecom/core/resource_types.rb
342
348
  - spec/factories/ecom/core/stakeholder_types.rb
343
349
  - spec/factories/ecom/core/stakeholders.rb
@@ -1,19 +0,0 @@
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
@@ -1,26 +0,0 @@
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,24 +0,0 @@
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,15 +0,0 @@
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