ecom_core 1.2.6 → 1.2.12
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/constants/ecom/core/status_constants.rb +11 -0
- data/app/controllers/ecom/core/access_controller.rb +1 -1
- data/app/models/ecom/core/attendance_sheet.rb +24 -18
- 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/crew.rb +8 -2
- data/app/models/ecom/core/crew_overtime.rb +5 -0
- data/app/models/ecom/core/crew_time.rb +7 -2
- data/app/models/ecom/core/equipment_component.rb +1 -0
- data/app/models/ecom/core/equipment_item.rb +14 -2
- data/app/models/ecom/core/overtime_sheet.rb +9 -9
- data/app/models/ecom/core/payroll.rb +4 -0
- data/app/validators/ecom/core/date_range_validator.rb +11 -0
- data/config/database.ci.yml +1 -0
- data/db/migrate/20191225100054_create_ecom_core_crews.rb +3 -1
- data/db/migrate/20191225140433_create_ecom_core_attendance_sheets.rb +2 -1
- 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/20200410090701_create_ecom_core_overtime_sheets.rb +3 -1
- 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/attendance_sheets.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/crews.rb +2 -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/overtime_sheets.rb +1 -1
- data/spec/factories/ecom/core/users.rb +1 -0
- data/spec/factories/ecom/core/work_products.rb +1 -1
- metadata +14 -16
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
|
@@ -18,7 +18,7 @@ module Ecom
|
|
18
18
|
return
|
19
19
|
end
|
20
20
|
|
21
|
-
payload = { id: user.id, email: user.email, name: user.full_name, roles: roles }
|
21
|
+
payload = { id: user.id, email: user.email, name: user.full_name, roles: roles, projects: user.projects }
|
22
22
|
jwt = TokenAuthService.issue(payload)
|
23
23
|
render json: { token: jwt, user: payload, error: nil }
|
24
24
|
else
|
@@ -1,37 +1,43 @@
|
|
1
1
|
module Ecom
|
2
2
|
module Core
|
3
3
|
class AttendanceSheet < ApplicationRecord
|
4
|
-
|
5
|
-
|
6
|
-
APPROVED = 'Approved'.freeze
|
7
|
-
|
8
|
-
validates :date, presence: true, uniqueness: true
|
9
|
-
validates :status, inclusion: [OPEN, SUBMITTED, APPROVED]
|
4
|
+
validates :date, presence: true, uniqueness: { scope: :project_id }
|
5
|
+
validates :status, inclusion: StatusConstants::STATUSES
|
10
6
|
|
11
7
|
belongs_to :project
|
12
8
|
|
13
9
|
has_many :attendance_sheet_entries
|
14
10
|
has_many :crew_times, through: :attendance_sheet_entries
|
15
11
|
|
16
|
-
scope :
|
17
|
-
scope :
|
18
|
-
scope :
|
19
|
-
scope :
|
12
|
+
scope :by_project, ->(id) { where(project_id: id) }
|
13
|
+
scope :by_date, ->(date) { where(date: date) }
|
14
|
+
scope :by_status, ->(status) { where(status: status) }
|
15
|
+
scope :by_date_between, ->(from, to) { where('date BETWEEN ? AND ?', from, to) }
|
20
16
|
|
21
17
|
def self.open_for_date(date, project_id)
|
22
|
-
AttendanceSheet.find_by(status: OPEN, date: date, project_id: project_id)
|
18
|
+
AttendanceSheet.find_by(status: StatusConstants::OPEN, date: date, project_id: project_id)
|
23
19
|
end
|
24
20
|
|
25
21
|
def self.open_exists?(project_id)
|
26
|
-
AttendanceSheet
|
22
|
+
AttendanceSheet
|
23
|
+
.by_project(project_id)
|
24
|
+
.by_status(StatusConstants::OPEN)
|
25
|
+
.exists?
|
27
26
|
end
|
28
27
|
|
29
28
|
def self.exists_for_today?(project_id)
|
30
|
-
AttendanceSheet
|
29
|
+
AttendanceSheet
|
30
|
+
.by_project(project_id)
|
31
|
+
.by_date(Date.today)
|
32
|
+
.exists?
|
31
33
|
end
|
32
34
|
|
33
35
|
def self.open_exists_for_today?(project_id)
|
34
|
-
AttendanceSheet
|
36
|
+
AttendanceSheet
|
37
|
+
.by_project(project_id)
|
38
|
+
.by_date(Date.today)
|
39
|
+
.by_status(StatusConstants::OPEN)
|
40
|
+
.exists?
|
35
41
|
end
|
36
42
|
|
37
43
|
# Attendance sheet should be created using the
|
@@ -46,16 +52,16 @@ module Ecom
|
|
46
52
|
raise 'There is an open attendance sheet which needs to be submitted before creating a new one.'
|
47
53
|
end
|
48
54
|
|
49
|
-
AttendanceSheet.create(date: Date.today, opened_at: Time.now, status: OPEN, project_id: project_id)
|
55
|
+
AttendanceSheet.create(date: Date.today, opened_at: Time.now, status: StatusConstants::OPEN, project_id: project_id)
|
50
56
|
end
|
51
57
|
|
52
58
|
def self.submit_current(project_id)
|
53
|
-
sheet = AttendanceSheet.find_by(date: Date.today, status: OPEN, project_id: project_id)
|
59
|
+
sheet = AttendanceSheet.find_by(date: Date.today, status: StatusConstants::OPEN, project_id: project_id)
|
54
60
|
|
55
61
|
raise 'There is no open attendance sheet to submit.' if sheet.nil?
|
56
62
|
|
57
63
|
sheet.closed_at = Time.now
|
58
|
-
sheet.status = SUBMITTED
|
64
|
+
sheet.status = StatusConstants::SUBMITTED
|
59
65
|
sheet.save
|
60
66
|
sheet
|
61
67
|
end
|
@@ -69,7 +75,7 @@ module Ecom
|
|
69
75
|
raise 'There is no open attendance sheet to submit for the selected day.' unless sheet
|
70
76
|
|
71
77
|
sheet.closed_at = Time.now
|
72
|
-
sheet.status = SUBMITTED
|
78
|
+
sheet.status = StatusConstants::SUBMITTED
|
73
79
|
sheet.save
|
74
80
|
sheet
|
75
81
|
end
|
@@ -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
|
@@ -2,15 +2,21 @@ module Ecom
|
|
2
2
|
module Core
|
3
3
|
class Crew < ApplicationRecord
|
4
4
|
PERMANENT = 'Permanent'.freeze
|
5
|
+
SUPERVISOR = 'Supervisor'.freeze
|
5
6
|
TEMPORARY = 'Temporary'.freeze
|
7
|
+
EMPLOYMENT_TYPES = [PERMANENT, SUPERVISOR, TEMPORARY].freeze
|
6
8
|
|
7
9
|
before_save :set_employment_date,
|
8
10
|
if: proc { |c| c.employment_date.nil? }
|
9
11
|
|
10
12
|
belongs_to :crew_type
|
11
13
|
|
12
|
-
validates :name, :qualification, presence: true
|
13
|
-
validates :employment, inclusion:
|
14
|
+
validates :name, :address, :qualification, :employment, :wage, :wage_in_words, presence: true
|
15
|
+
validates :employment, inclusion: EMPLOYMENT_TYPES
|
16
|
+
|
17
|
+
scope :by_active, ->(active) { where(active: active) }
|
18
|
+
scope :by_qualification, ->(qualification) { where(qualification: qualification) }
|
19
|
+
scope :by_sub_contracted, ->(sub_contracted) { where(sub_contracted: sub_contracted) }
|
14
20
|
|
15
21
|
def set_employment_date
|
16
22
|
self.employment_date = Date.today
|
@@ -10,6 +10,11 @@ module Ecom
|
|
10
10
|
|
11
11
|
validates :hours, :raw_hours, presence: true
|
12
12
|
|
13
|
+
scope :by_overtime, lambda { |id|
|
14
|
+
joins(:overtime_sheet_entry).where(ecom_core_overtime_sheet_entries: { overtime_sheet_id: id })
|
15
|
+
}
|
16
|
+
scope :revised, ->(revised) { where(revised: revised) }
|
17
|
+
|
13
18
|
before_save :calculate_hours
|
14
19
|
|
15
20
|
def calculate_hours
|
@@ -7,8 +7,8 @@ module Ecom
|
|
7
7
|
BOTH = 'Both'.freeze
|
8
8
|
|
9
9
|
TIME_RANGE = {
|
10
|
-
MORNING => {start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('9:00 AM')},
|
11
|
-
AFTERNOON => {start: Time.zone.parse('10:00 AM'), end: Time.zone.parse('2:00 PM')},
|
10
|
+
MORNING => { start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('9:00 AM') },
|
11
|
+
AFTERNOON => { start: Time.zone.parse('10:00 AM'), end: Time.zone.parse('2:00 PM') },
|
12
12
|
BOTH => {start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('2:00 PM')}
|
13
13
|
}.freeze
|
14
14
|
|
@@ -19,6 +19,11 @@ module Ecom
|
|
19
19
|
|
20
20
|
validates :checkin_time, presence: true, if: :checkout_time
|
21
21
|
|
22
|
+
scope :by_attendance, lambda { |id|
|
23
|
+
joins(:attendance_sheet_entry).where(ecom_core_attendance_sheet_entries: { attendance_sheet_id: id })
|
24
|
+
}
|
25
|
+
scope :revised, ->(revised) { where(revised: revised) }
|
26
|
+
|
22
27
|
before_save :calculate_hours
|
23
28
|
after_save :calculate_total
|
24
29
|
|
@@ -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)
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module Ecom
|
2
2
|
module Core
|
3
3
|
class OvertimeSheet < ApplicationRecord
|
4
|
-
|
5
|
-
|
6
|
-
APPROVED = 'Approved'.freeze
|
7
|
-
|
8
|
-
validates :date, :opened_at, presence: true, uniqueness: true
|
9
|
-
validates :status, inclusion: [OPEN, SUBMITTED, APPROVED]
|
4
|
+
validates :date, :opened_at, presence: true, uniqueness: { scope: :project_id }
|
5
|
+
validates :status, inclusion: StatusConstants::STATUSES
|
10
6
|
|
11
7
|
belongs_to :project
|
12
8
|
|
13
9
|
has_many :overtime_sheet_entries
|
14
10
|
has_many :crew_overtimes, through: :overtime_sheet_entries
|
15
11
|
|
16
|
-
scope :
|
17
|
-
scope :
|
12
|
+
scope :by_project, ->(id) { where(project_id: id) }
|
13
|
+
scope :by_date, ->(date) { where(date: date) }
|
14
|
+
scope :by_status, ->(status) { where(status: status) }
|
15
|
+
scope :by_date_between, ->(from, to) { where('date BETWEEN ? AND ?', from, to) }
|
16
|
+
scope :open, ->(id) { where(status: StatusConstants::OPEN, project_id: id) }
|
17
|
+
scope :submitted, ->(id) { where(status: StatusConstants::SUBMITTED, project_id: id) }
|
18
18
|
|
19
19
|
def self.open_exists?(project_id)
|
20
20
|
OvertimeSheet.open(project_id).exists?
|
@@ -38,7 +38,7 @@ module Ecom
|
|
38
38
|
raise 'There is already an open overtime sheet. It has to be submitted before creating a new one.'
|
39
39
|
end
|
40
40
|
|
41
|
-
OvertimeSheet.create(date: date, opened_at: Time.now, status: OPEN, project_id: project_id)
|
41
|
+
OvertimeSheet.create(date: date, opened_at: Time.now, status: StatusConstants::OPEN, project_id: project_id)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -5,6 +5,10 @@ module Ecom
|
|
5
5
|
|
6
6
|
has_many :payments, class_name: 'Ecom::Core::Payment'
|
7
7
|
belongs_to :project
|
8
|
+
|
9
|
+
scope :by_project, ->(id) { where(project_id: id) }
|
10
|
+
scope :by_month, ->(month) { where(month: month) }
|
11
|
+
scope :by_year, ->(year) { where(year: year) }
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
@@ -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
|
data/config/database.ci.yml
CHANGED
@@ -3,11 +3,13 @@ class CreateEcomCoreCrews < ActiveRecord::Migration[6.0]
|
|
3
3
|
create_table :ecom_core_crews do |t|
|
4
4
|
t.string :employee_id
|
5
5
|
t.string :name, null: false
|
6
|
+
t.string :address, null: false
|
6
7
|
t.string :phone
|
7
8
|
t.string :email
|
8
9
|
t.string :qualification, null: false
|
9
10
|
t.string :employment, null: false
|
10
|
-
t.float :wage
|
11
|
+
t.float :wage, null: false
|
12
|
+
t.string :wage_in_words, null: false
|
11
13
|
t.date :employment_date
|
12
14
|
t.boolean :sub_contracted, null: false, default: false
|
13
15
|
t.string :guarantor_name
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CreateEcomCoreAttendanceSheets < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
create_table :ecom_core_attendance_sheets do |t|
|
4
|
-
t.date :date, null: false
|
4
|
+
t.date :date, null: false
|
5
5
|
t.time :opened_at, null: false
|
6
6
|
t.time :closed_at
|
7
7
|
t.string :remark
|
@@ -13,5 +13,6 @@ class CreateEcomCoreAttendanceSheets < ActiveRecord::Migration[6.0]
|
|
13
13
|
|
14
14
|
t.timestamps
|
15
15
|
end
|
16
|
+
add_index :ecom_core_attendance_sheets, %i[date project_id], unique: true
|
16
17
|
end
|
17
18
|
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
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class CreateEcomCoreOvertimeSheets < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
create_table :ecom_core_overtime_sheets do |t|
|
4
|
-
t.date :date, null: false
|
4
|
+
t.date :date, null: false
|
5
5
|
t.time :opened_at, null: false
|
6
6
|
t.time :submitted_at
|
7
|
+
t.string :remark
|
7
8
|
t.string :status, null: false, default: 'Open'
|
8
9
|
t.references :project,
|
9
10
|
null: false,
|
@@ -12,5 +13,6 @@ class CreateEcomCoreOvertimeSheets < ActiveRecord::Migration[6.0]
|
|
12
13
|
|
13
14
|
t.timestamps
|
14
15
|
end
|
16
|
+
add_index :ecom_core_overtime_sheets, %i[date project_id], unique: true
|
15
17
|
end
|
16
18
|
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
|
@@ -1,11 +1,13 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
factory :crew, class: Ecom::Core::Crew do
|
3
3
|
name { FFaker::Name.name }
|
4
|
+
address { FFaker::Name.name }
|
4
5
|
phone { FFaker::Name.name }
|
5
6
|
email { FFaker::Name.name }
|
6
7
|
qualification { FFaker::Name.name }
|
7
8
|
employment { Ecom::Core::Crew::PERMANENT }
|
8
9
|
wage { FFaker::Random.rand(1000..5000) }
|
10
|
+
wage_in_words { FFaker::Name.name }
|
9
11
|
employment_date { Date.today - 1 }
|
10
12
|
sub_contracted { false }
|
11
13
|
guarantor_name { FFaker::Name.name }
|
@@ -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-
|
11
|
+
date: 2020-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|
@@ -178,20 +178,6 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: solargraph
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
195
181
|
description: An engine which contains the core of a construction management app as
|
196
182
|
a layer.
|
197
183
|
email:
|
@@ -203,6 +189,7 @@ files:
|
|
203
189
|
- MIT-LICENSE
|
204
190
|
- README.md
|
205
191
|
- Rakefile
|
192
|
+
- app/constants/ecom/core/status_constants.rb
|
206
193
|
- app/controllers/concerns/ecom/core/lookupable.rb
|
207
194
|
- app/controllers/concerns/ecom/core/resource_typeable.rb
|
208
195
|
- app/controllers/ecom/core/access_controller.rb
|
@@ -218,7 +205,11 @@ files:
|
|
218
205
|
- app/models/ecom/core/application_record.rb
|
219
206
|
- app/models/ecom/core/attendance_sheet.rb
|
220
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
|
221
210
|
- app/models/ecom/core/company.rb
|
211
|
+
- app/models/ecom/core/component_type.rb
|
212
|
+
- app/models/ecom/core/country.rb
|
222
213
|
- app/models/ecom/core/crew.rb
|
223
214
|
- app/models/ecom/core/crew_overtime.rb
|
224
215
|
- app/models/ecom/core/crew_time.rb
|
@@ -264,6 +255,7 @@ files:
|
|
264
255
|
- app/serializers/ecom/core/user_serializer.rb
|
265
256
|
- app/services/ecom/core/menu_service.rb
|
266
257
|
- app/services/ecom/core/token_auth_service.rb
|
258
|
+
- app/validators/ecom/core/date_range_validator.rb
|
267
259
|
- config/database.ci.yml
|
268
260
|
- config/routes.rb
|
269
261
|
- db/migrate/20190101085530_create_ecom_core_companies.rb
|
@@ -305,6 +297,8 @@ files:
|
|
305
297
|
- db/migrate/20200410090701_create_ecom_core_overtime_sheets.rb
|
306
298
|
- db/migrate/20200410100035_create_ecom_core_overtime_sheet_entries.rb
|
307
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
|
308
302
|
- lib/ecom/core.rb
|
309
303
|
- lib/ecom/core/engine.rb
|
310
304
|
- lib/ecom/core/version.rb
|
@@ -313,7 +307,11 @@ files:
|
|
313
307
|
- spec/factories/ecom/core/application_modules.rb
|
314
308
|
- spec/factories/ecom/core/attendance_sheet_entries.rb
|
315
309
|
- spec/factories/ecom/core/attendance_sheets.rb
|
310
|
+
- spec/factories/ecom/core/booked_equipments.rb
|
311
|
+
- spec/factories/ecom/core/booking_requests.rb
|
316
312
|
- spec/factories/ecom/core/companies.rb
|
313
|
+
- spec/factories/ecom/core/component_types.rb
|
314
|
+
- spec/factories/ecom/core/countries.rb
|
317
315
|
- spec/factories/ecom/core/crew_overtimes.rb
|
318
316
|
- spec/factories/ecom/core/crew_times.rb
|
319
317
|
- spec/factories/ecom/core/crew_types.rb
|