erp_work_effort 3.1.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/app/controllers/erp_work_effort/erp_app/organizer/tasks/base_controller.rb +13 -0
  3. data/app/controllers/erp_work_effort/erp_app/organizer/tasks/work_efforts_controller.rb +128 -0
  4. data/app/models/associated_transportation_route.rb +12 -0
  5. data/app/models/associated_work_effort.rb +12 -0
  6. data/app/models/deliverable.rb +7 -0
  7. data/app/models/deliverable_type.rb +9 -0
  8. data/app/models/extensions/party.rb +0 -2
  9. data/app/models/good_type.rb +11 -0
  10. data/app/models/party_fixed_asset_assignment.rb +12 -0
  11. data/app/models/party_skill.rb +6 -0
  12. data/app/models/requirement.rb +14 -0
  13. data/app/models/requirement_party_role.rb +8 -0
  14. data/app/models/requirement_type.rb +7 -0
  15. data/app/models/skill_type.rb +10 -0
  16. data/app/models/transportation_route.rb +71 -0
  17. data/app/models/transportation_route_segment.rb +9 -0
  18. data/app/models/transportation_route_stop.rb +6 -0
  19. data/app/models/work_effort.rb +82 -92
  20. data/app/models/work_effort_association.rb +16 -0
  21. data/app/models/work_effort_association_type.rb +14 -0
  22. data/app/models/work_effort_deliverable_produced.rb +6 -0
  23. data/app/models/work_effort_fixed_asset_assignment.rb +10 -0
  24. data/app/models/work_effort_fixed_asset_serviced.rb +6 -0
  25. data/app/models/work_effort_fixed_asset_standard.rb +7 -0
  26. data/app/models/work_effort_good_standard.rb +7 -0
  27. data/app/models/work_effort_inventory_assignment.rb +10 -0
  28. data/app/models/work_effort_inventory_produced.rb +7 -0
  29. data/app/models/work_effort_party_assignment.rb +12 -0
  30. data/app/models/work_effort_purpose_type.rb +11 -0
  31. data/app/models/work_effort_skill_standard.rb +7 -0
  32. data/app/models/work_effort_type.rb +9 -0
  33. data/app/models/work_effort_type_association.rb +10 -0
  34. data/app/models/work_order_item.rb +5 -0
  35. data/app/models/work_order_item_fulfillment.rb +11 -0
  36. data/app/models/work_requirement_fulfillment.rb +3 -0
  37. data/config/routes.rb +20 -0
  38. data/db/data_migrations/20131213151309_create_tasks_organizer_application.rb +14 -0
  39. data/db/data_migrations/20131215225329_add_task_work_effort_types.rb +11 -0
  40. data/db/data_migrations/20131215234936_add_task_statuses.rb +21 -0
  41. data/db/migrate/20100220000000_base_work_efforts.rb +506 -103
  42. data/db/migrate/20130829153419_base_routes.rb +93 -0
  43. data/db/migrate/20131213140617_add_work_effort_role_assignments.rb +16 -0
  44. data/db/migrate/20131213144223_add_work_item_to_work_effort.rb +8 -0
  45. data/db/migrate/20140106184615_update_work_effort_item_id_to_int.rb +27 -0
  46. data/lib/erp_work_effort.rb +1 -1
  47. data/lib/erp_work_effort/engine.rb +7 -5
  48. data/lib/erp_work_effort/extensions.rb +2 -4
  49. data/lib/erp_work_effort/extensions/active_record/acts_as_routable.rb +55 -0
  50. data/lib/erp_work_effort/extensions/active_record/acts_as_work_effort.rb +66 -0
  51. data/lib/erp_work_effort/version.rb +7 -3
  52. data/spec/models/deliverable_spec.rb +5 -0
  53. data/spec/models/deliverable_type_spec.rb +5 -0
  54. data/spec/models/facility_spec.rb +8 -0
  55. data/spec/models/facility_type_spec.rb +8 -0
  56. data/spec/models/fixed_asset_party_role_spec.rb +5 -0
  57. data/spec/models/fixed_asset_spec.rb +5 -0
  58. data/spec/models/fixed_asset_type_spec.rb +5 -0
  59. data/spec/models/good_type_spec.rb +5 -0
  60. data/spec/models/party_fixed_asset_assignment_spec.rb +5 -0
  61. data/spec/models/party_skill_spec.rb +5 -0
  62. data/spec/models/requirement_party_role_spec.rb +5 -0
  63. data/spec/models/requirement_spec.rb +5 -0
  64. data/spec/models/requirement_type_spec.rb +5 -0
  65. data/spec/models/skill_type_spec.rb +8 -0
  66. data/spec/models/work_effort_association_spec.rb +5 -0
  67. data/spec/models/work_effort_association_type_spec.rb +5 -0
  68. data/spec/models/work_effort_deliverable_produced_spec.rb +5 -0
  69. data/spec/models/work_effort_fixed_asset_assignment_spec.rb +5 -0
  70. data/spec/models/work_effort_fixed_asset_serviced_spec.rb +5 -0
  71. data/spec/models/work_effort_fixed_asset_standard_spec.rb +5 -0
  72. data/spec/models/work_effort_good_standard_spec.rb +5 -0
  73. data/spec/models/work_effort_inventory_assignment_spec.rb +5 -0
  74. data/spec/models/work_effort_inventory_produced_spec.rb +5 -0
  75. data/spec/models/work_effort_party_assignment_spec.rb +5 -0
  76. data/spec/models/work_effort_purpose_type_spec.rb +5 -0
  77. data/spec/models/work_effort_skill_standard_spec.rb +5 -0
  78. data/spec/models/work_effort_spec.rb +49 -0
  79. data/spec/models/work_effort_type_association_spec.rb +5 -0
  80. data/spec/models/work_effort_type_spec.rb +5 -0
  81. data/spec/models/work_order_item_fulfillment_spec.rb +5 -0
  82. data/spec/models/work_order_item_spec.rb +29 -0
  83. data/spec/models/work_requirement_fulfillment_spec.rb +5 -0
  84. metadata +141 -105
  85. data/app/assets/javascripts/erp_work_effort/application.js +0 -9
  86. data/app/assets/stylesheets/erp_work_effort/application.css +0 -7
  87. data/app/controllers/erp_work_effort/application_controller.rb +0 -4
  88. data/app/helpers/erp_work_effort/application_helper.rb +0 -4
  89. data/app/models/cost.rb +0 -5
  90. data/app/models/project_effort.rb +0 -2
  91. data/app/models/project_requirement.rb +0 -2
  92. data/app/models/support_effort.rb +0 -2
  93. data/app/models/support_requirement.rb +0 -2
  94. data/app/models/work_effort_assignment.rb +0 -12
  95. data/app/models/work_effort_status.rb +0 -6
  96. data/app/models/work_effort_status_type.rb +0 -15
  97. data/app/models/work_requirement.rb +0 -78
  98. data/app/models/work_requirement_work_effort_status_type.rb +0 -6
  99. data/app/views/layouts/erp_work_effort/application.html.erb +0 -14
  100. data/lib/erp_work_effort/extensions/active_record/acts_as_project_effort.rb +0 -66
  101. data/lib/erp_work_effort/extensions/active_record/acts_as_project_requirement.rb +0 -64
  102. data/lib/erp_work_effort/extensions/active_record/acts_as_support_effort.rb +0 -61
  103. data/lib/erp_work_effort/extensions/active_record/acts_as_support_requirement.rb +0 -68
  104. data/spec/dummy/db/data_migrations/20110109173616_create_capability_scope_types.erp_tech_svcs.rb +0 -15
  105. data/spec/dummy/db/data_migrations/20110525001935_add_usd_currency.erp_base_erp_svcs.rb +0 -12
  106. data/spec/dummy/db/data_migrations/20110609150135_add_iso_codes.erp_base_erp_svcs.rb +0 -19
  107. data/spec/dummy/db/data_migrations/20110802200222_schedule_delete_expired_sessions_job.erp_tech_svcs.rb +0 -16
  108. data/spec/dummy/db/data_migrations/20110913145838_setup_compass_ae_instance.erp_base_erp_svcs.rb +0 -12
  109. data/spec/dummy/db/data_migrations/20111111144706_setup_audit_log_types.erp_tech_svcs.rb +0 -22
  110. data/spec/dummy/db/data_migrations/20121116155018_create_group_relationship_and_role_types.erp_tech_svcs.rb +0 -20
  111. data/spec/dummy/db/data_migrations/20121130212146_note_capabilities.erp_tech_svcs.rb +0 -24
  112. data/spec/dummy/db/migrate/20130107204429_base_erp_services.erp_base_erp_svcs.rb +0 -461
  113. data/spec/dummy/db/migrate/20130107204430_base_work_efforts.erp_work_effort.rb +0 -211
  114. data/spec/dummy/db/migrate/20130107204431_base_tech_services.erp_tech_svcs.rb +0 -271
  115. data/spec/dummy/db/migrate/20130107204432_create_has_attribute_tables.erp_tech_svcs.rb +0 -39
  116. data/spec/dummy/db/migrate/20130107204433_create_groups.erp_tech_svcs.rb +0 -19
  117. data/spec/dummy/db/migrate/20130107204434_upgrade_security.erp_tech_svcs.rb +0 -54
  118. data/spec/dummy/db/migrate/20130107204435_upgrade_security2.erp_tech_svcs.rb +0 -270
  119. data/spec/dummy/db/schema.rb +0 -750
  120. data/spec/dummy/db/spec.sqlite3 +0 -0
  121. data/spec/models/cost_spec.rb +0 -11
  122. data/spec/models/project_effort_spec.rb +0 -11
  123. data/spec/models/project_requirement_spec.rb +0 -11
  124. data/spec/models/support_effort_spec.rb +0 -11
  125. data/spec/models/support_requirement_spec.rb +0 -11
  126. data/spec/models/valid_work_assignment_attribute_spec.rb +0 -11
  127. data/spec/models/valid_work_assignment_spec.rb +0 -11
  128. data/spec/models/work_effort_assignment_spec.rb +0 -13
  129. data/spec/models/work_effort_status_spec.rb +0 -11
  130. data/spec/models/work_effort_status_type_spec.rb +0 -11
  131. data/spec/models/work_requirement_spec.rb +0 -11
  132. data/spec/models/work_requirement_work_effort_status_type._spec.rb +0 -11
