ecom_core 1.2.14 → 1.2.19

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/ecom/core/booking.rb +1 -1
  3. data/app/models/ecom/core/crew_time.rb +45 -17
  4. data/app/models/ecom/core/overtime_sheet.rb +6 -2
  5. data/app/models/ecom/core/product_group.rb +9 -0
  6. data/app/models/ecom/core/project.rb +1 -1
  7. data/app/models/ecom/core/task.rb +45 -2
  8. data/app/models/ecom/core/task_resource.rb +10 -0
  9. data/app/models/ecom/core/task_template.rb +1 -1
  10. data/app/models/ecom/core/work_package.rb +12 -0
  11. data/app/models/ecom/core/work_product.rb +19 -45
  12. data/app/models/ecom/core/work_product_template.rb +2 -6
  13. data/app/services/ecom/core/menu_service.rb +1 -1
  14. data/db/migrate/20191119012030_create_ecom_core_task_templates.rb +2 -0
  15. data/db/migrate/20191119013236_create_ecom_core_work_product_templates.rb +14 -4
  16. data/db/migrate/20191201145848_create_ecom_core_projects.rb +2 -2
  17. data/db/migrate/20191201251015_create_ecom_core_product_groups.rb +13 -0
  18. data/db/migrate/20191202222210_create_ecom_core_work_packages.rb +17 -0
  19. data/db/migrate/20191202235434_create_ecom_core_work_products.rb +8 -13
  20. data/db/migrate/20191207103735_create_ecom_core_tasks.rb +45 -0
  21. data/db/migrate/20191210724614_create_ecom_core_task_resources.rb +18 -0
  22. data/lib/ecom/core/version.rb +1 -1
  23. data/spec/factories/ecom/core/application_modules.rb +3 -1
  24. data/spec/factories/ecom/core/companies.rb +3 -1
  25. data/spec/factories/ecom/core/product_groups.rb +6 -0
  26. data/spec/factories/ecom/core/projects.rb +1 -1
  27. data/spec/factories/ecom/core/resource_types.rb +3 -1
  28. data/spec/factories/ecom/core/task_resources.rb +8 -0
  29. data/spec/factories/ecom/core/task_template_types.rb +6 -2
  30. data/spec/factories/ecom/core/task_templates.rb +5 -7
  31. data/spec/factories/ecom/core/tasks.rb +14 -3
  32. data/spec/factories/ecom/core/work_packages.rb +12 -0
  33. data/spec/factories/ecom/core/work_product_templates.rb +7 -4
  34. data/spec/factories/ecom/core/work_products.rb +5 -7
  35. metadata +12 -9
  36. data/app/models/ecom/core/work_component.rb +0 -14
  37. data/app/models/ecom/core/work_component_template.rb +0 -11
  38. data/db/migrate/20191201134420_create_ecom_core_work_component_templates.rb +0 -25
  39. data/db/migrate/20191202103735_create_ecom_core_tasks.rb +0 -20
  40. data/db/migrate/20191206104247_create_ecom_core_work_components.rb +0 -40
  41. data/spec/factories/ecom/core/work_component_templates.rb +0 -11
  42. data/spec/factories/ecom/core/work_components.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 556990381397a6b8767f5e0b8f169a9f3ec26fe4ca86f3511f2c032e87980b36
4
- data.tar.gz: 519d394938acc41e78d25cbab80b720347686cb14c059dd9b5d742316d69bb8a
3
+ metadata.gz: dec564e431b435c4775432757843f7d46c2c98d0c3858bb783e8325b630ba84f
4
+ data.tar.gz: 6831882fb350c6d92d1324a7f6d3fcf6a95ec334af3b551b11b6e24c93c29c75
5
5
  SHA512:
6
- metadata.gz: fdf6100d006de268f4dd92f9ee2583e02067f8a88e0c231cb67ea8939fff986e56cf5f121c94efcd14980016067e394469a46e3b9379369200e72c87e91c8ed4
7
- data.tar.gz: 46dfdcef2f8300fd34fc89f81beced4d313ef6c63207392290e87457d4d00e236c97d1a1b8f5fdb6ab23709dd86555a75c53ba10de2c2a22caf2bc59452aed65
6
+ metadata.gz: a9043260a84f6ad95cb2e3ba02329f50bb60a98159b143e58db19c5273bacc1d15d6df538ee460ded92e519071741ac32e6003ec29ae659548109d806ea50d36
7
+ data.tar.gz: 0e280d833e3b19ce2c87ec29f3d7880e20d015e712c289c027785c885bb8b3b601e8347ecf1290ac26bd14c5b7ccc8cae7fbbc2ecb911b3ef0f2cd97d03f87ba
@@ -13,4 +13,4 @@ module Ecom
13
13
  validates :status, presence: true, inclusion: STATUSES
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -2,15 +2,15 @@ module Ecom
2
2
  module Core
3
3
  class CrewTime < ApplicationRecord
4
4
  # Time Ranges
