ecom_core 1.2.5 → 1.2.6
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/attendance_sheet.rb +24 -19
- data/app/models/ecom/core/attendance_sheet_entry.rb +1 -1
- data/app/models/ecom/core/company.rb +10 -0
- data/app/models/ecom/core/crew.rb +0 -2
- data/app/models/ecom/core/crew_overtime.rb +1 -1
- data/app/models/ecom/core/crew_time.rb +0 -3
- data/app/models/ecom/core/overtime_sheet.rb +13 -10
- data/app/models/ecom/core/payment_detail.rb +1 -1
- data/app/models/ecom/core/payroll.rb +1 -0
- data/app/models/ecom/core/project.rb +4 -0
- data/app/models/ecom/core/project_crew.rb +15 -0
- data/db/migrate/20190101085530_create_ecom_core_companies.rb +14 -0
- data/db/migrate/20191119012030_create_ecom_core_task_templates.rb +4 -3
- data/db/migrate/20191119013236_create_ecom_core_work_product_templates.rb +4 -3
- data/db/migrate/20191119144618_create_ecom_core_stakeholders.rb +4 -3
- data/db/migrate/20191201131341_create_ecom_core_product_types.rb +4 -2
- data/db/migrate/20191201134420_create_ecom_core_work_component_templates.rb +8 -6
- data/db/migrate/20191201145848_create_ecom_core_projects.rb +28 -13
- data/db/migrate/20191202103735_create_ecom_core_tasks.rb +8 -5
- data/db/migrate/20191202105355_create_task_templates_resource_types.rb +8 -7
- data/db/migrate/20191202220832_create_ecom_core_users.rb +9 -6
- data/db/migrate/20191202220953_create_ecom_core_user_roles.rb +13 -8
- data/db/migrate/20191202221423_create_ecom_core_menus.rb +16 -9
- data/db/migrate/20191202235434_create_ecom_core_work_products.rb +29 -15
- data/db/migrate/20191206104247_create_ecom_core_work_components.rb +24 -14
- data/db/migrate/20191225100054_create_ecom_core_crews.rb +5 -3
- data/db/migrate/20191225121850_create_ecom_core_project_crews.rb +19 -0
- data/db/migrate/{20200401040433_create_ecom_core_attendance_sheets.rb → 20191225140433_create_ecom_core_attendance_sheets.rb} +4 -0
- data/db/migrate/20191225162539_create_ecom_core_attendance_sheet_entries.rb +17 -0
- data/db/migrate/20191225211712_create_ecom_core_crew_times.rb +15 -9
- data/db/migrate/20200126081005_create_ecom_core_payrolls.rb +4 -0
- data/db/migrate/20200126082103_create_ecom_core_payments.rb +6 -3
- data/db/migrate/20200126183218_create_ecom_core_payment_details.rb +10 -5
- data/db/migrate/20200307112519_create_ecom_core_custom_payment_details.rb +4 -3
- data/db/migrate/20200315145215_create_ecom_core_equipment_locations.rb +4 -3
- data/db/migrate/20200315150500_create_ecom_core_equipment_categories.rb +4 -2
- data/db/migrate/20200315152143_create_ecom_core_equipment.rb +4 -2
- data/db/migrate/20200315153640_create_ecom_core_equipment_items.rb +8 -5
- data/db/migrate/20200315160810_create_ecom_core_equipment_valuations.rb +4 -3
- data/db/migrate/20200316125323_create_ecom_core_equipment_components.rb +4 -3
- data/db/migrate/20200410090701_create_ecom_core_overtime_sheets.rb +4 -0
- data/db/migrate/20200410100035_create_ecom_core_overtime_sheet_entries.rb +8 -5
- data/db/migrate/20200410111827_create_ecom_core_crew_overtimes.rb +17 -11
- data/lib/ecom/core/version.rb +1 -1
- data/spec/factories/ecom/core/application_modules.rb +1 -1
- data/spec/factories/ecom/core/attendance_sheet_entries.rb +1 -1
- data/spec/factories/ecom/core/attendance_sheets.rb +2 -1
- data/spec/factories/ecom/core/companies.rb +9 -0
- data/spec/factories/ecom/core/crew_overtimes.rb +1 -1
- data/spec/factories/ecom/core/crew_times.rb +1 -1
- data/spec/factories/ecom/core/crew_types.rb +1 -1
- data/spec/factories/ecom/core/crews.rb +1 -1
- data/spec/factories/ecom/core/currencies.rb +1 -1
- data/spec/factories/ecom/core/custom_payment_details.rb +1 -1
- data/spec/factories/ecom/core/equipment.rb +1 -1
- data/spec/factories/ecom/core/equipment_categories.rb +1 -1
- data/spec/factories/ecom/core/equipment_components.rb +1 -1
- data/spec/factories/ecom/core/equipment_items.rb +1 -1
- data/spec/factories/ecom/core/equipment_locations.rb +1 -1
- data/spec/factories/ecom/core/equipment_types.rb +1 -1
- data/spec/factories/ecom/core/equipment_valuations.rb +1 -1
- data/spec/factories/ecom/core/location_types.rb +1 -1
- data/spec/factories/ecom/core/lookups.rb +1 -1
- data/spec/factories/ecom/core/material_types.rb +1 -1
- data/spec/factories/ecom/core/menus.rb +1 -1
- data/spec/factories/ecom/core/overtime_sheet_entries.rb +1 -1
- data/spec/factories/ecom/core/overtime_sheets.rb +2 -1
- data/spec/factories/ecom/core/overtime_types.rb +1 -1
- data/spec/factories/ecom/core/payment_details.rb +1 -1
- data/spec/factories/ecom/core/payments.rb +1 -1
- data/spec/factories/ecom/core/payrolls.rb +2 -1
- data/spec/factories/ecom/core/product_types.rb +1 -1
- data/spec/factories/ecom/core/project_crews.rb +9 -0
- data/spec/factories/ecom/core/projects.rb +2 -1
- data/spec/factories/ecom/core/resource_types.rb +1 -1
- data/spec/factories/ecom/core/stakeholder_types.rb +1 -1
- data/spec/factories/ecom/core/stakeholders.rb +1 -1
- data/spec/factories/ecom/core/task_template_types.rb +1 -1
- data/spec/factories/ecom/core/task_templates.rb +1 -1
- data/spec/factories/ecom/core/tasks.rb +1 -1
- data/spec/factories/ecom/core/user_roles.rb +1 -1
- data/spec/factories/ecom/core/users.rb +1 -1
- data/spec/factories/ecom/core/work_component_templates.rb +1 -1
- data/spec/factories/ecom/core/work_components.rb +1 -1
- data/spec/factories/ecom/core/work_product_templates.rb +1 -1
- data/spec/factories/ecom/core/work_products.rb +2 -2
- metadata +25 -15
- data/db/migrate/20200207035823_add_additional_columns_to_payment.rb +0 -6
- data/db/migrate/20200207040844_add_net_pay_column_to_payment_details.rb +0 -5
- data/db/migrate/20200210095535_add_advance_column_to_payment_details.rb +0 -5
- data/db/migrate/20200221123207_add_employee_id_to_crew.rb +0 -5
- data/db/migrate/20200401071343_remove_date_column_from_crew_times.rb +0 -5
- data/db/migrate/20200401122539_create_ecom_core_attendance_sheet_entries.rb +0 -14
- data/db/migrate/20200401142959_relate_crew_time_with_attendance_sheet_entry.rb +0 -8
- data/db/migrate/20200401144137_remove_crew_time_id_from_crew.rb +0 -7
- data/db/migrate/20200413144023_fix_crew_time_columns.rb +0 -17
- data/db/migrate/20200414044144_adjust_crew_overtime_column_names.rb +0 -6
- data/db/migrate/20200414185248_change_time_columns_to_datetime.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa793b02a7d9a24882708250c891541910d0f2d4d97c8e713f0226a03da2c7b9
|
4
|
+
data.tar.gz: 102319f9e9313bac6294441dbb4218dc3ed61fd527b4e5fdc81fbf6e3f70032e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a80e478986df2a080fc9573565fcbe99bb75313c95a54946d74b731633c2f67877dc9371ddd014c9cbd6b358edeef1319b2e8c00b632a2c404b03479eb4e7c97
|
7
|
+
data.tar.gz: 3bcfcd09666b8847e6d61ae03908a799eb7ce02322fa97f42a78a2d4dbdac81a40aa22d4cf44967a0bd52ecea8587b8120f71248aaf7feb55e0ad6c0b5a5f809
|
@@ -8,27 +8,30 @@ module Ecom
|
|
8
8
|
validates :date, presence: true, uniqueness: true
|
9
9
|
validates :status, inclusion: [OPEN, SUBMITTED, APPROVED]
|
10
10
|
|
11
|
+
belongs_to :project
|
12
|
+
|
11
13
|
has_many :attendance_sheet_entries
|
12
14
|
has_many :crew_times, through: :attendance_sheet_entries
|
13
15
|
|
14
|
-
scope :open, -> { where(status: OPEN) }
|
15
|
-
scope :
|
16
|
-
scope :
|
16
|
+
scope :open, ->(id) { where(status: OPEN, project_id: id) }
|
17
|
+
scope :submitted, ->(id) { where(status: SUBMITTED, project_id: id) }
|
18
|
+
scope :current, ->(id) { where(date: Date.today, project_id: id) }
|
19
|
+
scope :current_open, ->(id) { where(date: Date.today, project_id: id, status: OPEN) }
|
17
20
|
|
18
|
-
def self.open_for_date(date)
|
19
|
-
AttendanceSheet.find_by(status: OPEN, date: date)
|
21
|
+
def self.open_for_date(date, project_id)
|
22
|
+
AttendanceSheet.find_by(status: OPEN, date: date, project_id: project_id)
|
20
23
|
end
|
21
24
|
|
22
|
-
def self.open_exists?
|
23
|
-
AttendanceSheet.open.exists?
|
25
|
+
def self.open_exists?(project_id)
|
26
|
+
AttendanceSheet.open(project_id).exists?
|
24
27
|
end
|
25
28
|
|
26
|
-
def self.exists_for_today?
|
27
|
-
AttendanceSheet.current.exists?
|
29
|
+
def self.exists_for_today?(project_id)
|
30
|
+
AttendanceSheet.current(project_id).exists?
|
28
31
|
end
|
29
32
|
|
30
|
-
def self.open_exists_for_today?
|
31
|
-
AttendanceSheet.current_open.exists?
|
33
|
+
def self.open_exists_for_today?(project_id)
|
34
|
+
AttendanceSheet.current_open(project_id).exists?
|
32
35
|
end
|
33
36
|
|
34
37
|
# Attendance sheet should be created using the
|
@@ -36,16 +39,18 @@ module Ecom
|
|
36
39
|
# check if there is an open attendance already,
|
37
40
|
# and also that we have only one attendace sheet
|
38
41
|
# per day.
|
39
|
-
def self.create_current
|
40
|
-
raise 'Attendance sheet already created for the day.' if AttendanceSheet.exists_for_today?
|
42
|
+
def self.create_current(project_id)
|
43
|
+
raise 'Attendance sheet already created for the day.' if AttendanceSheet.exists_for_today?(project_id)
|
41
44
|
|
42
|
-
|
45
|
+
if AttendanceSheet.open_exists?(project_id)
|
46
|
+
raise 'There is an open attendance sheet which needs to be submitted before creating a new one.'
|
47
|
+
end
|
43
48
|
|
44
|
-
AttendanceSheet.create(date: Date.today, opened_at: Time.now, status: OPEN)
|
49
|
+
AttendanceSheet.create(date: Date.today, opened_at: Time.now, status: OPEN, project_id: project_id)
|
45
50
|
end
|
46
51
|
|
47
|
-
def self.submit_current
|
48
|
-
sheet = AttendanceSheet.find_by(date: Date.today, status: OPEN)
|
52
|
+
def self.submit_current(project_id)
|
53
|
+
sheet = AttendanceSheet.find_by(date: Date.today, status: OPEN, project_id: project_id)
|
49
54
|
|
50
55
|
raise 'There is no open attendance sheet to submit.' if sheet.nil?
|
51
56
|
|
@@ -59,8 +64,8 @@ module Ecom
|
|
59
64
|
# to submit the attendance sheet after the date has
|
60
65
|
# passed. Normally, timekeepers need to open and close
|
61
66
|
# an attendance sheet of a date on the specific date.
|
62
|
-
def self.submit(date)
|
63
|
-
sheet = AttendanceSheet.open_for_date(date)
|
67
|
+
def self.submit(date, project_id)
|
68
|
+
sheet = AttendanceSheet.open_for_date(date, project_id)
|
64
69
|
raise 'There is no open attendance sheet to submit for the selected day.' unless sheet
|
65
70
|
|
66
71
|
sheet.closed_at = Time.now
|
@@ -11,8 +11,6 @@ module Ecom
|
|
11
11
|
|
12
12
|
validates :name, :qualification, presence: true
|
13
13
|
validates :employment, inclusion: [PERMANENT, TEMPORARY]
|
14
|
-
#validates :wage, presence: true, if: ->(o) { o.employment == PERMANENT }
|
15
|
-
#validates :wage, absence: true, if: ->(o) { o.employment == TEMPORARY }
|
16
14
|
|
17
15
|
def set_employment_date
|
18
16
|
self.employment_date = Date.today
|
@@ -61,13 +61,10 @@ module Ecom
|
|
61
61
|
start = Time.zone.parse(checkin_time.strftime('%I:%M%p'))
|
62
62
|
finish = Time.zone.parse(checkout_time.strftime('%I:%M%p'))
|
63
63
|
range = find_range(start, finish)
|
64
|
-
puts "Found the range #{range} for [#{start} - #{finish}]"
|
65
64
|
left = start.before?(TIME_RANGE[range][:start]) ? TIME_RANGE[range][:start] : start
|
66
65
|
right = finish.after?(TIME_RANGE[range][:end]) ? TIME_RANGE[range][:end] : finish
|
67
|
-
puts "Applicable time range is [#{left} - #{right}]"
|
68
66
|
time = (right - left) / 1.hour
|
69
67
|
time -= 1 if range == BOTH
|
70
|
-
puts "Calculated time is #{time}"
|
71
68
|
time
|
72
69
|
end
|
73
70
|
end
|
@@ -8,17 +8,20 @@ module Ecom
|
|
8
8
|
validates :date, :opened_at, presence: true, uniqueness: true
|
9
9
|
validates :status, inclusion: [OPEN, SUBMITTED, APPROVED]
|
10
10
|
|
11
|
+
belongs_to :project
|
12
|
+
|
11
13
|
has_many :overtime_sheet_entries
|
14
|
+
has_many :crew_overtimes, through: :overtime_sheet_entries
|
12
15
|
|
13
|
-
scope :open, -> { where(status: OPEN) }
|
14
|
-
scope :
|
16
|
+
scope :open, ->(id) { where(status: OPEN, project_id: id) }
|
17
|
+
scope :submitted, ->(id) { where(status: SUBMITTED, project_id: id) }
|
15
18
|
|
16
|
-
def self.open_exists?
|
17
|
-
OvertimeSheet.open.exists?
|
19
|
+
def self.open_exists?(project_id)
|
20
|
+
OvertimeSheet.open(project_id).exists?
|
18
21
|
end
|
19
22
|
|
20
|
-
def self.open_for_date_exists?(date)
|
21
|
-
OvertimeSheet.open.
|
23
|
+
def self.open_for_date_exists?(date, project_id)
|
24
|
+
OvertimeSheet.open(project_id).where(date: date).exists?
|
22
25
|
end
|
23
26
|
|
24
27
|
# Overtime sheet should be created using the
|
@@ -26,16 +29,16 @@ module Ecom
|
|
26
29
|
# check if there is an open overtime already,
|
27
30
|
# and also that we have only one open overtime
|
28
31
|
# sheet at a time.
|
29
|
-
def self.create_new(date)
|
30
|
-
if OvertimeSheet.open_for_date_exists?(date)
|
32
|
+
def self.create_new(date, project_id)
|
33
|
+
if OvertimeSheet.open_for_date_exists?(date, project_id)
|
31
34
|
raise 'There is already an open overtime sheet for the selected date.'
|
32
35
|
end
|
33
36
|
|
34
|
-
if OvertimeSheet.open_exists?
|
37
|
+
if OvertimeSheet.open_exists?(project_id)
|
35
38
|
raise 'There is already an open overtime sheet. It has to be submitted before creating a new one.'
|
36
39
|
end
|
37
40
|
|
38
|
-
OvertimeSheet.create(date: date, opened_at: Time.now, status: OPEN)
|
41
|
+
OvertimeSheet.create(date: date, opened_at: Time.now, status: OPEN, project_id: project_id)
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
@@ -7,6 +7,10 @@ module Ecom
|
|
7
7
|
belongs_to :project_manager, class_name: 'Ecom::Core::Stakeholder'
|
8
8
|
belongs_to :task_template
|
9
9
|
belongs_to :currency
|
10
|
+
belongs_to :company
|
11
|
+
|
12
|
+
has_many :project_crews
|
13
|
+
has_many :crews, through: :project_crews
|
10
14
|
|
11
15
|
validates :name, :location, :contract_number, :date_contract_signed, :commencement_date, :completion_date,
|
12
16
|
:contract_amount, :advance_payment, :retention, presence: true
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Core
|
3
|
+
class ProjectCrew < ApplicationRecord
|
4
|
+
ACTIVE = 'Active'.freeze
|
5
|
+
INACTIVE = 'Inactive'.freeze
|
6
|
+
STATUSES = [ACTIVE, INACTIVE].freeze
|
7
|
+
|
8
|
+
belongs_to :project
|
9
|
+
belongs_to :crew
|
10
|
+
|
11
|
+
validates :start_date, :status, presence: true
|
12
|
+
validates :status, inclusion: STATUSES
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateEcomCoreCompanies < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_core_companies do |t|
|
4
|
+
t.string :code, null: false, unique: true
|
5
|
+
t.string :name, null: false, unique: true
|
6
|
+
t.string :address, null: false
|
7
|
+
t.string :telephone, null: false
|
8
|
+
t.string :email
|
9
|
+
t.json :settings
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -4,12 +4,13 @@ class CreateEcomCoreTaskTemplates < ActiveRecord::Migration[6.0]
|
|
4
4
|
t.string :code, null: false
|
5
5
|
t.string :name, null: false
|
6
6
|
t.string :description
|
7
|
-
t.references :task_template_type,
|
7
|
+
t.references :task_template_type,
|
8
|
+
null: false,
|
9
|
+
index: { name: 'tt_on_ttt_indx' },
|
10
|
+
foreign_key: { to_table: :ecom_core_task_template_types }
|
8
11
|
t.string :ancestry, index: true
|
9
12
|
|
10
13
|
t.timestamps
|
11
14
|
end
|
12
|
-
|
13
|
-
add_foreign_key :ecom_core_task_templates, :ecom_core_task_template_types, column: :task_template_type_id
|
14
15
|
end
|
15
16
|
end
|
@@ -5,11 +5,12 @@ class CreateEcomCoreWorkProductTemplates < ActiveRecord::Migration[6.0]
|
|
5
5
|
t.string :name, null: false, unique: true
|
6
6
|
t.string :description
|
7
7
|
t.string :remark
|
8
|
-
t.references :task_template,
|
8
|
+
t.references :task_template,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'tt_on_wpt_indx' },
|
11
|
+
foreign_key: { to_table: :ecom_core_task_templates }
|
9
12
|
|
10
13
|
t.timestamps
|
11
14
|
end
|
12
|
-
|
13
|
-
add_foreign_key :ecom_core_work_product_templates, :ecom_core_task_templates, column: :task_template_id
|
14
15
|
end
|
15
16
|
end
|
@@ -9,11 +9,12 @@ class CreateEcomCoreStakeholders < ActiveRecord::Migration[6.0]
|
|
9
9
|
t.string :contact_name, null: false
|
10
10
|
t.string :contact_phone, null: false
|
11
11
|
t.string :contact_email, null: false
|
12
|
-
t.references :stakeholder_type,
|
12
|
+
t.references :stakeholder_type,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'stakeholders_on_st_indx' },
|
15
|
+
foreign_key: { to_table: :ecom_core_stakeholder_types }
|
13
16
|
|
14
17
|
t.timestamps
|
15
18
|
end
|
16
|
-
|
17
|
-
add_foreign_key :ecom_core_stakeholders, :ecom_core_stakeholder_types, column: :stakeholder_type_id
|
18
19
|
end
|
19
20
|
end
|
@@ -2,13 +2,15 @@ class CreateEcomCoreProductTypes < ActiveRecord::Migration[6.0]
|
|
2
2
|
def change
|
3
3
|
create_table :ecom_core_product_types do |t|
|
4
4
|
t.string :name, null: false
|
5
|
-
t.references :work_product_template,
|
5
|
+
t.references :work_product_template,
|
6
|
+
null: false,
|
7
|
+
index: { name: 'pt_on_wpt_indx' },
|
8
|
+
foreign_key: { to_table: :ecom_core_work_product_templates }
|
6
9
|
t.json :dimension
|
7
10
|
|
8
11
|
t.timestamps
|
9
12
|
end
|
10
13
|
|
11
14
|
add_index :ecom_core_product_types, %i[name work_product_template_id], unique: true, name: 'wpt_on_pt_name_indx'
|
12
|
-
add_foreign_key :ecom_core_product_types, :ecom_core_work_product_templates, column: :work_product_template_id
|
13
15
|
end
|
14
16
|
end
|
@@ -6,8 +6,14 @@ class CreateEcomCoreWorkComponentTemplates < ActiveRecord::Migration[6.0]
|
|
6
6
|
t.string :description
|
7
7
|
t.integer :relative_percentage
|
8
8
|
t.json :dimension
|
9
|
-
t.references :work_product_template,
|
10
|
-
|
9
|
+
t.references :work_product_template,
|
10
|
+
null: false,
|
11
|
+
index: { name: 'wct_on_wpt_indx' },
|
12
|
+
foreign_key: { to_table: :ecom_core_work_product_templates }
|
13
|
+
t.references :task_template,
|
14
|
+
null: false,
|
15
|
+
index: { name: 'wct_on_tt_indx' },
|
16
|
+
foreign_key: { to_table: :ecom_core_task_templates }
|
11
17
|
|
12
18
|
t.timestamps
|
13
19
|
end
|
@@ -15,9 +21,5 @@ class CreateEcomCoreWorkComponentTemplates < ActiveRecord::Migration[6.0]
|
|
15
21
|
add_index :ecom_core_work_component_templates, %i[code work_product_template_id task_template_id],
|
16
22
|
unique: true,
|
17
23
|
name: 'wct_on_code_wpt_id_tt_id_indx'
|
18
|
-
add_foreign_key :ecom_core_work_component_templates, :ecom_core_work_product_templates,
|
19
|
-
column: :work_product_template_id
|
20
|
-
add_foreign_key :ecom_core_work_component_templates, :ecom_core_task_templates,
|
21
|
-
column: :task_template_id
|
22
24
|
end
|
23
25
|
end
|
@@ -6,11 +6,26 @@ class CreateEcomCoreProjects < ActiveRecord::Migration[6.0]
|
|
6
6
|
t.string :location, null: false
|
7
7
|
t.string :objective
|
8
8
|
t.string :project_scope
|
9
|
-
t.references :employer,
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
t.references :
|
9
|
+
t.references :employer,
|
10
|
+
null: false,
|
11
|
+
index: { name: 'employer_on_projects_indx' },
|
12
|
+
foreign_key: { to_table: :ecom_core_stakeholders }
|
13
|
+
t.references :contractor,
|
14
|
+
null: false,
|
15
|
+
index: { name: 'employer_on_contractor_indx' },
|
16
|
+
foreign_key: { to_table: :ecom_core_stakeholders }
|
17
|
+
t.references :consultant,
|
18
|
+
null: false,
|
19
|
+
index: { name: 'employer_on_consultant_indx' },
|
20
|
+
foreign_key: { to_table: :ecom_core_stakeholders }
|
21
|
+
t.references :project_manager,
|
22
|
+
null: false,
|
23
|
+
index: { name: 'employer_on_pm_indx' },
|
24
|
+
foreign_key: { to_table: :ecom_core_stakeholders }
|
25
|
+
t.references :task_template,
|
26
|
+
null: false,
|
27
|
+
index: { name: 'employer_on_tt_indx' },
|
28
|
+
foreign_key: { to_table: :ecom_core_task_templates }
|
14
29
|
t.string :contract_number, null: false
|
15
30
|
t.date :date_contract_signed, null: false
|
16
31
|
t.date :commencement_date, null: false
|
@@ -19,16 +34,16 @@ class CreateEcomCoreProjects < ActiveRecord::Migration[6.0]
|
|
19
34
|
t.float :advance_payment, null: false
|
20
35
|
t.float :retention, null: false
|
21
36
|
t.string :remark
|
22
|
-
t.references :currency,
|
37
|
+
t.references :currency,
|
38
|
+
null: false,
|
39
|
+
index: { name: 'employer_on_currency_indx' },
|
40
|
+
foreign_key: { to_table: :ecom_core_currencies }
|
41
|
+
t.references :company,
|
42
|
+
null: false,
|
43
|
+
index: { name: 'project_on_company_indx' },
|
44
|
+
foreign_key: { to_table: :ecom_core_companies }
|
23
45
|
|
24
46
|
t.timestamps
|
25
47
|
end
|
26
|
-
|
27
|
-
add_foreign_key :ecom_core_projects, :ecom_core_stakeholders, column: :employer_id
|
28
|
-
add_foreign_key :ecom_core_projects, :ecom_core_stakeholders, column: :contractor_id
|
29
|
-
add_foreign_key :ecom_core_projects, :ecom_core_stakeholders, column: :consultant_id
|
30
|
-
add_foreign_key :ecom_core_projects, :ecom_core_stakeholders, column: :project_manager_id
|
31
|
-
add_foreign_key :ecom_core_projects, :ecom_core_task_templates, column: :task_template_id
|
32
|
-
add_foreign_key :ecom_core_projects, :ecom_core_currencies, column: :currency_id
|
33
48
|
end
|
34
49
|
end
|
@@ -5,13 +5,16 @@ class CreateEcomCoreTasks < ActiveRecord::Migration[6.0]
|
|
5
5
|
t.string :name, null: false
|
6
6
|
t.string :description
|
7
7
|
t.string :ancestry
|
8
|
-
t.references :project,
|
9
|
-
|
8
|
+
t.references :project,
|
9
|
+
null: false,
|
10
|
+
index: { name: 'tasks_on_project_indx' },
|
11
|
+
foreign_key: { to_table: :ecom_core_projects }
|
12
|
+
t.references :task_template,
|
13
|
+
null: false,
|
14
|
+
index: { name: 'tt_on_project_indx' },
|
15
|
+
foreign_key: { to_table: :ecom_core_task_templates }
|
10
16
|
|
11
17
|
t.timestamps
|
12
18
|
end
|
13
|
-
|
14
|
-
add_foreign_key :ecom_core_tasks, :ecom_core_projects, column: :project_id
|
15
|
-
add_foreign_key :ecom_core_tasks, :ecom_core_task_templates, column: :task_template_id
|
16
19
|
end
|
17
20
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
class CreateTaskTemplatesResourceTypes < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
create_table :ecom_core_task_templates_resource_types, id: false do |t|
|
4
|
-
t.references :task_template,
|
5
|
-
|
4
|
+
t.references :task_template,
|
5
|
+
null: false,
|
6
|
+
index: false,
|
7
|
+
foreign_key: { to_table: :ecom_core_task_templates }
|
8
|
+
t.references :resource_type,
|
9
|
+
null: false,
|
10
|
+
index: false,
|
11
|
+
foreign_key: { to_table: :ecom_core_resource_types }
|
6
12
|
end
|
7
13
|
|
8
14
|
add_index :ecom_core_task_templates_resource_types, %i[task_template_id resource_type_id],
|
9
15
|
unique: true, name: 'ttr_on_tt_rt_indx'
|
10
|
-
|
11
|
-
add_foreign_key :ecom_core_task_templates_resource_types, :ecom_core_task_templates,
|
12
|
-
column: :task_template_id
|
13
|
-
add_foreign_key :ecom_core_task_templates_resource_types, :ecom_core_resource_types,
|
14
|
-
column: :resource_type_id
|
15
16
|
end
|
16
17
|
end
|
@@ -6,19 +6,22 @@ class CreateEcomCoreUsers < ActiveRecord::Migration[6.0]
|
|
6
6
|
t.string :email, null: false
|
7
7
|
t.boolean :active, null: false, default: true
|
8
8
|
t.string :password_digest
|
9
|
+
t.jsonb :projects
|
9
10
|
|
10
11
|
t.timestamps
|
11
12
|
end
|
12
13
|
|
13
14
|
create_table :ecom_core_application_modules_users, id: false do |t|
|
14
|
-
t.references :user,
|
15
|
-
|
15
|
+
t.references :user,
|
16
|
+
null: false,
|
17
|
+
index: false,
|
18
|
+
foreign_key: { to_table: :ecom_core_users }
|
19
|
+
t.references :application_module,
|
20
|
+
null: false,
|
21
|
+
index: false,
|
22
|
+
foreign_key: { to_table: :ecom_core_application_modules }
|
16
23
|
end
|
17
24
|
|
18
25
|
add_index :ecom_core_application_modules_users, %i[user_id application_module_id], name: 'am_on_users_indx'
|
19
|
-
|
20
|
-
add_foreign_key :ecom_core_application_modules_users, :ecom_core_users, column: :user_id
|
21
|
-
add_foreign_key :ecom_core_application_modules_users, :ecom_core_application_modules,
|
22
|
-
column: :application_module_id
|
23
26
|
end
|
24
27
|
end
|
@@ -2,21 +2,26 @@ class CreateEcomCoreUserRoles < ActiveRecord::Migration[6.0]
|
|
2
2
|
def change
|
3
3
|
create_table :ecom_core_user_roles do |t|
|
4
4
|
t.string :name, index: false
|
5
|
-
t.references :application_module,
|
5
|
+
t.references :application_module,
|
6
|
+
null: false,
|
7
|
+
index: { name: 'ur_on_am_indx' },
|
8
|
+
foreign_key: { to_table: :ecom_core_application_modules }
|
6
9
|
|
7
10
|
t.timestamps
|
8
11
|
end
|
9
|
-
add_index :ecom_core_user_roles, %i[name application_module_id], unique: true, name: 'am_name_indx'
|
10
|
-
add_foreign_key :ecom_core_user_roles, :ecom_core_application_modules,
|
11
|
-
column: :application_module_id
|
12
12
|
|
13
13
|
create_table :ecom_core_users_user_roles, id: false do |t|
|
14
|
-
t.references :user,
|
15
|
-
|
14
|
+
t.references :user,
|
15
|
+
null: false,
|
16
|
+
index: false,
|
17
|
+
foreign_key: { to_table: :ecom_core_users }
|
18
|
+
t.references :user_role,
|
19
|
+
null: false,
|
20
|
+
index: false,
|
21
|
+
foreign_key: { to_table: :ecom_core_user_roles }
|
16
22
|
end
|
17
23
|
|
24
|
+
add_index :ecom_core_user_roles, %i[name application_module_id], unique: true, name: 'am_name_indx'
|
18
25
|
add_index :ecom_core_users_user_roles, %i[user_id user_role_id], unique: true, name: 'users_user_roles_indx'
|
19
|
-
add_foreign_key :ecom_core_users_user_roles, :ecom_core_users, column: :user_id
|
20
|
-
add_foreign_key :ecom_core_users_user_roles, :ecom_core_user_roles, column: :user_role_id
|
21
26
|
end
|
22
27
|
end
|
@@ -4,22 +4,29 @@ class CreateEcomCoreMenus < ActiveRecord::Migration[6.0]
|
|
4
4
|
t.string :label, null: false
|
5
5
|
t.string :icon
|
6
6
|
t.string :route, null: false
|
7
|
-
t.references :parent,
|
8
|
-
|
7
|
+
t.references :parent,
|
8
|
+
null: true,
|
9
|
+
index: false,
|
10
|
+
foreign_key: { to_table: :ecom_core_menus }
|
11
|
+
t.references :application_module,
|
12
|
+
null: false,
|
13
|
+
index: { name: 'menus_on_am_indx' },
|
14
|
+
foreign_key: { to_table: :ecom_core_application_modules }
|
9
15
|
|
10
16
|
t.timestamps
|
11
17
|
end
|
12
18
|
|
13
|
-
add_foreign_key :ecom_core_menus, :ecom_core_menus, column: :parent_id
|
14
|
-
add_foreign_key :ecom_core_menus, :ecom_core_application_modules, column: :application_module_id
|
15
|
-
|
16
19
|
create_table :ecom_core_menus_user_roles, id: false do |t|
|
17
|
-
t.references :menu,
|
18
|
-
|
20
|
+
t.references :menu,
|
21
|
+
null: false,
|
22
|
+
index: false,
|
23
|
+
foreign_key: { to_table: :ecom_core_menus }
|
24
|
+
t.references :user_role,
|
25
|
+
null: false,
|
26
|
+
index: false,
|
27
|
+
foreign_key: { to_table: :ecom_core_user_roles }
|
19
28
|
end
|
20
29
|
|
21
30
|
add_index :ecom_core_menus_user_roles, %i[menu_id user_role_id], unique: true, name: 'menus_user_roles_indx'
|
22
|
-
add_foreign_key :ecom_core_menus_user_roles, :ecom_core_menus, column: :menu_id
|
23
|
-
add_foreign_key :ecom_core_menus_user_roles, :ecom_core_user_roles, column: :user_role_id
|
24
31
|
end
|
25
32
|
end
|
@@ -6,30 +6,44 @@ class CreateEcomCoreWorkProducts < ActiveRecord::Migration[6.0]
|
|
6
6
|
t.string :description
|
7
7
|
t.string :design_reference_no, unique: true
|
8
8
|
t.json :dimension
|
9
|
-
t.references :task,
|
10
|
-
|
11
|
-
|
9
|
+
t.references :task,
|
10
|
+
null: false,
|
11
|
+
index: { name: 'task_on_wp_indx' },
|
12
|
+
foreign_key: { to_table: :ecom_core_tasks }
|
13
|
+
t.references :work_product_template,
|
14
|
+
null: false,
|
15
|
+
index: { name: 'wpt_on_wp_indx' },
|
16
|
+
foreign_key: { to_table: :ecom_core_work_product_templates }
|
17
|
+
t.references :project,
|
18
|
+
null: false,
|
19
|
+
index: { name: 'projects_on_wp_indx' },
|
20
|
+
foreign_key: { to_table: :ecom_core_projects }
|
12
21
|
t.string :assignment_status, default: 'UNASSIGNED'
|
13
22
|
t.string :task_status, default: 'NEW'
|
14
23
|
t.integer :percent_completed
|
15
24
|
t.string :remark
|
16
|
-
t.references :performer,
|
17
|
-
|
18
|
-
|
19
|
-
|
25
|
+
t.references :performer,
|
26
|
+
null: true,
|
27
|
+
index: false,
|
28
|
+
foreign_key: { to_table: :ecom_core_users }
|
29
|
+
t.references :approver,
|
30
|
+
null: true,
|
31
|
+
index: false,
|
32
|
+
foreign_key: { to_table: :ecom_core_users }
|
33
|
+
t.references :supervisor,
|
34
|
+
null: true,
|
35
|
+
index: false,
|
36
|
+
foreign_key: { to_table: :ecom_core_users }
|
37
|
+
t.references :quality_controller,
|
38
|
+
null: true,
|
39
|
+
index: false,
|
40
|
+
foreign_key: { to_table: :ecom_core_users }
|
20
41
|
t.datetime :start_date
|
21
42
|
t.datetime :completion_date
|
22
43
|
|
23
44
|
t.timestamps
|
24
45
|
end
|
46
|
+
|
25
47
|
add_index :ecom_core_work_products, %i[code project_id], unique: true
|
26
|
-
add_foreign_key :ecom_core_work_products, :ecom_core_tasks, column: :task_id
|
27
|
-
add_foreign_key :ecom_core_work_products, :ecom_core_work_product_templates,
|
28
|
-
column: :work_product_template_id
|
29
|
-
add_foreign_key :ecom_core_work_products, :ecom_core_projects, column: :project_id
|
30
|
-
add_foreign_key :ecom_core_work_products, :ecom_core_users, column: :performer_id
|
31
|
-
add_foreign_key :ecom_core_work_products, :ecom_core_users, column: :approver_id
|
32
|
-
add_foreign_key :ecom_core_work_products, :ecom_core_users, column: :supervisor_id
|
33
|
-
add_foreign_key :ecom_core_work_products, :ecom_core_users, column: :quality_controller_id
|
34
48
|
end
|
35
49
|
end
|