@@ -0,0 +1,16 @@
1
+ ## Work effort associations store precedence, concurrence. They can also store
2
+ ## task breakdowns, but there is a more efficient nested-set data structure directly on the work_effort
3
+ ## for this purpose, since it is common to reconstruct large work breakdown structures
4
+ ## with important read performance requirements
5
+
6
+ class WorkEffortAssociation < ActiveRecord::Base
7
+ attr_protected :created_at, :updated_at
8
+
9
+ belongs_to :work_effort_association_type
10
+
11
+ belongs_to :work_effort_from, :class_name => "WorkEffort", :foreign_key => "work_effort_id_from"
12
+ belongs_to :work_effort_to, :class_name => "WorkEffort", :foreign_key => "work_effort_id_to"
13
+ belongs_to :from_role, :class_name => "RoleType", :foreign_key => "role_type_id_from"
14
+ belongs_to :to_role, :class_name => "RoleType", :foreign_key => "role_type_id_to"
15
+
16
+ end
@@ -0,0 +1,14 @@
1
+ ## Easy to confuse this with work_effort_type_associations, which are for associations between types of
2
+ ## work efforts used for standards or templates. This is the type used when the actual association is created.
3
+ ## It is still used to store things like dependency and breakdown, but this is the type data and
4
+ ## work_effort_type_associations is used to store valid combinations of work effort types.
5
+
6
+ class WorkEffortAssociationType < ActiveRecord::Base
7
+ attr_protected :created_at, :updated_at
8
+
9
+ acts_as_nested_set
10
+ include ErpTechSvcs::Utils::DefaultNestedSetMethods
11
+
12
+ has_many :work_effort_associations
13
+
14
+ end
@@ -0,0 +1,6 @@
1
+ class WorkEffortDeliverableProduced < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ belongs_to :work_effort
5
+ belongs_to :deliverable
6
+ end
@@ -0,0 +1,10 @@
1
+ ##********************************************************************************************
2
+ ## Work Effort Assignments - what is necessary to complete this work effort - Fixed Assets
3
+ ## like equipment / tools
4
+ ##********************************************************************************************
5
+ class WorkEffortFixedAssetAssignment < ActiveRecord::Base
6
+ attr_protected :created_at, :updated_at
7
+
8
+ belongs_to :work_effort
9
+ belongs_to :fixed_asset
10
+ end
@@ -0,0 +1,6 @@
1
+ class WorkEffortFixedAssetServiced < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ belongs_to :work_effort
5
+ belongs_to :fixed_asset
6
+ end
@@ -0,0 +1,7 @@
1
+ class WorkEffortFixedAssetStandard < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ belongs_to :work_effort
5
+ belongs_to :fixed_asset_type
6
+ belongs_to :estimated_cost, :class_name => 'Money', :foreign_key => 'estimated_cost_money_id'
7
+ end
@@ -0,0 +1,7 @@
1
+ class WorkEffortGoodStandard < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ belongs_to :work_effort
5
+ belongs_to :good_type
6
+ belongs_to :estimated_cost, :class_name => 'Money', :foreign_key => 'estimated_cost_money_id'
7
+ end
@@ -0,0 +1,10 @@
1
+ ##********************************************************************************************
2
+ ## Work Effort Assignments - what is necessary to complete this work effort - Inventory
3
+ ##********************************************************************************************
4
+ class WorkEffortInventoryAssignment < ActiveRecord::Base
5
+ attr_protected :created_at, :updated_at
6
+
7
+ belongs_to :work_effort
8
+ belongs_to :inventory_entry
9
+
10
+ end
@@ -0,0 +1,7 @@
1
+ class WorkEffortInventoryProduced < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ belongs_to :work_effort
5
+ belongs_to :inventory_entry
6
+
7
+ end
@@ -0,0 +1,12 @@
1
+ ## Work Effort Assignments - what is necessary to complete this work effort
2
+
3
+ ## work_effort_party_assignments
4
+ ## this is straight entity_party_role pattern with from and thru dates, but we are keeping
5
+ ## the DMRB name for this entity.
6
+ class WorkEffortPartyAssignment < ActiveRecord::Base
7
+ attr_protected :created_at, :updated_at
8
+
9
+ belongs_to :work_effort
10
+ belongs_to :party
11
+ belongs_to :role_type
12
+ end
@@ -0,0 +1,11 @@
1
+ # work_effort purpose types - is this work_effort to produce something or repair something?
2
+
3
+ class WorkEffortPurposeType < ActiveRecord::Base
4
+ attr_protected :created_at, :updated_at
5
+
6
+ acts_as_nested_set
7
+ include ErpTechSvcs::Utils::DefaultNestedSetMethods
8
+
9
+ has_many :work_efforts
10
+
11
+ end
@@ -0,0 +1,7 @@
1
+ class WorkEffortSkillStandard < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ belongs_to :work_effort
5
+ belongs_to :skill_type
6
+ belongs_to :estimated_cost, :class_name => 'Money', :foreign_key => 'estimated_cost_money_id'
7
+ end
@@ -0,0 +1,9 @@
1
+ class WorkEffortType < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ acts_as_nested_set
5
+ include ErpTechSvcs::Utils::DefaultNestedSetMethods
6
+
7
+ has_many :work_efforts
8
+
9
+ end
@@ -0,0 +1,10 @@
1
+ ## work_effort type associations - standard for associations between work_efforts
2
+
3
+ class WorkEffortTypeAssociation < ActiveRecord::Base
4
+ # attr_accessible :title, :body
5
+ attr_protected :created_at, :updated_at
6
+
7
+ belongs_to :work_effort_from_type, :class_name => "WorkEffort", :foreign_key => "work_effort_type_id_from"
8
+ belongs_to :work_effort_to_type, :class_name => "WorkEffort", :foreign_key => "work_effort_type_id_to"
9
+
10
+ end
@@ -0,0 +1,5 @@
1
+ class WorkOrderItem < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+
4
+ acts_as_order_line_item
5
+ end
@@ -0,0 +1,11 @@
1
+ ## This entity tracks the relationship between the
2
+ ## work_order (order_line_item) and the work_effort by which it is fulfilled.
3
+
4
+ class WorkOrderItemFulfillment < ActiveRecord::Base
5
+ # attr_accessible :title, :body
6
+ attr_protected :created_at, :updated_at
7
+
8
+ belongs_to :work_effort
9
+ belongs_to :order_line_item
10
+
11
+ end
@@ -0,0 +1,3 @@
1
+ class WorkRequirementFulfillment < ActiveRecord::Base
2
+ attr_protected :created_at, :updated_at
3
+ end
@@ -1,2 +1,22 @@
1
1
  ErpWorkEffort::Engine.routes.draw do