5
- MORNING = 'Morning'.freeze
6
- AFTERNOON = 'Afternoon'.freeze
7
- BOTH = 'Both'.freeze
5
+ MORNING = :morning
6
+ AFTERNOON = :afternoon
7
+ FULL_DAY = :full_day
8
8
 
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') },
12
- BOTH => { start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('2:00 PM') }
13
- }.freeze
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') },
12
+ # BOTH => { start: Time.zone.parse('5:00 AM'), end: Time.zone.parse('2:00 PM') }
13
+ # }.freeze
14
14
 
15
15
  belongs_to :attendance_sheet_entry
16
16
  belongs_to :revision_to, class_name: 'Ecom::Core::CrewTime', optional: true
@@ -47,15 +47,42 @@ module Ecom
47
47
  attendance_sheet_entry.save
48
48
  end
49
49
 
50
+ # A method to get the available time ranges at a given point.
51
+ # We cannot define the range variables as a constant because
52
+ # the parsing should be done at the exact moment we are about
53
+ # to do time range calculations to avoid errors caused by date
54
+ # mismatches
55
+ def define_range
56
+ morning = {
57
+ start: Time.zone.parse('5:00 AM'),
58
+ finish: Time.zone.parse('9:00 AM')
59
+ }
60
+ afternoon = {
61
+ start: Time.zone.parse('10:00 AM'),
62
+ finish: Time.zone.parse('2:00 PM')
63
+ }
64
+ full_day = {
65
+ start: Time.zone.parse('5:00 AM'),
66
+ finish: Time.zone.parse('2:00 PM')
67
+ }
68
+
69
+ {
70
+ morning: morning,
71
+ afternoon: afternoon,
72
+ full_day: full_day
73
+ }
74
+ end
75
+
50
76
  # A method to check if checkin and checkout range falls in the morning,
51
77
  # afternoon, or both.
52
78
  def find_range(start, finish)
53
- if start.before?(TIME_RANGE[MORNING][:end]) && finish.before?(TIME_RANGE[AFTERNOON][:start])
54
- MORNING
55
- elsif start.after?(TIME_RANGE[MORNING][:end]) && finish.after?(TIME_RANGE[AFTERNOON][:start])
56
- AFTERNOON
79
+ range = define_range
80
+ if start.before?(range[:morning][:finish]) && finish.before?(range[:afternoon][:start])
81
+ :morning
82
+ elsif start.after?(range[:morning][:finish]) && finish.after?(range[:afternoon][:start])
83
+ :afternoon
57
84
  else
58
- BOTH
85
+ :full_day
59
86
  end
60
87
  end
61
88
 
@@ -63,13 +90,14 @@ module Ecom
63
90
  # of the defined morning and afternoon ranges
64
91
  def compute_hours
65
92
  # Reparse time to avoid errors caused by date differences
93
+ range = define_range
66
94
  start = Time.zone.parse(checkin_time.strftime('%I:%M%p'))
67
95
  finish = Time.zone.parse(checkout_time.strftime('%I:%M%p'))
68
- range = find_range(start, finish)
69
- left = start.before?(TIME_RANGE[range][:start]) ? TIME_RANGE[range][:start] : start
70
- right = finish.after?(TIME_RANGE[range][:end]) ? TIME_RANGE[range][:end] : finish
96
+ day_part = find_range(start, finish)
97
+ left = start.before?(range[day_part][:start]) ? range[day_part][:start] : start
98
+ right = finish.after?(range[day_part][:finish]) ? range[day_part][:finish] : finish
71
99
  time = (right - left) / 1.hour
72
- time -= 1 if range == BOTH
100
+ time -= 1 if day_part == FULL_DAY
73
101
  time
74
102
  end
75
103
  end
@@ -24,14 +24,18 @@ module Ecom
24
24
  OvertimeSheet.open(project_id).where(date: date).exists?
25
25
  end
26
26
 
27
+ def self.exists_for_date?(date, project_id)
28
+ OvertimeSheet.by_project(project_id).by_date(date).exists?
29
+ end
30
+
27
31
  # Overtime sheet should be created using the
28
32
  # method below only. This is because we need to
29
33
  # check if there is an open overtime already,
30
34
  # and also that we have only one open overtime
31
35
  # sheet at a time.
32
36
  def self.create_new(date, project_id)
33
- if OvertimeSheet.open_for_date_exists?(date, project_id)
34
- raise 'There is already an open overtime sheet for the selected date.'
37
+ if OvertimeSheet.exists_for_date?(date, project_id)
38
+ raise 'There is already an overtime sheet for the selected date.'
35
39
  end
36
40
 
37
41
  if OvertimeSheet.open_exists?(project_id)
@@ -0,0 +1,9 @@
1
+ module Ecom
2
+ module Core
3
+ class ProductGroup < ApplicationRecord
4
+ belongs_to :project
5
+
6
+ validates :name, presence: true, uniqueness: true
7
+ end
8
+ end
9
+ end
@@ -5,7 +5,7 @@ module Ecom
5
5
  belongs_to :contractor, class_name: 'Ecom::Core::Stakeholder'
6
6
  belongs_to :consultant, class_name: 'Ecom::Core::Stakeholder'
7
7
  belongs_to :project_manager, class_name: 'Ecom::Core::Stakeholder'
8
- belongs_to :task_template
8
+ belongs_to :task_template_type
9
9
  belongs_to :currency
