ecom_core 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +24 -0
  5. data/app/controllers/concerns/ecom/core/resource_typeable.rb +43 -0
  6. data/app/controllers/ecom/core/application_controller.rb +7 -0
  7. data/app/controllers/ecom/core/crew_types_controller.rb +7 -0
  8. data/app/models/ecom/core/application_module.rb +7 -0
  9. data/app/models/ecom/core/application_record.rb +7 -0
  10. data/app/models/ecom/core/crew.rb +14 -0
  11. data/app/models/ecom/core/crew_time.rb +9 -0
  12. data/app/models/ecom/core/crew_type.rb +6 -0
  13. data/app/models/ecom/core/currency.rb +7 -0
  14. data/app/models/ecom/core/equipment_type.rb +6 -0
  15. data/app/models/ecom/core/material_type.rb +6 -0
  16. data/app/models/ecom/core/menu.rb +10 -0
  17. data/app/models/ecom/core/product_type.rb +10 -0
  18. data/app/models/ecom/core/project.rb +15 -0
  19. data/app/models/ecom/core/resource_type.rb +9 -0
  20. data/app/models/ecom/core/stakeholder.rb +11 -0
  21. data/app/models/ecom/core/stakeholder_type.rb +7 -0
  22. data/app/models/ecom/core/task.rb +10 -0
  23. data/app/models/ecom/core/task_template.rb +34 -0
  24. data/app/models/ecom/core/task_template_type.rb +7 -0
  25. data/app/models/ecom/core/user.rb +18 -0
  26. data/app/models/ecom/core/user_role.rb +12 -0
  27. data/app/models/ecom/core/work_component.rb +14 -0
  28. data/app/models/ecom/core/work_component_template.rb +11 -0
  29. data/app/models/ecom/core/work_product.rb +70 -0
  30. data/app/models/ecom/core/work_product_template.rb +14 -0
  31. data/app/serializers/ecom/core/resource_type_serializer.rb +8 -0
  32. data/config/database.ci.yml +12 -0
  33. data/config/routes.rb +3 -0
  34. data/db/migrate/20191119010518_create_ecom_core_task_template_types.rb +13 -0
  35. data/db/migrate/20191119012030_create_ecom_core_task_templates.rb +15 -0
  36. data/db/migrate/20191119013236_create_ecom_core_work_product_templates.rb +15 -0
  37. data/db/migrate/20191119144141_create_ecom_core_stakeholder_types.rb +10 -0
  38. data/db/migrate/20191119144618_create_ecom_core_stakeholders.rb +19 -0
  39. data/db/migrate/20191119145711_create_ecom_core_resource_types.rb +15 -0
  40. data/db/migrate/20191201131341_create_ecom_core_product_types.rb +14 -0
  41. data/db/migrate/20191201134420_create_ecom_core_work_component_templates.rb +23 -0
  42. data/db/migrate/20191201145816_create_ecom_core_currencies.rb +10 -0
  43. data/db/migrate/20191201145848_create_ecom_core_projects.rb +34 -0
  44. data/db/migrate/20191202103735_create_ecom_core_tasks.rb +17 -0
  45. data/db/migrate/20191202105355_create_task_templates_resource_types.rb +16 -0
  46. data/db/migrate/20191202220752_create_ecom_core_application_modules.rb +10 -0
  47. data/db/migrate/20191202220832_create_ecom_core_users.rb +24 -0
  48. data/db/migrate/20191202220953_create_ecom_core_user_roles.rb +22 -0
  49. data/db/migrate/20191202221423_create_ecom_core_menus.rb +25 -0
  50. data/db/migrate/20191202235434_create_ecom_core_work_products.rb +35 -0
  51. data/db/migrate/20191206104247_create_ecom_core_work_components.rb +30 -0
  52. data/db/migrate/20191225100054_create_ecom_core_crews.rb +17 -0
  53. data/db/migrate/20191225211712_create_ecom_core_crew_times.rb +16 -0
  54. data/lib/ecom/core/engine.rb +25 -0
  55. data/lib/ecom/core/version.rb +5 -0
  56. data/lib/ecom/core.rb +4 -0
  57. data/lib/ecom_core.rb +5 -0
  58. data/lib/tasks/ecom_core_tasks.rake +4 -0
  59. data/spec/factories/ecom/core/application_modules.rb +6 -0
  60. data/spec/factories/ecom/core/crew_times.rb +10 -0
  61. data/spec/factories/ecom/core/crew_types.rb +5 -0
  62. data/spec/factories/ecom/core/crews.rb +12 -0
  63. data/spec/factories/ecom/core/currencies.rb +6 -0
  64. data/spec/factories/ecom/core/equipment_types.rb +5 -0
  65. data/spec/factories/ecom/core/material_types.rb +5 -0
  66. data/spec/factories/ecom/core/menus.rb +9 -0
  67. data/spec/factories/ecom/core/product_types.rb +7 -0
  68. data/spec/factories/ecom/core/projects.rb +23 -0
  69. data/spec/factories/ecom/core/resource_types.rb +8 -0
  70. data/spec/factories/ecom/core/stakeholder_types.rb +5 -0
  71. data/spec/factories/ecom/core/stakeholders.rb +13 -0
  72. data/spec/factories/ecom/core/task_template_types.rb +6 -0
  73. data/spec/factories/ecom/core/task_templates.rb +15 -0
  74. data/spec/factories/ecom/core/tasks.rb +10 -0
  75. data/spec/factories/ecom/core/user_roles.rb +6 -0
  76. data/spec/factories/ecom/core/users.rb +9 -0
  77. data/spec/factories/ecom/core/work_component_templates.rb +11 -0
  78. data/spec/factories/ecom/core/work_components.rb +18 -0
  79. data/spec/factories/ecom/core/work_product_templates.rb +9 -0
  80. data/spec/factories/ecom/core/work_products.rb +22 -0
  81. metadata +291 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 47ccd7e2c54144e923760559287513ba289fb117647a448890de1bcb9b971d67