2
+
3
+ namespace :erp_app do
4
+ namespace :organizer do
5
+ namespace :tasks do
6
+
7
+ resources :work_efforts do
8
+
9
+ collection do
10
+ get :role_types
11
+ get :work_effort_types
12
+ get :task_count
13
+ end
14
+
15
+
16
+ end
17
+
18
+ end #tasks
19
+ end #organizer
20
+ end #erp_app
21
+
2
22
  end
@@ -0,0 +1,14 @@
1
+ class CreateTasksOrganizerApplication
2
+ def self.up
3
+ OrganizerApplication.create(
4
+ :description => 'Tasks',
5
+ :icon => 'icon-note_pinned',
6
+ :javascript_class_name => 'Compass.ErpApp.Organizer.Applications.Tasks.Base',
7
+ :internal_identifier => 'tasks'
8
+ )
9
+ end
10
+
11
+ def self.down
12
+ OrganizerApplication.destroy_all(:conditions => ['internal_identifier = ?','tasks'])
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ class AddTaskWorkEffortTypes
2
+
3
+ def self.up
4
+ WorkEffortType.create(description: 'Ticket', internal_identifier: 'ticket')
5
+ end
6
+
7
+ def self.down
8
+ WorkEffortType.find_by_internal_identifier('ticket').destroy
9
+ end
10
+
11
+ end
@@ -0,0 +1,21 @@
1
+ class AddTaskStatuses
2
+
3
+ def self.up
4
+ if TrackedStatusType.find_by_internal_identifier('pending').nil?
5
+ TrackedStatusType.create(description: 'Pending', internal_identifier: 'pending')
6
+ end
7
+
8
+ if TrackedStatusType.find_by_internal_identifier('in_progress').nil?
9
+ TrackedStatusType.create(description: 'In Progress', internal_identifier: 'in_progress')
10
+ end
11
+
12
+ if TrackedStatusType.find_by_internal_identifier('complete').nil?
13
+ TrackedStatusType.create(description: 'Complete', internal_identifier: 'complete')
14
+ end
15
+ end
16
+
17
+ def self.down
18
+ #remove data here
19
+ end
20
+
21
+ end
@@ -1,10 +1,191 @@
1
1
  class BaseWorkEfforts < ActiveRecord::Migration