10
10
  belongs_to :company
11
11
 
@@ -1,10 +1,53 @@
1
1
  module Ecom
2
2
  module Core
3
3
  class Task < ApplicationRecord
4
- belongs_to :project
4
+ include AASM
5
+
6
+ has_ancestry
7
+
8
+ belongs_to :work_product
5
9
  belongs_to :task_template
10
+ belongs_to :work_package, optional: true
11
+ belongs_to :performer, class_name: 'Ecom::Core::User', optional: true
12
+ belongs_to :approver, class_name: 'Ecom::Core::User', optional: true
13
+ belongs_to :supervisor, class_name: 'Ecom::Core::User', optional: true
14
+ belongs_to :quality_controller, class_name: 'Ecom::Core::User', optional: true
15
+
16
+ validates :code, :name, :status, :percent_completed, presence: true
17
+ validates_numericality_of :percent_completed,
18
+ only_integer: true,
19
+ greater_than_or_equal_to: 0,
20
+ less_than_or_equal_to: 100
21
+
22
+ scope :by_status, ->(status) { where(status: status) }
23
+
24
+ aasm column: 'status' do
25
+ state :new, initial: true
26
+ state :in_progress
27
+ state :submitted
28
+ state :under_review
29
+ state :completed
30
+
31
+ event :start do
32
+ transitions from: :new, to: :in_progress
33
+ end
34
+
35
+ event :submit do
36
+ transitions from: :in_progress, to: :submitted
37
+ end
38
+
39
+ event :review do
40
+ transitions from: :submitted, to: :under_review
41
+ end
42
+
43
+ event :complete do
44
+ transitions from: %i[submitted under_review], to: :completed
45
+ end
6
46
 
7
- validates :code, :name, presence: true
47
+ event :rework do
48
+ transitions from: :under_review, to: :in_progress
49
+ end
50
+ end
8
51
  end
9
52
  end
10
53
  end
@@ -0,0 +1,10 @@
1
+ module Ecom
2
+ module Core
3
+ class TaskResource < ApplicationRecord
4
+ belongs_to :task
5
+ belongs_to :resource_type
6
+
7
+ validates :amount, presence: true, numericality: { greater_than: 0 }
8
+ end
9
+ end
10
+ end
@@ -4,7 +4,7 @@ module Ecom
4
4
  has_ancestry
5
5
 
6
6
  belongs_to :task_template_type
7
- has_one :work_product_template
7
+ has_and_belongs_to_many :work_product_templates, join_table: 'ecom_core_task_templates_work_product_templates'
8
8
  has_and_belongs_to_many :resource_types, join_table: 'ecom_core_task_templates_resource_types'
9
9
 
10
10
  validates :name, :code, presence: true
@@ -0,0 +1,12 @@
1
+ module Ecom
2
+ module Core
3
+ class WorkPackage < ApplicationRecord
4
+ belongs_to :project
5
+
6
+ validates :code, :name, presence: true
7
+ validates :code, uniqueness: true
8
+
9
+ has_many :tasks
10
+ end
11
+ end
12
+ end
@@ -17,53 +17,27 @@ module Ecom
17
17
  class WorkProduct < ApplicationRecord
18
18
  include AASM
19
19
 
20
- belongs_to :work_product_template
21
- belongs_to :task
22
- belongs_to :project
23
- belongs_to :performer, class_name: 'Ecom::Core::User'
24
- belongs_to :approver, class_name: 'Ecom::Core::User'
25
- belongs_to :supervisor, class_name: 'Ecom::Core::User'
26
- belongs_to :quality_controller, class_name: 'Ecom::Core::User'
27
-
28
- validates :name, presence: true
29
- validates :design_reference_no, uniqueness: true
30
-
31
- aasm column: 'task_status' do
32
- state :new, initial: true
33
- state :in_progress
34
- state :submitted
35
- state :under_review
36
- state :completed
37
-
38
- event :start do
39
- transitions from: :new, to: :in_progress
40
- end
41
-
42
- event :submit do
43
- transitions from: :in_progress, to: :submitted
44
- end
20
+ NEW = 'New'.freeze
21
+ UNDER_CONSTRUCTION = 'Under Construction'.freeze
22
+ COMPLETED = 'Completed'.freeze
45
23
 
46
- event :review do
47
- transitions from: :submitted, to: :under_review
48
- end
24
+ STATUSES = [NEW, UNDER_CONSTRUCTION, COMPLETED].freeze
49
25
 
50
- event :complete do
51
- transitions from: %i[submitted under_review], to: :completed
52
- end
53
-
54
- event :rework do
55
- transitions from: :under_review, to: :in_progress
56
- end
57
- end
58
-
59
- aasm column: 'assignment_status' do
60
- state :unassigned, initial: true
61
- state :assigned
62
-
63
- event :assign do
64
- transitions from: :unassigned, to: :assigned
65
- end
66
- end
26
+ belongs_to :work_product_template
27
+ belongs_to :project
28
+ belongs_to :product_group, optional: true
29
+ belongs_to :approver, class_name: 'Ecom::Core::User', optional: true
30
+ belongs_to :supervisor, class_name: 'Ecom::Core::User', optional: true
31
+ belongs_to :quality_controller, class_name: 'Ecom::Core::User', optional: true
32
+ has_many :tasks
33
+
34
+ validates :name, :design_reference_no, :status, :percent_completed, presence: true
35
+ validates :design_reference_no, uniqueness: { scope: :project_id }
36
+ validates :status, inclusion: STATUSES
37
+ validates_numericality_of :percent_completed,
38
+ only_integer: true,
39
+ greater_than_or_equal_to: 0,
40
+ less_than_or_equal_to: 100
67
41
  end