4
+ data.tar.gz: b8e18049239a4241bf93aec57e0a57d451edacd791e11ad51ac2daf8cfaa0854
5
+ SHA512:
6
+ metadata.gz: 7cea63bfb85af16d0171286a566101ecabe2f3bceab181400d6de20dede48c5766154c26bced86d8920eb64f3bde0b7cfc98657ae003a444290c6ec488cb9723
7
+ data.tar.gz: faa67d9ee5d399e3236b8d69af16c57021c464ec0a831890f3ae69b8d5710357455200cbfe7f7068124aab0aacf28e8e12da6aa287a1dcf7e7d63d0bdd3c11b4
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Henock L.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Ecom Core
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'ecom_core'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install ecom_model
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'EcomCore'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+ require 'rspec/core/rake_task'
24
+ RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
@@ -0,0 +1,43 @@
1
+ module Ecom
2
+ module Core
3
+ module ResourceTypeable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ before_action :set_clazz
8
+ end
9
+
10
+ def index
11
+ render json: ResourceTypeSerializer.new(@clazz.all)
12
+ end
13
+
14
+ def create
15
+ resource_type = @clazz.new(resource_type_params)
16
+ if resource_type.save
17
+ render json: ResourceTypeSerializer.new(resource_type), status: :created
18
+ else
19
+ render json: { success: false, errors: resource_type.errors }, status: :unprocessable_entity
20
+ end
21
+ end
22
+
23
+ def update
24
+ resource_type = @clazz.find(params[:id])
25
+ if resource_type.update(resource_type_params)
26
+ render json: ResourceTypeSerializer.new(resource_type)
27
+ else
28
+ render json: { success: false, errors: resource_type.errors }, status: :unprocessable_entity
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def set_clazz
35
+ @clazz = "Ecom::Core::#{controller_name.classify}".constantize
36
+ end
37
+
38
+ def resource_type_params
39
+ params.require(:resource_type).permit(:code, :name, :base_unit)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,7 @@
1
+ module Ecom
2
+ module Core
3
+ class ApplicationController < ActionController::API
4
+ # protect_from_forgery with: :exception
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Ecom
2
+ module Core
3
+ class CrewTypesController < ApplicationController
4
+ include ResourceTypeable
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Ecom
2
+ module Core
3
+ class ApplicationModule < ApplicationRecord
4
+ validates :code, :name, uniqueness: true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Ecom
2
+ module Core
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ module Ecom
2
+ module Core
3
+ class Crew < ApplicationRecord
4
+ PERMANENT = 'Permanent'.freeze
5
+ TEMPORARY = 'Temporary'.freeze
6
+
7
+ belongs_to :crew_type
8
+
9
+ validates :name, :qualification, presence: true
10
+ validates :wage, presence: true, if: ->(o) { o.employment == PERMANENT }
11
+ validates :wage, absence: true, if: ->(o) { o.employment == TEMPORARY }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ module Ecom
2
+ module Core
3
+ class CrewTime < ApplicationRecord
4
+ belongs_to :crew
5
+
6
+ validates :date, presence: true
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ module Ecom
2
+ module Core
3
+ class CrewType < ResourceType
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module Ecom
2
+ module Core
3
+ class Currency < ApplicationRecord
4
+ validates :code, :name, presence: true, uniqueness: true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module Ecom
2
+ module Core
3
+ class EquipmentType < ResourceType
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Ecom
2
+ module Core
3
+ class MaterialType < ResourceType
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ module Ecom
2
+ module Core
3
+ class Menu < ApplicationRecord
4
+ belongs_to :parent, class_name: 'Ecom::Core::Menu', optional: true
5
+ belongs_to :application_module
6
+
7
+ validates :label, :route, presence: true
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Ecom
2
+ module Core
3
+ class ProductType < ApplicationRecord
4
+ belongs_to :work_product_template
5
+
6
+ validates :name, presence: true
7
+ validates :name, uniqueness: { scope: :work_product_template_id }
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ module Ecom
2
+ module Core
3
+ class Project < ApplicationRecord
4
+ belongs_to :employer, class_name: 'Ecom::Core::Stakeholder'
5
+ belongs_to :contractor, class_name: 'Ecom::Core::Stakeholder'
6
+ belongs_to :consultant, class_name: 'Ecom::Core::Stakeholder'
7
+ belongs_to :project_manager, class_name: 'Ecom::Core::Stakeholder'
8
+ belongs_to :task_template
9
+ belongs_to :currency
10
+
11
+ validates :name, :location, :contract_number, :date_contract_signed, :commencement_date, :completion_date,
12
+ :contract_amount, :advance_payment, :retention, presence: true
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module Ecom
2
+ module Core
3
+ class ResourceType < ApplicationRecord
4
+ validates :code, :name, :base_unit, :type, presence: true
5
+ validates :code, uniqueness: { scope: :type }
6
+ validates :name, uniqueness: { scope: :type }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Ecom
2
+ module Core
3
+ class Stakeholder < ApplicationRecord
4
+ belongs_to :stakeholder_type
5
+
6
+ validates :name, presence: true, uniqueness: true
7
+
8
+ delegate :name, to: :stakeholder_type, prefix: true
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Ecom
2
+ module Core
3
+ class StakeholderType < ApplicationRecord
4
+ validates :name, presence: true, uniqueness: true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ module Ecom
2
+ module Core
3
+ class Task < ApplicationRecord
4
+ belongs_to :project
5
+ belongs_to :task_template
6
+
7
+ validates :code, :name, presence: true
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ module Ecom
2
+ module Core
3
+ class TaskTemplate < ApplicationRecord
4
+ has_ancestry
5
+
6
+ belongs_to :task_template_type
7
+ has_one :work_product_template
8
+ has_and_belongs_to_many :resource_types, join_table: 'ecom_core_task_templates_resource_types'
9
+
10
+ validates :name, :code, presence: true
11
+ validates :code, uniqueness: true
12
+ delegate(:name, to: :task_template_type, prefix: true)
13
+
14
+ def full_name
15
+ parent_name = parent&.name
16
+ return name unless parent_name
17
+
18
+ "#{name} - #{parent_name}"
19
+ end
20
+
21
+ def crew_types
22
+ resource_types.where(type: 'Ecom::Core::CrewType')
23
+ end
24
+
25
+ def material_types
26
+ resource_types.where(type: 'Ecom::Core::MaterialType')
27
+ end
28
+
29
+ def equipment_types
30
+ resource_types.where(type: 'Ecom::Core::EquipmentType')
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ module Ecom
2
+ module Core
3
+ class TaskTemplateType < ApplicationRecord
4
+ validates :code, :name, presence: true, uniqueness: true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ module Ecom
2
+ module Core
3
+ class User < ApplicationRecord
4
+ has_secure_password
5
+
6
+ has_and_belongs_to_many :user_roles, join_table: 'ecom_core_users_user_roles'
7
+
8
+ VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i.freeze
9
+ validates :first_name, :last_name, :active, presence: true
10
+ validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false }
11
+ validates :password, length: { minimum: 6 }
12
+
13
+ def full_name
14
+ "#{first_name} #{last_name}"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ module Ecom
2
+ module Core
3
+ class UserRole < ApplicationRecord
4
+ belongs_to :application_module
5
+ has_and_belongs_to_many :users, join_table: 'ecom_core_users_user_roles'
6
+ has_and_belongs_to_many :menus, join_table: 'ecom_core_menus_user_roles'
7
+
8
+ validates :name, presence: true
9
+ validates :name, uniqueness: { scope: :application_module_id }
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,11 @@
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
@@ -0,0 +1,70 @@
1
+ # The WorkProduct core represents a task being implemented on a specific
2
+ # work product. To this regard, a work product is an assignable itself which
3
+ # contains the basic product attributes (e.g. dimension, name, design reference)
4
+ # on one hand, and task related attributes (e.g. start date and completion date)
5
+ # on the other hand. A task may have multiple work products under it. It is
6
+ # important to note that currently there is no direct way to link products and
7
+ # sub products, as we have done with tasks and sub tasks. If there is a desire
8
+ # to have such a link between products (e.g. we may later want to have reports
9
+ # per specific high level products, which in turn asks for finding all sub products
10
+ # under the selected high level product and do calculations), then a `code` field
11
+ # has been introduced to the WorkProduct core. This field can be used in a similar
12
+ # way as chart of accounts to identify parent and child relationships. Even then,
13
+ # there needs to be a well defined coding scheme developed before using the column
14
+ # field.
15
+ #
16
+ module Ecom
17
+ module Core
18
+ class WorkProduct < ApplicationRecord
19
+ include AASM
20
+
21
+ belongs_to :work_product_template
22
+ belongs_to :task
23
+ belongs_to :project
24
+ belongs_to :performer, class_name: 'Ecom::Core::User'
25
+ belongs_to :approver, class_name: 'Ecom::Core::User'
26
+ belongs_to :supervisor, class_name: 'Ecom::Core::User'
27
+ belongs_to :quality_controller, class_name: 'Ecom::Core::User'
28
+
29
+ validates :name, presence: true
30
+ validates :design_reference_no, uniqueness: true
31
+
32
+ aasm column: 'task_status' do
33
+ state :new, initial: true
34
+ state :in_progress
35
+ state :submitted
36
+ state :under_review
37
+ state :completed
38
+
39
+ event :start do
40
+ transitions from: :new, to: :in_progress
41
+ end
42
+
43
+ event :submit do
44
+ transitions from: :in_progress, to: :submitted
45
+ end
46
+
47
+ event :review do
48
+ transitions from: :submitted, to: :under_review
49
+ end
50
+
51
+ event :complete do
52
+ transitions from: %i[submitted under_review], to: :completed
53
+ end
54
+
55
+ event :rework do
56
+ transitions from: :under_review, to: :in_progress
57
+ end
58
+ end
59
+
60
+ aasm column: 'assignment_status' do
61
+ state :unassigned, initial: true
62
+ state :assigned
63
+
64
+ event :assign do
65
+ transitions from: :unassigned, to: :assigned
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,14 @@
1
+ module Ecom
2
+ module Core
3
+ class WorkProductTemplate < ApplicationRecord
4
+ validates :code, :name, presence: true, uniqueness: true
5
+ belongs_to :task_template
6
+ 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
+ end
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ module Ecom
2
+ module Core
3
+ class ResourceTypeSerializer
4
+ include FastJsonapi::ObjectSerializer
5
+ attributes :code, :name, :base_unit, :type
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ default: &default
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ pool: 5
5
+ timeout: 5000
6
+ host: <%= ENV['DB_HOST'] %>
7
+ username: <%= ENV['POSTGRES_USER'] %>
8
+ password: <%= ENV['POSTGRES_PASSWORD'] %>
9
+ database: <%= ENV['POSTGRES_DB'] %>
10
+
11
+ test:
12
+ <<: *default
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Ecom::Core::Engine.routes.draw do
2
+ resources :crew_types
3
+ end
@@ -0,0 +1,13 @@
1
+ class CreateEcomCoreTaskTemplateTypes < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_task_template_types do |t|
4
+ t.string :code, null: false
5
+ t.string :name, null: false
6
+
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :ecom_core_task_template_types, :code, unique: true
11
+ add_index :ecom_core_task_template_types, :name, unique: true
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ class CreateEcomCoreTaskTemplates < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_task_templates do |t|
4
+ t.string :code, null: false
5
+ t.string :name, null: false
6
+ t.string :description
7
+ t.references :task_template_type, index: { name: 'ttt_on_tt_indx' }
8
+ t.string :ancestry, index: true
9
+
10
+ t.timestamps
11
+ end
12
+
13
+ add_foreign_key :ecom_core_task_templates, :ecom_core_task_template_types, column: :task_template_type_id
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class CreateEcomCoreWorkProductTemplates < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_work_product_templates do |t|
4
+ t.string :code, null: false, unique: true
5
+ t.string :name, null: false, unique: true
6
+ t.string :description
7
+ t.string :remark
8
+ t.references :task_template, index: { name: 'tt_on_wpt_indx' }
9
+
10
+ t.timestamps
11
+ end
12
+
13
+ add_foreign_key :ecom_core_work_product_templates, :ecom_core_task_templates, column: :task_template_id
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ class CreateEcomCoreStakeholderTypes < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_stakeholder_types do |t|
4
+ t.string :name, null: false, unique: true
5
+ t.string :description
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ class CreateEcomCoreStakeholders < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_stakeholders do |t|
4
+ t.string :name, null: false, unique: true
5
+ t.string :type_of_business
6
+ t.string :address
7
+ t.string :license_no
8
+ t.string :tin_no
9
+ t.string :contact_name, null: false
10
+ t.string :contact_phone, null: false
11
+ t.string :contact_email, null: false
12
+ t.references :stakeholder_type, index: { name: 'em_stakeholders_on_type_indx' }
13
+
14
+ t.timestamps
15
+ end
16
+
17
+ add_foreign_key :ecom_core_stakeholders, :ecom_core_stakeholder_types, column: :stakeholder_type_id
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ class CreateEcomCoreResourceTypes < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_resource_types do |t|
4
+ t.string :code, null: false
5
+ t.string :name, null: false
6
+ t.string :base_unit, null: false
7
+ t.string :type, null: false
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :ecom_core_resource_types, %i[code type], unique: true
13
+ add_index :ecom_core_resource_types, %i[name type], unique: true
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ class CreateEcomCoreProductTypes < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :ecom_core_product_types do |t|
4
+ t.string :name, null: false
5
+ t.references :work_product_template, index: { name: 'pt_on_wpt_indx' }
6
+ t.json :dimension
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ 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
+ end
14
+ end
@@ -0,0 +1,23 @@
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, index: { name: 'wct_on_wpt_indx' }
10
+ t.references :task_template, index: { name: 'wct_on_tt_indx' }
11
+
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :ecom_core_work_component_templates, %i[code work_product_template_id task_template_id],
16
+ unique: true,
17
+ 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
+ end
23
+ end