2
2
 
3
- def self.up
3
+ def self.up
4
+
5
+ ##********************************************************************************************
6
+ ## Human resource (Party) skill types
7
+ ##********************************************************************************************
8
+ unless table_exists?(:skill_types)
9
+ create_table :skill_types do |t|
10
+ t.integer :parent_id
11
+ t.integer :lft
12
+ t.integer :rgt
13
+
14
+ #custom columns go here
15
+ t.string :description
16
+ t.string :comments
17
+ t.string :internal_identifier
18
+ t.string :external_identifier
19
+ t.string :external_id_source
20
+
21
+ t.timestamps
22
+ end
23
+ end
24
+
25
+ ## party skills
26
+ unless table_exists?(:party_skills)
27
+ create_table :party_skills do |t|
28
+ t.integer :party_id
29
+ t.integer :skill_type_id
30
+
31
+ t.timestamps
32
+ end
33
+ add_index :party_skills, [:party_id, :skill_type_id], :name => "party_skills_idx"
34
+ end
35
+
36
+ ##********************************************************************************************
37
+ ## Types of goods required as a standard for the completion of work efforts. This is different from
38
+ ## inventory_items because it is not for planning. It is only for noting the type of good
39
+ ## that is required to perform the work effort. - See DMRB v1, pp 223-224
40
+ ##********************************************************************************************
41
+ unless table_exists?(:good_types)
42
+ create_table :good_types do |t|
43
+ #these columns are required to support the behavior of the plugin 'awesome_nested_set'
44
+ t.integer :parent_id
45
+ t.integer :lft
46
+ t.integer :rgt
47
+
48
+ #custom columns go here
49
+ t.string :description
50
+ t.string :comments
51
+ t.string :internal_identifier
52
+ t.string :external_identifier
53
+ t.string :external_id_source
54
+
55
+ t.timestamps
56
+ end
57
+ end
58
+
59
+ ##********************************************************************************************
60
+ ## Deliverables - outputs from work efforts
61
+ ##********************************************************************************************
62
+ unless table_exists?(:deliverables)
63
+ create_table :deliverables do |t|
64
+
65
+ t.string :description
66
+ t.string :comments
67
+ t.string :internal_identifier
68
+ t.string :external_identifier
69
+ t.string :external_id_source
70
+
71
+ #polymorphic columns
72
+ t.string :deliverable_record_type
73
+ t.integer :deliverable_record_id
74
+
75
+ t.timestamps
76
+ end
77
+ end
4
78
 