68
42
  end
69
43
  end
@@ -2,13 +2,9 @@ module Ecom
2
2
  module Core
3
3
  class WorkProductTemplate < ApplicationRecord
4
4
  validates :code, :name, presence: true, uniqueness: true
5
- belongs_to :task_template
5
+ belongs_to :task_template_type
6
+ has_and_belongs_to_many :task_templates
6
7
  has_many :product_types
7
-
8
- scope :filtered_by_template_type, lambda { |id|
9
- joins(:task_template).where('ecom_core_task_templates.task_template_type_id = ?', id)
10
- .order(:code)
11
- }
12
8
  end
13
9
  end
14
10
  end
@@ -7,7 +7,7 @@ module Ecom
7
7
  INNER JOIN ecom_core_menus_user_roles MUR ON MUR.menu_id = ecom_core_menus.id
8
8
  INNER JOIN ecom_core_user_roles UR ON MUR.user_role_id = UR.id
9
9
  SQL
10
- menu = Menu.joins(join_sql).where('UR.id IN (?)', role_ids).distinct
10
+ menu = Menu.joins(join_sql).where('UR.id IN (?)', role_ids).order(:id).distinct
11
11
  menu_list = menu.select { |m| m.parent.nil? }.each_with_object([]) do |item, list|
12
12
  list << { id: item.id, text: item.label, iconCss: item.icon, items: [] }
13
13
  end
@@ -9,6 +9,8 @@ class CreateEcomCoreTaskTemplates < ActiveRecord::Migration[6.0]
9
9
  index: { name: 'tt_on_ttt_indx' },
10
10
  foreign_key: { to_table: :ecom_core_task_template_types }
11
11
  t.string :ancestry, index: true
12
+ t.boolean :has_takeoff_fields, null:false, default: false
13
+ t.jsonb :fields
12
14
 
13
15
  t.timestamps
14
16
  end
@@ -4,13 +4,23 @@ class CreateEcomCoreWorkProductTemplates < ActiveRecord::Migration[6.0]
4
4
  t.string :code, null: false, unique: true
5
5
  t.string :name, null: false, unique: true
6
6
  t.string :description
7
- t.string :remark
8
- t.references :task_template,
7
+ t.references :task_template_type,
9
8
  null: false,
10
- index: { name: 'tt_on_wpt_indx' },
11
- foreign_key: { to_table: :ecom_core_task_templates }
9
+ index: { name: 'wpt_on_ttt_indx' },
10
+ foreign_key: { to_table: :ecom_core_task_template_types }
12
11
 
13
12
  t.timestamps
14
13
  end
14
+
15
+ create_table :ecom_core_task_templates_work_product_templates do |t|
16
+ t.references :task_template,
17
+ null: false,
18
+ index: { name: 'ttwpt_on_tt_indx' },
19
+ foreign_key: { to_table: :ecom_core_task_templates }
20
+ t.references :work_product_template,
21
+ null: false,
22
+ index: { name: 'ttwpt_on_wpt_indx' },
23
+ foreign_key: { to_table: :ecom_core_work_product_templates }
24
+ end
15
25
  end
16
26
  end
@@ -22,10 +22,10 @@ class CreateEcomCoreProjects < ActiveRecord::Migration[6.0]
22
22
  null: false,
23
23
  index: { name: 'employer_on_pm_indx' },
24
24
  foreign_key: { to_table: :ecom_core_stakeholders }
25
- t.references :task_template,
25
+ t.references :task_template_type,
26
26
  null: false,
27
27
  index: { name: 'employer_on_tt_indx' },
28
- foreign_key: { to_table: :ecom_core_task_templates }
28
+ foreign_key: { to_table: :ecom_core_task_template_types }
29
29
  t.string :contract_number, null: false
30
30
  t.date :date_contract_signed, null: false
31
31
  t.date :commencement_date, null: false
@@ -0,0 +1,13 @@
1
+ class CreateEcomCoreProductGroups < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_product_groups do |t|
4
+ t.string :name, null: false, unique: true
5
+ t.references :project,
6
+ null: false,
7
+ index: { name: 'pg_on_project_indx' },
8
+ foreign_key: { to_table: :ecom_core_projects }
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ class CreateEcomCoreWorkPackages < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_work_packages do |t|
4
+ t.string :code, null: false, unique: true
5
+ t.string :name, null: false
6
+ t.string :description
7
+ t.date :start_date
8
+ t.date :end_date
9
+ t.references :project,
10
+ null: false,
11
+ index: { name: 'wp_on_project_indx' },
12
+ foreign_key: { to_table: :ecom_core_projects }
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -1,15 +1,14 @@
1
1
  class CreateEcomCoreWorkProducts < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  create_table :ecom_core_work_products do |t|
4
- t.string :code, null: false
5
4
  t.string :name, null: false
6
5
  t.string :description
7
6
  t.string :design_reference_no, unique: true
8
7
  t.json :dimension
9
- t.references :task,
10
- null: false,
11
- index: { name: 'task_on_wp_indx' },
12
- foreign_key: { to_table: :ecom_core_tasks }
8
+ t.references :product_group,
9
+ null: true,
10
+ index: { name: 'wp_on_pg_indx' },
11
+ foreign_key: { to_table: :ecom_core_product_groups }
13
12
  t.references :work_product_template,
14
13
  null: false,
15
14
  index: { name: 'wpt_on_wp_indx' },
@@ -18,14 +17,9 @@ class CreateEcomCoreWorkProducts < ActiveRecord::Migration[6.0]
18
17
  null: false,
19
18
  index: { name: 'projects_on_wp_indx' },
20
19
  foreign_key: { to_table: :ecom_core_projects }
21
- t.string :assignment_status, default: 'UNASSIGNED'
22
- t.string :task_status, default: 'NEW'
23
- t.integer :percent_completed
20
+ t.string :status, default: 'New'
21
+ t.integer :percent_completed, null: false, default: 0
24
22
  t.string :remark
25
- t.references :performer,
26
- null: true,
27
- index: false,
28
- foreign_key: { to_table: :ecom_core_users }
29
23
  t.references :approver,
30
24
  null: true,
31
25
  index: false,
@@ -40,10 +34,11 @@ class CreateEcomCoreWorkProducts < ActiveRecord::Migration[6.0]
40
34
  foreign_key: { to_table: :ecom_core_users }
41
35
  t.datetime :start_date
42
36
  t.datetime :completion_date
37
+ t.boolean :tasks_generated, null: false, default: false
43
38
 
44
39
  t.timestamps
45
40
  end
46
41
 
47
- add_index :ecom_core_work_products, %i[code project_id], unique: true
42
+ add_index :ecom_core_work_products, %i[design_reference_no project_id], unique: true, name: 'wp_on_drpi_indx'
48
43
  end
49
44
  end
@@ -0,0 +1,45 @@
1
+ class CreateEcomCoreTasks < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_tasks do |t|
4
+ t.string :code, null: false
5
+ t.string :name, null: false
6
+ t.string :description
7
+ t.string :ancestry
8
+ t.date :start_date
9
+ t.date :end_date
10
+ t.string :status, null: false, default: :new
11
+ t.integer :percent_completed, null: false, default: 0
12
+ t.string :remark
13
+ t.references :work_package,
14
+ null: true,
15
+ index: { name: 'wp_on_wp_indx' },
16
+ foreign_key: { to_table: :ecom_core_work_packages }
17
+ t.references :performer,
18
+ null: true,
19
+ index: { name: 'tasks_on_performer_indx' },
20
+ foreign_key: { to_table: :ecom_core_users }
21
+ t.references :approver,
22
+ null: true,
23
+ index: { name: 'tasks_on_approver_indx' },
24
+ foreign_key: { to_table: :ecom_core_users }
25
+ t.references :supervisor,
26
+ null: true,
27
+ index: { name: 'tasks_on_supervisor_indx' },
28
+ foreign_key: { to_table: :ecom_core_users }
29
+ t.references :quality_controller,
30
+ null: true,
31
+ index: { name: 'tasks_on_qc_indx' },
32
+ foreign_key: { to_table: :ecom_core_users }
33
+ t.references :work_product,
34
+ null: false,
35
+ index: { name: 'tasks_on_wp_indx' },
36
+ foreign_key: { to_table: :ecom_core_work_products }
37
+ t.references :task_template,
38
+ null: false,
39
+ index: { name: 'tt_on_project_indx' },
40
+ foreign_key: { to_table: :ecom_core_task_templates }
41
+
42
+ t.timestamps
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,18 @@
1
+ class CreateEcomCoreTaskResources < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_task_resources do |t|
4
+ t.references :task,
5
+ null: false,
6
+ index: { name: 'tr_on_task_indx' },
7
+ foreign_key: { to_table: :ecom_core_tasks }
8
+ t.references :resource_type,
9
+ null: false,
10
+ index: { name: 'tr_on_rt_indx' },
11
+ foreign_key: { to_table: :ecom_core_resource_types }
12
+ t.date :date_assigned
13
+ t.float :amount, nullable: false
14
+
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  module Ecom
2
2
  module Core
3
- VERSION = '1.2.14'.freeze
3
+ VERSION = '1.2.19'.freeze
4
4
  end
5
5
  end
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :application_module, class: Ecom::Core::ApplicationModule do
3
- code { FFaker::Name.name }
3
+ sequence :code do |n|
4
+ "AMCode#{n}"
5
+ end
4
6
  name { FFaker::Name.name }
5
7
  end
6
8
  end
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :company, class: Ecom::Core::Company do
3
- code { FFaker::Name.name }
3
+ sequence :code do |n|
4
+ "CCode#{n}"
5
+ end
4
6
  name { FFaker::Name.name }