5
- ## work_efforts
79
+ # deliverable types
80
+ unless table_exists?(:deliverable_types)
81
+ create_table :deliverable_types do |t|
82
+ #these columns are required to support the behavior of the plugin 'awesome_nested_set'
83
+ t.integer :parent_id
84
+ t.integer :lft
85
+ t.integer :rgt
86
+
87
+ #custom columns go here
88
+ t.string :description
89
+ t.string :comments
90
+ t.string :internal_identifier
91
+ t.string :external_identifier
92
+ t.string :external_id_source
93
+
94
+ t.timestamps
95
+ end
96
+ end
97
+
98
+ ##********************************************************************************************
99
+ ## Requirements
100
+ ##********************************************************************************************
101
+ unless table_exists?(:requirements)
102
+ create_table :requirements do |t|
103
+
104
+ #better nested set columns
105
+ t.integer :parent_id
106
+ t.integer :lft
107
+ t.integer :rgt
108
+
109
+ t.string :description
110
+ t.string :type
111
+ t.integer :projected_completion_time
112
+ t.integer :estimated_budget_money_id
113
+
114
+ #requirement type
115
+ t.integer :requirement_type_id
116
+ #polymorphic columns
117
+ t.integer :requirement_record_id
118
+ t.string :requirement_record_type
119
+
120
+ #These columns represent optional relationships to the items used by and
121
+ #produced via fulfillment of the requirement
122
+ #TODO if we do separate requirement from work requirement, some of these relationships
123
+ #would get moved to work_requirement or another subtype. See DMRB V1 p187
124
+ t.integer :fixed_asset_id
125
+ t.integer :product_id
126
+ t.integer :deliverable_id
127
+
128
+ t.timestamps
129
+ end
130
+ end
131
+
132
+ # requirement types. We use polymorphic subtypes
133
+ unless table_exists?(:requirement_types)
134
+ create_table :requirement_types do |t|
135
+ #these columns are required to support the behavior of the plugin 'awesome_nested_set'
136
+ t.integer :parent_id
137
+ t.integer :lft
138
+ t.integer :rgt
139
+
140
+ #custom columns go here
141
+ t.string :description
142
+ t.string :comments
143
+ t.string :internal_identifier
144
+ t.string :external_identifier
145
+ t.string :external_id_source
146
+
147
+ t.timestamps
148
+ end
149
+ end
150
+
151
+ # Create requirement_party_roles
152
+ unless table_exists?(:requirement_party_roles)
153
+ create_table :requirement_party_roles do |t|
154
+ t.string :description
155
+
156
+ t.integer :requirement_id
157
+ t.integer :party_id
158
+ t.integer :role_type_id
159
+
160
+ t.string :external_identifier
161
+ t.string :external_id_source
162
+
163
+ t.datetime :valid_from
164
+ t.datetime :valid_to
165
+
166
+ t.timestamps
167
+ end
168
+ add_index :requirement_party_roles, [:requirement_id, :party_id, :role_type_id], :name => "requirement_party_roles_idx"
169
+ end
170
+
171
+ ##********************************************************************************************
172
+ ## Base Work Effort data structures
173
+ ##********************************************************************************************
6
174
  unless table_exists?(:work_efforts)
7
175
  create_table :work_efforts do |t|
176
+ #better nested set columns
177
+ t.integer :parent_id
178
+ t.integer :lft
179
+ t.integer :rgt
180
+
181
+ #foreign keys
182
+ t.integer :facility_id
183
+ t.integer :projected_cost_money_id
184
+ t.integer :actual_cost_money_id
185
+ t.references :fixed_asset
186
+ t.references :work_effort_purpose_type
187
+ t.references :work_effort_type
188
+
8
189
  t.string :description
9
190
  t.string :type
10
191
  t.datetime :started_at
@@ -12,145 +193,337 @@ class BaseWorkEfforts < ActiveRecord::Migration
12
193
  t.integer :projected_completion_time
13
194
  t.integer :actual_completion_time
14
195
 
15
- t.timestamps
16
-
17
196
  #polymorphic columns
18
- t.integer :facility_id
19
- t.string :facility_type
20
197
  t.integer :work_effort_record_id
21
198
  t.string :work_effort_record_type
22
199
 
200
+ t.timestamps
201
+ end
202
+ add_index :work_efforts, [:work_effort_record_id, :work_effort_record_type], :name => "work_effort_record_id_type_idx"
203
+ add_index :work_efforts, :fixed_asset_id
204
+ add_index :work_efforts, :finished_at
205
+ end
206
+
207
+ unless table_exists?(:associated_work_efforts)
208
+ create_table :associated_work_efforts do |t|
23
209
  #foreign keys
24
- t.integer :projected_cost_id
25
- t.integer :actual_cost_id
210
+ t.integer :work_effort_id
26
211
 
27
- #better nested set columns
212
+ #polymorphic columns
213
+ t.integer :associated_record_id
214
+ t.string :associated_record_type
215
+ end
216
+ add_index :associated_work_efforts, [:associated_record_id, :associated_record_type], :name => "associated_record_id_type_idx"
217
+ add_index :associated_work_efforts, :work_effort_id
218
+ end
219
+
220
+ ## work_effort types
221
+ unless table_exists?(:work_effort_types)
222
+ create_table :work_effort_types do |t|
223
+ #these columns are required to support the behavior of the plugin 'awesome_nested_set'
28
224
  t.integer :parent_id
29
225
  t.integer :lft
30
226
  t.integer :rgt
31
- end
32
-
33
- add_index :work_efforts, [:work_effort_record_id, :work_effort_record_type], :name => "work_effort_record_id_type"
34
- add_index :work_efforts, [:facility_type, :facility_id], :name => "facility"
35
- add_index :work_efforts, :finished_at
36
- end
37
227
 
38
- ## work_requirements
39
- unless table_exists?(:work_requirements)
40
- create_table :work_requirements do |t|
228
+ #custom columns go here
41
229
  t.string :description
42
- t.string :type
43
- t.integer :projected_completion_time
230
+ t.string :comments
231
+ t.string :internal_identifier
232
+ t.string :external_identifier
233
+ t.string :external_id_source
234
+
44
235
  t.timestamps
236
+ end
237
+ end
45
238
 
46
- #polymorphic columns
47
- t.integer :work_requirement_record_id
48
- t.string :work_requirement_record_type
49
- t.integer :facility_id
50
- t.string :facility_type
239
+ # work_effort purpose types - is this work_effort to produce something or repair something?
240
+ unless table_exists?(:work_effort_purpose_types)
241
+ create_table :work_effort_purpose_types do |t|
242
+ #these columns are required to support the behavior of the plugin 'awesome_nested_set'
243
+ t.integer :parent_id
244
+ t.integer :lft
245
+ t.integer :rgt
51
246
 
52
- # foreign keys
53
- t.integer :cost_id
247
+ #custom columns go here
248
+ t.string :description
249
+ t.string :comments
250
+ t.string :internal_identifier
251
+ t.string :external_identifier
252
+ t.string :external_id_source
54
253
 
55
- #better nested set columns
254
+ t.timestamps
255
+ end
256
+ end
257
+
258
+ ## Easy to confuse this with work_effort_type_associations, which are for associations between types of
259
+ ## work efforts used for standards or templates. This is the type used when the actual association is created.
260
+ ## It is still used to store things like dependency and breakdown, but this is the type data and
261
+ ## work_effort_type_associations is used to store valid combinations of work effort types.
262
+ unless table_exists?(:work_effort_association_types)
263
+ create_table :work_effort_association_types do |t|
56
264
  t.integer :parent_id
57
265
  t.integer :lft
58
266
  t.integer :rgt
267
+
268
+ #custom columns go here
269
+ t.integer :valid_from_role_type_id
270
+ t.integer :valid_to_role_type_id
271
+ t.string :name
272
+ t.string :description
273
+
274
+ t.string :internal_identifier
275
+ t.string :external_identifier
276
+ t.string :external_id_source
277
+
278
+ t.timestamps
59
279
  end
280
+ add_index :work_effort_association_types, :valid_from_role_type_id
281
+ add_index :work_effort_association_types, :valid_to_role_type_id
60
282
  end
61
-
62
- ## work_requirement_work_effort_status_types
63
- unless table_exists?(:work_requirement_work_effort_status_types)
64
- create_table :work_requirement_work_effort_status_types do |t|
65
- t.timestamps
66
283
 
67
- #foreign keys
68
- t.integer :work_requirement_id
69
- t.integer :work_effort_status_type_id
70
- t.boolean :is_initial_status
284
+ ## Work effort associations store precedence, concurrence. They can also store
285
+ ## task breakdowns, but there is a more efficient nested-set data structure directly on the work_effort
286
+ ## for this purpose, since it is common to reconstruct large work breakdown structures
287
+ ## with important read performance requirements
288
+ unless table_exists?(:work_effort_associations)
289
+ create_table :work_effort_associations do |t|
290
+ #foreign key references
291
+ t.references :work_effort_association_type
292
+
293
+ t.string :description
294
+ t.integer :work_effort_id_from
295
+ t.integer :work_effort_id_to
296
+ t.integer :role_type_id_from
297
+ t.integer :role_type_id_to
298
+ t.integer :relationship_type_id
299
+ t.datetime :effective_from
300
+ t.datetime :effective_thru
301
+
302
+ t.timestamps
71
303
  end
304
+ add_index :work_effort_associations, :relationship_type_id
72
305
  end
73
306
 
74
- ## work_effort_statuses
75
- unless table_exists?(:work_effort_statuses)
76
- create_table :work_effort_statuses do |t|
77
- t.datetime :started_at
78
- t.datetime :finished_at
79
- t.integer :work_effort_id
80
- t.integer :work_effort_status_type_id
307
+ ##********************************************************************************************
308
+ ## Work Effort Generation (DMRB V1 pp 194-195)
309
+ ##********************************************************************************************
310
+ ## The next three entities represent the relationships between three key entities
311
+ ## order_line_item <==> requirement <==> work_effort (and work_effort <==> order_line_item)
312
+
313
+ ## This entity tracks the relationship between the
314
+ ## work_order (order_line_item) and the work_effort by which it is fulfilled.
315
+ unless table_exists?(:work_order_item_fulfillments)
316
+ create_table :work_order_item_fulfillments do |t|
317
+ #foreign key references
318
+ t.references :work_effort
319
+ t.references :order_line_item
320
+
321
+ t.string :description
81
322
 
82
323
  t.timestamps
83
324
  end
325
+ add_index :work_order_item_fulfillments, [:work_effort_id, :order_line_item_id], :name => "work_order_item_fulfillments_idx"
326
+ end
84
327
 
85
- add_index :work_effort_statuses, :work_effort_status_type_id
86
- add_index :work_effort_statuses, :work_effort_id
328
+ unless table_exists?(:work_order_items)
329
+ create_table :work_order_items do |t|
330
+ # WorkOrderItem acts_as_order_line_item & polymorphic relationship is on order_line_item so this table only has timestamps
331
+ t.timestamps
332
+ end
87
333
  end
88
334
 
89
- ## work_effort_status_types
90
- unless table_exists?(:work_effort_status_types)
91
- create_table :work_effort_status_types do |t|
92
- t.string :internal_identifier
93
- t.string :description
94
- t.integer :next_status_id
95
- t.integer :previous_status_id
335
+ ## relationship to track the relationship between order_line_items and the requirement to fulfill them
336
+ unless table_exists?(:order_requirement_commitments)
337
+ create_table :order_requirement_commitments do |t|
338
+ #foreign key references
339
+ t.references :order_line_item
340
+ t.references :requirement
341
+
342
+ t.string :description
343
+ t.integer :quantity
96
344
 
97
345
  t.timestamps
98
346
  end
347
+ add_index :order_requirement_commitments, [:order_line_item_id, :requirement_id], :name => "order_item_req_fulfillment_idx"
348
+ end
349
+
350
+ ## relationship to track the relationship between requirements and the work_efforts to fulfill them
351
+ unless table_exists?(:work_requirement_fulfillment)
352
+ create_table :work_requirement_fulfillment do |t|
353
+ t.string :description
354
+
355
+ t.integer :work_effort_id
356
+ t.integer :requirement_id
99
357
 