5
7
  address { FFaker::Address.street_address }
6
8
  telephone { FFaker::PhoneNumber.phone_number }
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :product_group, class: Ecom::Core::ProductGroup do
3
+ name { FFaker::Name.name }
4
+ association :project
5
+ end
6
+ end
@@ -9,7 +9,7 @@ FactoryBot.define do
9
9
  association :contractor, factory: :stakeholder
10
10
  association :consultant, factory: :stakeholder
11
11
  association :project_manager, factory: :stakeholder
12
- association :task_template
12
+ association :task_template_type
13
13
  contract_number { FFaker::Name.name }
14
14
  date_contract_signed { 30.days.ago }
15
15
  commencement_date { 1.day.ago }
@@ -1,6 +1,8 @@
1
1
  FactoryBot.define do
2
2
  factory :resource_type, class: Ecom::Core::ResourceType do
3
- code { FFaker::Name.name }
3
+ sequence :code do |n|
4
+ "RTCode#{n}"
5
+ end
4
6
  name { FFaker::Name.name }
5
7
  base_unit { FFaker::Name.name }
6
8
  type { 'Ecom::Core::CrewType' }
@@ -0,0 +1,8 @@
1
+ FactoryBot.define do
2
+ factory :task_resource, class: Ecom::Core::TaskResource do
3
+ association :task
4
+ association :resource_type, factory: :crew_type
5
+ date_assigned { Date.today }
6
+ amount { 1 }
7
+ end
8
+ end
@@ -1,6 +1,10 @@
1
1
  FactoryBot.define do
2
2
  factory :task_template_type, class: Ecom::Core::TaskTemplateType do
3
- code { FFaker::Name.unique.name }
4
- name { FFaker::Name.unique.name }
3
+ sequence :code do |n|
4
+ "TTTCode#{n}"
5
+ end
6
+ sequence :name do |n|
7
+ "TTTName#{n}"
8
+ end
5
9
  end
6
10
  end
@@ -1,14 +1,12 @@
1
1
  FactoryBot.define do
2
2
  factory :task_template, class: Ecom::Core::TaskTemplate do
3
- code { FFaker::Name.name }
3
+ sequence :code do |n|
4
+ "TTCode#{n}"
5
+ end
4
6
  name { FFaker::Name.name }
5
7
  description { FFaker::Name.name }
6
8
  association :task_template_type
7
-
8
- factory :task_template_with_product_template do
9
- after :create do |task_template, _|
10
- create(:work_product_template, task_template: task_template)
11
- end
12
- end
9
+ has_takeoff_fields { false }
10
+ fields { [{ name: 'length', label: 'Length' }] }
13
11
  end
14
12
  end
@@ -1,10 +1,21 @@
1
1
  FactoryBot.define do
2
2
  factory :task, class: Ecom::Core::Task do
3
- code { FFaker::Name.name }
3
+ sequence :code do |n|
4
+ "TCode#{n}"
5
+ end
4
6
  name { FFaker::Name.name }
5
7
  description { FFaker::Name.name }
6
- ancestry { FFaker::Name.name }
7
- association :project
8
+ start_date { Date.yesterday }
9
+ end_date { Date.today }
10
+ status { :new }
11
+ percent_completed { 0 }
12
+ remark { FFaker::Name.name }
13
+ association :performer, factory: :user
14
+ association :approver, factory: :user
15
+ association :supervisor, factory: :user
16
+ association :quality_controller, factory: :user
8
17
  association :task_template
18
+ association :work_product
19
+ association :work_package
9
20
  end
10
21
  end
@@ -0,0 +1,12 @@
1
+ FactoryBot.define do
2
+ factory :work_package, class: Ecom::Core::WorkPackage do
3
+ sequence :code do |n|
4
+ "WPCode#{n}"
5
+ end
6
+ name { FFaker::Name.name }
7
+ description { FFaker::Name.name }
8
+ start_date { Date.yesterday }
9
+ end_date { Date.today }
10
+ association :project
11
+ end
12
+ end
@@ -1,9 +1,12 @@
1
1
  FactoryBot.define do
2
2
  factory :work_product_template, class: Ecom::Core::WorkProductTemplate do
3
- code { FFaker::Name.unique.name }
4
- name { FFaker::Name.unique.name }
3
+ sequence :code do |n|
4
+ "Code#{n}"
5
+ end
6
+ sequence :name do |n|
7
+ "Name#{n}"
8
+ end
5
9
  description { FFaker::Name.name }
6
- remark { FFaker::Name.name }
7
- association :task_template
10
+ association :task_template_type
8
11
  end
9
12
  end
@@ -1,22 +1,20 @@
1
1
  FactoryBot.define do
2
2
  factory :work_product, class: Ecom::Core::WorkProduct do
3
- code { FFaker::Name.name }
4
- name { FFaker::Name.unique.name }
3
+ name { FFaker::Name.name }
5
4
  description { FFaker::Name.name }
6
- design_reference_no { FFaker::Name.name }
5
+ design_reference_no { FFaker::Guid.guid }
7
6
  dimension { [{ label: 'Length', name: 'length', value: 12 }] }