100
- add_index :work_effort_status_types, :internal_identifier
101
- add_index :work_effort_status_types, :description
358
+ t.timestamps
359
+ end
360
+ add_index :work_requirement_fulfillment, [:work_effort_id, :requirement_id], :name => "work_order_req_fulfillment_idx"
102
361
  end
103
362
 
104
- ## work_effort_assignments
105
- unless table_exists?(:work_effort_assignments)
106
- create_table :work_effort_assignments do |t|
107
- #foreign keys
363
+ ##********************************************************************************************
364
+ ## Work Effort Assignments - what is necessary to complete this work effort
365
+ ##********************************************************************************************
366
+ ## work_effort_party_assignments
367
+ ## this is straight entity_party_role pattern with from and thru dates, but we are keeping
368
+ ## the DMRB name for this entity.
369
+ unless table_exists?(:work_effort_party_assignments)
370
+ create_table :work_effort_party_assignments do |t|
371
+ #foreign key references
108
372
  t.references :work_effort
373
+ t.references :role_type
374
+ t.references :party
109
375
 
110
- t.datetime :assigned_at
111
376
  t.datetime :assigned_from
112
377
  t.datetime :assigned_thru
113
- t.datetime :unassigned_at
114
378
 
115
- #Polymorphic Columns
116
- t.integer :assigned_to_id
117
- t.string :assigned_to_type
118
- t.integer :assigned_by_id
119
- t.string :assigned_by_type
379
+ t.text :comments
120
380
 
121
381
  t.timestamps
122
382
  end
383
+ add_index :work_effort_party_assignments, :assigned_from
384
+ add_index :work_effort_party_assignments, :assigned_thru
385
+ add_index :work_effort_party_assignments, :work_effort_id
386
+ add_index :work_effort_party_assignments, :party_id
387
+ end
388
+
389
+ unless table_exists?(:work_effort_inventory_assignments)
390
+ create_table :work_effort_inventory_assignments do |t|
391
+ #foreign key references
392
+ t.references :work_effort
393
+ t.references :inventory_entry
123
394
 
124
- add_index :work_effort_assignments, [:assigned_to_id, :assigned_to_type], :name => "assigned_to"
125
- add_index :work_effort_assignments, :assigned_from
126
- add_index :work_effort_assignments, :assigned_thru
127
- add_index :work_effort_assignments, :work_effort_id
395
+ t.timestamps
396
+ end
397
+ add_index :work_effort_inventory_assignments, [:work_effort_id, :inventory_entry_id], :name => "work_effort_inv_assignment_idx"
128
398
  end
129
399
 
130
- ## valid_work_assignments
131
- unless table_exists?(:valid_work_assignments)
132
- create_table :valid_work_assignments do |t|
133
- t.integer :role_type_id
134
- t.integer :work_requirement_id
400
+ unless table_exists?(:work_effort_fixed_asset_assignments)
401
+ create_table :work_effort_fixed_asset_assignments do |t|
402
+ #foreign key references
403
+ t.references :work_effort
404
+ t.references :fixed_asset
135
405
 
136
406
  t.timestamps
137
407
  end
408
+ add_index :work_effort_fixed_asset_assignments, [:work_effort_id, :fixed_asset_id], :name => "work_effort_fixed_asset_assign_idx"
409
+ end
410
+
411
+ ##********************************************************************************************
412
+ ## Work effort type standards
413
+ ##********************************************************************************************
414
+
415
+ ## work_effort type associations - standard for associations between work_efforts
416
+ unless table_exists?(:work_effort_type_associations)
417
+ create_table :work_effort_type_associations do |t|
418
+
419
+ #this type field is NOT REDUNDANT. It is here to distinguish between work breakdown type associations and
420
+ #dependency type associations
421
+ t.integer :work_effort_type_assoc_type
138
422
 
423
+ #the two work effort types involved in the association
424
+ t.integer :work_effort_type_id_from
425
+ t.integer :work_effort_type_id_to
426
+
427
+ #custom columns go here
428
+ t.string :description
429
+ t.string :comments
430
+ t.string :internal_identifier
431
+ t.string :external_identifier
432
+ t.string :external_id_source
433
+
434
+ t.timestamps
435
+ end
139
436
  end
140
437
 
141
- ## valid_work_assignment_attributes
142
- unless table_exists?(:valid_work_assignment_attributes)
143
- create_table :valid_work_assignment_attributes do |t|
144
- t.integer :valid_work_assignment_id
145
- t.string :name
146
- t.string :type
147
- t.string :value
438
+ unless table_exists?(:work_effort_fixed_asset_standards)
439
+ create_table :work_effort_fixed_asset_standards do |t|
440
+ #foreign key references
441
+ t.references :work_effort
442
+ t.references :fixed_asset_type
443
+
444
+ t.decimal :estimated_quantity
445
+ t.decimal :estimated_duration
446
+ t.integer :estimated_cost_money_id
447
+
448
+ t.timestamps
449
+ end
450
+ add_index :work_effort_fixed_asset_standards, :work_effort_id
451
+ add_index :work_effort_fixed_asset_standards, :fixed_asset_type_id
452
+ end
453
+
454
+ unless table_exists?(:work_effort_skill_standards)
455
+ create_table :work_effort_skill_standards do |t|
456
+ #foreign key references
457
+ t.references :work_effort
458
+ t.references :skill_type
459
+
460
+ t.decimal :estimated_num_people
461
+ t.decimal :estimated_duration
462
+ t.integer :estimated_cost_money_id
148
463
 