8
- association :task
7
+ association :product_group
9
8
  association :work_product_template
10
9
  association :project
11
- assignment_status { :unassigned }
12
- task_status { :new }
10
+ status { Ecom::Core::WorkProduct::NEW }
13
11
  percent_completed { FFaker::Random.rand(1..100) }
14
12
  remark { FFaker::Name.name }
15
- association :performer, factory: :user
16
13
  association :approver, factory: :user
17
14
  association :supervisor, factory: :user
18
15
  association :quality_controller, factory: :user
19
16
  start_date { 1.day.ago }
20
17
  completion_date { Time.now.next_week }
18
+ tasks_generated { false }
21
19
  end
22
20
  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.14
4
+ version: 1.2.19
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-07 00:00:00.000000000 Z
11
+ date: 2020-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm
@@ -234,6 +234,7 @@ files:
234
234
  - app/models/ecom/core/payment.rb
235
235
  - app/models/ecom/core/payment_detail.rb
236
236
  - app/models/ecom/core/payroll.rb
237
+ - app/models/ecom/core/product_group.rb
237
238
  - app/models/ecom/core/product_type.rb
238
239
  - app/models/ecom/core/project.rb
239
240
  - app/models/ecom/core/project_crew.rb
@@ -242,12 +243,12 @@ files:
242
243
  - app/models/ecom/core/stakeholder.rb
243
244
  - app/models/ecom/core/stakeholder_type.rb
244
245
  - app/models/ecom/core/task.rb
246
+ - app/models/ecom/core/task_resource.rb
245
247
  - app/models/ecom/core/task_template.rb
246
248
  - app/models/ecom/core/task_template_type.rb
247
249
  - app/models/ecom/core/user.rb
248
250
  - app/models/ecom/core/user_role.rb
249
- - app/models/ecom/core/work_component.rb
250
- - app/models/ecom/core/work_component_template.rb
251
+ - app/models/ecom/core/work_package.rb
251
252
  - app/models/ecom/core/work_product.rb
252
253
  - app/models/ecom/core/work_product_template.rb
253
254
  - app/serializers/ecom/core/application_module_serializer.rb
@@ -270,17 +271,18 @@ files:
270
271
  - db/migrate/20191119144618_create_ecom_core_stakeholders.rb
271
272
  - db/migrate/20191119145711_create_ecom_core_resource_types.rb
272
273
  - db/migrate/20191201131341_create_ecom_core_product_types.rb
273
- - db/migrate/20191201134420_create_ecom_core_work_component_templates.rb
274
274
  - db/migrate/20191201145816_create_ecom_core_currencies.rb
275
275
  - db/migrate/20191201145848_create_ecom_core_projects.rb
276
- - db/migrate/20191202103735_create_ecom_core_tasks.rb
276
+ - db/migrate/20191201251015_create_ecom_core_product_groups.rb
277
277
  - db/migrate/20191202105355_create_task_templates_resource_types.rb
278
278
  - db/migrate/20191202220752_create_ecom_core_application_modules.rb
279
279
  - db/migrate/20191202220832_create_ecom_core_users.rb
280
280
  - db/migrate/20191202220953_create_ecom_core_user_roles.rb
281
281
  - db/migrate/20191202221423_create_ecom_core_menus.rb
282
+ - db/migrate/20191202222210_create_ecom_core_work_packages.rb
282
283
  - db/migrate/20191202235434_create_ecom_core_work_products.rb
283
- - db/migrate/20191206104247_create_ecom_core_work_components.rb
284
+ - db/migrate/20191207103735_create_ecom_core_tasks.rb
285
+ - db/migrate/20191210724614_create_ecom_core_task_resources.rb
284
286
  - db/migrate/20191225100054_create_ecom_core_crews.rb
285
287
  - db/migrate/20191225121850_create_ecom_core_project_crews.rb
286
288
  - db/migrate/20191225140433_create_ecom_core_attendance_sheets.rb
@@ -340,6 +342,7 @@ files:
340
342
  - spec/factories/ecom/core/payment_details.rb
341
343
  - spec/factories/ecom/core/payments.rb
342
344
  - spec/factories/ecom/core/payrolls.rb
345
+ - spec/factories/ecom/core/product_groups.rb
343
346
  - spec/factories/ecom/core/product_types.rb
344
347
  - spec/factories/ecom/core/project_crews.rb
345
348
  - spec/factories/ecom/core/projects.rb
@@ -347,13 +350,13 @@ files:
347
350
  - spec/factories/ecom/core/resource_types.rb
348
351
  - spec/factories/ecom/core/stakeholder_types.rb
349
352
  - spec/factories/ecom/core/stakeholders.rb
353
+ - spec/factories/ecom/core/task_resources.rb
350
354
  - spec/factories/ecom/core/task_template_types.rb
351
355
  - spec/factories/ecom/core/task_templates.rb
352
356
  - spec/factories/ecom/core/tasks.rb
353
357
  - spec/factories/ecom/core/user_roles.rb
354
358
  - spec/factories/ecom/core/users.rb