149
464
  t.timestamps
150
465
  end
466
+ add_index :work_effort_skill_standards, :work_effort_id
467
+ add_index :work_effort_skill_standards, :skill_type_id
151
468
  end
152
469
 
153
- ## party_resource_availabilities
470
+ unless table_exists?(:work_effort_good_standards)
471
+ create_table :work_effort_good_standards do |t|
472
+ #foreign key references
473
+ t.references :work_effort
474
+ t.references :good_type
475
+
476
+ t.decimal :estimated_quantity
477
+ t.integer :estimated_cost_money_id
478
+
479
+ t.timestamps
480
+ end
481
+ add_index :work_effort_good_standards, :work_effort_id
482
+ end
483
+
484
+ ##********************************************************************************************
485
+ ## Work Effort Results
486
+ ##********************************************************************************************
487
+ unless table_exists?(:work_effort_inventory_produced)
488
+ create_table :work_effort_inventory_produced do |t|
489
+ #foreign key references
490
+ t.references :work_effort
491
+ t.references :inventory_entry
492
+
493
+ t.timestamps
494
+ end
495
+ add_index :work_effort_inventory_produced, :work_effort_id
496
+ add_index :work_effort_inventory_produced, :inventory_entry_id
497
+ end
498
+
499
+ unless table_exists?(:work_effort_deliverable_produced)
500
+ create_table :work_effort_deliverable_produced do |t|
501
+ #foreign key references
502
+ t.references :work_effort
503
+ t.references :deliverable
504
+
505
+ t.timestamps
506
+ end
507
+ add_index :work_effort_deliverable_produced, :work_effort_id
508
+ add_index :work_effort_deliverable_produced, :deliverable_id
509
+ end
510
+
511
+ unless table_exists?(:work_effort_fixed_asset_serviced)
512
+ create_table :work_effort_fixed_asset_serviced do |t|
513
+ #foreign key references
514
+ t.references :work_effort
515
+ t.references :fixed_asset
516
+
517
+ t.timestamps
518
+ end
519
+ add_index :work_effort_fixed_asset_serviced, :work_effort_id
520
+ add_index :work_effort_fixed_asset_serviced, :fixed_asset_id
521
+ end
522
+
523
+ ##********************************************************************************************
524
+ ## TODO - delete these?
525
+ ## Party Resource Availability - NOT IN DMRB, but didn't want to delete without review
526
+ ##********************************************************************************************
154
527
  unless table_exists?(:party_resource_availabilities)
155
528
  create_table :party_resource_availabilities do |t|
156
529
  t.datetime :from_date
@@ -160,7 +533,6 @@ class BaseWorkEfforts < ActiveRecord::Migration
160
533
 
161
534
  t.timestamps
162
535
  end
163
-
164
536
  add_index :party_resource_availabilities, :from_date
165
537
  add_index :party_resource_availabilities, :to_date
166
538
  add_index :party_resource_availabilities, :pra_type_id
@@ -174,37 +546,68 @@ class BaseWorkEfforts < ActiveRecord::Migration
174
546
 
175
547
  t.timestamps
176
548
  end
177
-
178
549
  add_index :party_resource_availability_types, :internal_identifier
179
550
  add_index :party_resource_availability_types, :description
180
551
  end
181
552
 
182
- ## costs
183
- unless table_exists?(:costs)
184
- create_table :costs do |t|
185
- t.integer :money_id
186
- t.timestamps
187
- end
188
- end
189
-
190
553
  end
191
554
 
192
555
  def self.down
193
- # Drop all tables, including those that were originally created then deleted
194
556
  [
195
- # Old tables deleted and no longer used
196
- :work_requirement_assignabilities,
197
- # Currently used tables
198
- :category_classifications, :categories, :work_requirement_assignability_attributes,
199
- :valid_work_assignments, :work_effort_assignments, :work_effort_status_types,
200
- :work_effort_statuses, :work_requirement_work_effort_status_types,
201
- :work_requirements, :work_efforts, :party_resource_availabilities, :party_resource_availability_types,
202
- :costs
557
+ :good_types,
558
+
559
+ #hr-skills
560
+ :skill_types,
561
+ :party_skills,
562
+
563
+ #deliverables
564
+ :deliverables,
565
+ :deliverable_types,
566
+
567
+ #requirements
568
+ :requirements,
569
+ :requirement_types,
570
+ :requirement_party_roles,
571
+
572
+ #work effort data structures
573
+ :work_efforts,
574
+ :work_effort_types,
575
+ :work_effort_purpose_types,
576
+ :work_effort_association_types,
577
+ :work_effort_associations,
578
+ :associated_work_efforts,
579
+
580
+ #work_effort generation
581
+ :work_order_item_fulfillment,
582
+ :work_order_items,
583
+ :order_requirement_commitments,
584
+ :work_requirement_fulfillment,
585
+
586
+ #assignments
587
+ :work_effort_party_assignments,
588
+ :work_effort_inventory_assignments,
589
+ :work_effort_fixed_asset_assignments,
590
+
591
+ ##standards
592
+ :work_effort_type_associations,
593
+ :work_effort_fixed_asset_standards,
594
+ :work_effort_skill_standards,
595
+ :work_effort_good_standards,
596
+
597
+ ##results
598
+ :work_effort_inventory_produced,
599
+ :work_effort_deliverable_produced,
600
+ :work_effort_fixed_asset_serviced,
601
+
602
+ ##obsolete??
603
+ :party_resource_availabilities,
604
+ :party_resource_availability_types
605
+
203
606
  ].each do |tbl|
204
607
  if table_exists?(tbl)
205
608
  drop_table tbl
206
609
  end
207
610
  end
208
-
209
611
  end
612
+
210
613
  end