355
- - spec/factories/ecom/core/work_component_templates.rb
356
- - spec/factories/ecom/core/work_components.rb
359
+ - spec/factories/ecom/core/work_packages.rb
357
360
  - spec/factories/ecom/core/work_product_templates.rb
358
361
  - spec/factories/ecom/core/work_products.rb
359
362
  homepage: http://www.mks.com.et
@@ -1,14 +0,0 @@
1
- module Ecom
2
- module Core
3
- class WorkComponent < ApplicationRecord
4
- belongs_to :performer, class_name: 'Ecom::Core::User'
5
- belongs_to :approver, class_name: 'Ecom::Core::User'
6
- belongs_to :supervisor, class_name: 'Ecom::Core::User'
7
- belongs_to :quality_controller, class_name: 'Ecom::Core::User'
8
- belongs_to :work_component_template
9
- belongs_to :work_product
10
-
11
- validates :name, :assignment_status, :task_status, :percent_completed, presence: true
12
- end
13
- end
14
- end
@@ -1,11 +0,0 @@
1
- module Ecom
2
- module Core
3
- class WorkComponentTemplate < ApplicationRecord
4
- belongs_to :work_product_template
5
- belongs_to :task_template
6
-
7
- validates :code, :name, presence: true
8
- validates :code, uniqueness: { scope: %i[work_product_template_id task_template_id] }
9
- end
10
- end
11
- end
@@ -1,25 +0,0 @@
1
- class CreateEcomCoreWorkComponentTemplates < ActiveRecord::Migration[6.0]
2
- def change
3
- create_table :ecom_core_work_component_templates do |t|
4
- t.string :code, null: false
5
- t.string :name, null: false
6
- t.string :description
7
- t.integer :relative_percentage
8
- t.json :dimension
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 }
17
-
18
- t.timestamps
19
- end
20
-
21
- add_index :ecom_core_work_component_templates, %i[code work_product_template_id task_template_id],
22
- unique: true,
23
- name: 'wct_on_code_wpt_id_tt_id_indx'
24
- end
25
- end
@@ -1,20 +0,0 @@
1
- class CreateEcomCoreTasks < ActiveRecord::Migration[6.0]
2
- def change
3
- create_table :ecom_core_tasks do |t|
4
- t.string :code, null: false
5
- t.string :name, null: false
6
- t.string :description
7
- t.string :ancestry
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 }
16
-
17
- t.timestamps
18
- end
19
- end
20
- end
@@ -1,40 +0,0 @@
1
- class CreateEcomCoreWorkComponents < ActiveRecord::Migration[6.0]
2
- def change
3
- create_table :ecom_core_work_components do |t|
4
- t.string :name, null: false
5
- t.json :dimension
6
- t.string :assignment_status, null: false, default: :unassigned
7
- t.string :task_status, null: false, default: :new
8
- t.integer :percent_completed, null: false, default: 0
9
- t.string :remark
10
- t.references :performer,
11
- null: true,
12
- index: false,
13
- foreign_key: { to_table: :ecom_core_users }
14
- t.references :approver,
15
- null: true,
16
- index: false,
17
- foreign_key: { to_table: :ecom_core_users }
18
- t.references :supervisor,
19
- null: true,
20
- index: false,
21
- foreign_key: { to_table: :ecom_core_users }
22
- t.references :quality_controller,
23
- null: true,
24
- index: false,
25
- foreign_key: { to_table: :ecom_core_users }
26
- t.date :start_date
27
- t.date :completion_date
28
- t.references :work_component_template,
29
- null: false,
30
- index: { name: 'wct_on_wc_indx' },
31
- foreign_key: { to_table: :ecom_core_work_component_templates }
32
- t.references :work_product,
33
- null: false,
34
- index: { name: 'wp_on_wc_indx' },
35
- foreign_key: { to_table: :ecom_core_work_products }
36
-
37
- t.timestamps
38
- end
39
- end
40
- end
@@ -1,11 +0,0 @@
1
- FactoryBot.define do
2
- factory :work_component_template, class: Ecom::Core::WorkComponentTemplate do
3
- code { FFaker::Name.name }
4
- name { FFaker::Name.name }
5
- description { FFaker::Name.name }
6
- relative_percentage { FFaker::Random.rand(0..100) }
7
- dimension { [{ label: 'Length', name: 'length' }, { label: 'Width', name: 'width' }] }
8
- association :work_product_template
9
- association :task_template
10
- end
11
- end
@@ -1,18 +0,0 @@
1
- FactoryBot.define do
2
- factory :work_component, class: Ecom::Core::WorkComponent do
3
- name { FFaker::Name.name }
4
- dimension { [{ label: 'Length', name: 'length', value: 10 }] }
5
- assignment_status { :unassigned }
6
- task_status { :new }
7
- percent_completed { FFaker::Random.rand(1..100) }
8
- remark { FFaker::Name.name }
9
- association :performer, factory: :user
10
- association :approver, factory: :user
11
- association :supervisor, factory: :user
12
- association :quality_controller, factory: :user
13
- start_date { 1.day.ago }
14
- completion_date { Time.now.next_week }
15
- association :work_component_template
16
- association :work_product
17
- end
18
- end