erp_work_effort 4.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v1/projects_controller.rb +25 -0
  3. data/app/controllers/api/v1/time_entries_controller.rb +313 -0
  4. data/app/controllers/api/v1/transportation_routes_controller.rb +9 -0
  5. data/app/controllers/api/v1/work_effort_associations_controller.rb +102 -0
  6. data/app/controllers/api/v1/work_effort_party_assignments_controller.rb +136 -0
  7. data/app/controllers/api/v1/work_effort_types_controller.rb +120 -0
  8. data/app/controllers/api/v1/work_efforts_controller.rb +284 -0
  9. data/app/models/associated_transportation_route.rb +8 -5
  10. data/app/models/cal_evt_party_role.rb +9 -0
  11. data/app/models/calendar_event.rb +46 -0
  12. data/app/models/calendar_invite.rb +10 -0
  13. data/app/models/candidate_submission.rb +37 -0
  14. data/app/models/experience.rb +11 -0
  15. data/app/models/extensions/biz_txn_events.rb +35 -0
  16. data/app/models/extensions/finacial_txns.rb +27 -0
  17. data/app/models/extensions/order_line_item.rb +12 -0
  18. data/app/models/extensions/party.rb +204 -0
  19. data/app/models/party_skill.rb +2 -0
  20. data/app/models/pay_period.rb +59 -0
  21. data/app/models/position.rb +8 -0
  22. data/app/models/position_fulfillment.rb +8 -0
  23. data/app/models/position_type.rb +12 -0
  24. data/app/models/project.rb +59 -0
  25. data/app/models/requirement.rb +2 -0
  26. data/app/models/resume.rb +11 -0
  27. data/app/models/shift.rb +22 -0
  28. data/app/models/skill_type.rb +8 -0
  29. data/app/models/staffing_position.rb +9 -0
  30. data/app/models/time_entry.rb +260 -0
  31. data/app/models/timesheet.rb +194 -0
  32. data/app/models/timesheet_party_role.rb +21 -0
  33. data/app/models/transportation_route.rb +103 -18
  34. data/app/models/transportation_route_segment.rb +44 -0
  35. data/app/models/transportation_route_stop.rb +19 -0
  36. data/app/models/wc_code.rb +7 -0
  37. data/app/models/work_effort.rb +512 -30
  38. data/app/models/work_effort_association.rb +7 -0
  39. data/app/models/work_effort_association_type.rb +5 -0
  40. data/app/models/work_effort_biz_txn_event.rb +22 -0
  41. data/app/models/work_effort_party_assignment.rb +140 -3
  42. data/app/models/work_effort_type.rb +5 -0
  43. data/config/routes.rb +54 -11
  44. data/db/data_migrations/20150709053041_add_skill_types.rb +27 -0
  45. data/db/data_migrations/20150709055922_add_position_types.rb +27 -0
  46. data/db/data_migrations/20150711220000_add_task_tracked_statuses.rb +25 -0
  47. data/db/data_migrations/20150712081804_add_work_effort_types.rb +23 -0
  48. data/db/data_migrations/20150718052204_add_project_tracked_statuses.rb +24 -0
  49. data/db/data_migrations/20150718054404_add_project_party_role_types.rb +14 -0
  50. data/db/data_migrations/20150812150320_add_work_effort_dependency_types.rb +35 -0
  51. data/db/migrate/20100220000000_base_work_efforts.rb +310 -89
  52. data/db/migrate/20150227174108_create_staffing_positions.rb +11 -0
  53. data/db/migrate/20150305194158_create_wc_codes.rb +24 -0
  54. data/db/migrate/20150313134411_create_shifts.rb +28 -0
  55. data/db/migrate/20150325195749_create_candidate_submissions.rb +22 -0
  56. data/db/migrate/20150327115910_resumes.rb +15 -0
  57. data/db/migrate/20150401060938_add_resume_parser_statuses.rb +14 -0
  58. data/db/migrate/20150607181734_create_calendar_events.rb +24 -0
  59. data/db/migrate/20150616174228_create_cal_evt_party_roles.rb +19 -0
  60. data/db/migrate/20150707164520_create_calendar_invites.rb +21 -0
  61. data/db/migrate/20150718052404_create_projects.rb +20 -0
  62. data/db/migrate/20150812191812_update_work_efforts.rb +59 -0
  63. data/db/migrate/20150824152639_add_sequence_to_work_effort.rb +9 -0
  64. data/db/migrate/20150830133951_add_work_effort_biz_txn_events.rb +21 -0
  65. data/db/migrate/20150908200612_update_time_entries.rb +70 -0
  66. data/db/migrate/20151115180427_add_defaults_for_work_effort.rb +36 -0
  67. data/db/migrate/20151218195330_update_transportation_routes.rb +72 -0
  68. data/db/migrate/20160310163052_add_created_by_updated_by_to_erp_work_effort.rb +63 -0
  69. data/db/migrate/20160418115227_add_created_by_updated_by_to_skill_type.rb +34 -0
  70. data/lib/erp_work_effort.rb +3 -0
  71. data/lib/erp_work_effort/config.rb +33 -0
  72. data/lib/erp_work_effort/engine.rb +0 -4
  73. data/lib/erp_work_effort/services/unit_converter.rb +284 -0
  74. data/lib/erp_work_effort/version.rb +1 -1
  75. data/lib/tasks/populate_model_data.rake +19 -0
  76. data/lib/tasks/resume_parser.rake +18 -0
  77. metadata +80 -16
  78. data/app/controllers/erp_work_effort/erp_app/organizer/tasks/base_controller.rb +0 -13
  79. data/app/controllers/erp_work_effort/erp_app/organizer/tasks/work_efforts_controller.rb +0 -128
  80. data/db/data_migrations/20131213151309_create_tasks_organizer_application.rb +0 -14
  81. data/db/migrate/20130829153419_base_routes.rb +0 -93
  82. data/db/migrate/20131213140617_add_work_effort_role_assignments.rb +0 -16
  83. data/db/migrate/20131213144223_add_work_item_to_work_effort.rb +0 -8
  84. data/db/migrate/20140106184615_update_work_effort_item_id_to_int.rb +0 -27
@@ -0,0 +1,136 @@
1
+ module Api
2
+ module V1
3
+ class WorkEffortPartyAssignmentsController < BaseController
4
+
5
+ def index
6
+ query_filter = params[:query_filter].blank? ? {} : JSON.parse(params[:query_filter]).symbolize_keys
7
+ limit = params[:limit] || 25
8
+ start = params[:start] || 0
9
+
10
+ work_effort_party_assignments = WorkEffortPartyAssignment
11
+
12
+ # apply filters
13
+ work_effort_party_assignments = WorkEffortPartyAssignment.apply_filters(query_filter, work_effort_party_assignments)
14
+
15
+ # scope by dba organization
16
+ if query_filter[:parties].blank?
17
+ dba_organizations = [current_user.party.dba_organization]
18
+ dba_organizations = dba_organizations.concat(current_user.party.dba_organization.child_dba_organizations)
19
+ work_effort_party_assignments = work_effort_party_assignments.scope_by_dba_organization(dba_organizations)
20
+ end
21
+
22
+ work_effort_party_assignments = work_effort_party_assignments.uniq
23
+
24
+ total_count = work_effort_party_assignments.count
25
+ work_effort_party_assignments = work_effort_party_assignments.offset(start).limit(limit)
26
+
27
+ render :json => {
28
+ success: true,
29
+ total_count: total_count,
30
+ work_effort_party_assignments: work_effort_party_assignments.all.collect do |work_effort_party_assignment|
31
+ work_effort_party_assignment.to_data_hash
32
+ end
33
+ }
34
+ end
35
+
36
+ def create
37
+ begin
38
+ ActiveRecord::Base.connection.transaction do
39
+
40
+ work_effort_party_assignment = WorkEffortPartyAssignment.new
41
+ work_effort_party_assignment.party_id = params['party.id']
42
+ work_effort_party_assignment.work_effort_id = params['work_effort.id']
43
+ work_effort_party_assignment.role_type = RoleType.iid('work_resource')
44
+ work_effort_party_assignment.resource_allocation = params[:resource_allocation]
45
+
46
+ work_effort_party_assignment.created_by_party = current_user.party
47
+
48
+ work_effort_party_assignment.save!
49
+
50
+ # if the party assigned is not watching this task then make them a watcher
51
+ current_watcher_relationship = EntityPartyRole.where('entity_record_type = ?
52
+ and entity_record_id = ?
53
+ and party_id = ?',
54
+ 'WorkEffort',
55
+ work_effort_party_assignment.work_effort_id,
56
+ work_effort_party_assignment.party_id).first
57
+
58
+ unless current_watcher_relationship
59
+ work_effort = work_effort_party_assignment.work_effort
60
+ work_effort.add_party_with_role(work_effort_party_assignment.party, RoleType.iid('watcher'))
61
+ end
62
+
63
+ render :json => {success: true,
64
+ work_effort_party_assignment: work_effort_party_assignment.to_data_hash}
65
+
66
+ end
67
+ rescue ActiveRecord::RecordInvalid => invalid
68
+ Rails.logger.error invalid.record.errors
69
+
70
+ render :json => {:success => false, :message => invalid.record.errors}
71
+ rescue StandardError => ex
72
+ Rails.logger.error ex.message
73
+ Rails.logger.error ex.backtrace.join("\n")
74
+
75
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
76
+
77
+ render json: {success: false, message: 'Error creating WorkEffortPartyAssignment'}
78
+ end
79
+ end
80
+
81
+ def update
82
+
83
+ begin
84
+ ActiveRecord::Base.connection.transaction do
85
+
86
+ work_effort_party_assignment = WorkEffortPartyAssignment.find(params[:id])
87
+ work_effort_party_assignment.party_id = params['party.id']
88
+ work_effort_party_assignment.work_effort_id = params['work_effort.id']
89
+ work_effort_party_assignment.role_type = RoleType.iid('work_resource')
90
+ work_effort_party_assignment.resource_allocation = params[:resource_allocation]
91
+
92
+ work_effort_party_assignment.updated_by_party = current_user.party
93
+
94
+ render :json => {success: work_effort_party_assignment.save!,
95
+ work_effort_party_assignment: work_effort_party_assignment.to_data_hash}
96
+
97
+ end
98
+ rescue ActiveRecord::RecordInvalid => invalid
99
+ Rails.logger.error invalid.record.errors
100
+
101
+ render :json => {:success => false, :message => invalid.record.errors}
102
+ rescue StandardError => ex
103
+ Rails.logger.error ex.message
104
+ Rails.logger.error ex.backtrace.join("\n")
105
+
106
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
107
+
108
+ render json: {success: false, message: 'Error updating WorkEffortPartyAssignment'}
109
+ end
110
+
111
+ end
112
+
113
+ def destroy
114
+
115
+ work_effort_party_assignment = WorkEffortPartyAssignment.find(params[:id])
116
+
117
+ begin
118
+ ActiveRecord::Base.connection.transaction do
119
+
120
+ render json: {success: work_effort_party_assignment.destroy}
121
+
122
+ end
123
+ rescue StandardError => ex
124
+ Rails.logger.error ex.message
125
+ Rails.logger.error ex.backtrace.join("\n")
126
+
127
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
128
+
129
+ render json: {success: false, message: 'Error destroying WorkEffortPartyAssignment'}
130
+ end
131
+
132
+ end
133
+
134
+ end # WorkEffortPartyAssignmentsController
135
+ end # V1
136
+ end # Api
@@ -0,0 +1,120 @@
1
+ module Api
2
+ module V1
3
+ class WorkEffortTypesController < BaseController
4
+
5
+ def index
6
+ if !params[:parent].blank?
7
+ parent = nil
8
+ # create parent if it doesn't exist
9
+ # if the parent param is a comma separated string then
10
+ # the parent is nested from left to right
11
+ params[:parent].split(',').each do |parent_iid|
12
+ if parent
13
+ parent = WorkEffortType.find_or_create(parent_iid, parent_iid.humanize, parent)
14
+ else
15
+ parent = WorkEffortType.find_or_create(parent_iid, parent_iid.humanize)
16
+ end
17
+ end
18
+
19
+ respond_to do |format|
20
+ format.tree do
21
+ render :json => {success: true, work_effort_types: parent.children_to_tree_hash}
22
+ end
23
+ format.json do
24
+ render :json => {success: true, work_effort_types: WorkEffortType.to_all_representation(parent)}
25
+ end
26
+ end
27
+
28
+ # if ids are passed look up on the txn types with the ids passed
29
+ elsif params[:ids]
30
+ ids = params[:ids].split(',').compact
31
+
32
+ work_effort_types = []
33
+
34
+ ids.each do |id|
35
+ # check if id is a integer if so fine by id
36
+ if id.is_integer?
37
+ work_effort_type = WorkEffortType.find(id)
38
+ else
39
+ work_effort_type = WorkEffortType.iid(id)
40
+ end
41
+
42
+ respond_to do |format|
43
+ format.tree do
44
+ data = work_effort_type.to_hash({
45
+ only: [:id, :parent_id, :internal_identifier, :description],
46
+ leaf: work_effort_type.leaf?,
47
+ text: work_effort_type.to_label,
48
+ children: []
49
+ })
50
+
51
+ parent = nil
52
+ work_effort_types.each do |work_effort_type_hash|
53
+ if work_effort_type_hash[:id] == data[:parent_id]
54
+ parent = work_effort_type_hash
55
+ end
56
+ end
57
+
58
+ if parent
59
+ parent[:children].push(data)
60
+ else
61
+ work_effort_types.push(data)
62
+ end
63
+ end
64
+ format.json do
65
+ work_effort_types.push(work_effort_type.to_hash(only: [:id, :description, :internal_identifier]))
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ render :json => {success: true, work_effort_types: work_effort_types}
72
+
73
+ # get all txn types
74
+ else
75
+
76
+ respond_to do |format|
77
+ format.tree do
78
+ nodes = [].tap do |nodes|
79
+ WorkEffortType.roots.each do |root|
80
+ nodes.push(root.to_tree_hash)
81
+ end
82
+ end
83
+
84
+ render :json => {success: true, work_effort_types: nodes}
85
+ end
86
+ format.json do
87
+ render :json => {success: true, work_effort_types: WorkEffortType.to_all_representation}
88
+ end
89
+ end
90
+
91
+ end
92
+ end
93
+
94
+ def show
95
+ work_effort_type = WorkEffortType.find(params[:id])
96
+
97
+ render :json => {success: true, work_effort_type: [work_effort_type.to_data_hash]}
98
+ end
99
+
100
+ def create
101
+ description = params[:description].strip
102
+
103
+ ActiveRecord::Base.transaction do
104
+ work_effort_type = WorkEffortType.create(description: description, internal_identifier: description.to_iid)
105
+
106
+ if !params[:parent].blank? and params[:parent] != 'No Parent'
107
+ parent = WorkEffortType.iid(params[:parent])
108
+ work_effort_type.move_to_child_of(parent)
109
+ elsif !params[:default_parent].blank?
110
+ parent = WorkEffortType.iid(params[:default_parent])
111
+ work_effort_type.move_to_child_of(parent)
112
+ end
113
+
114
+ render :json => {success: true, work_effort_type: work_effort_type.to_hash(only: [:id, :description, :internal_identifier])}
115
+ end
116
+ end
117
+
118
+ end # WorkEffortTypeController
119
+ end # V1
120
+ end # Api
@@ -0,0 +1,284 @@
1
+ module Api
2
+ module V1
3
+ class WorkEffortsController < BaseController
4
+
5
+ def index
6
+ query_filter = params[:query_filter].blank? ? {} : JSON.parse(params[:query_filter]).symbolize_keys
7
+
8
+ work_efforts = WorkEffort.where("work_efforts.parent_id is null")
9
+
10
+ # scope by user if that option is passed and no parties are passed to filter by
11
+ if query_filter[:parties].blank? and params[:scope_by_user].present? and params[:scope_by_user].to_bool
12
+ work_efforts = work_efforts.scope_by_user(current_user, {role_types: [RoleType.iid('work_resource')]})
13
+
14
+ # scope by dba organization if we are not scoping by user or filtering by parties
15
+ elsif query_filter[:parties].blank?
16
+ dba_organizations = [current_user.party.dba_organization]
17
+ dba_organizations = dba_organizations.concat(current_user.party.dba_organization.child_dba_organizations)
18
+ work_efforts = work_efforts.scope_by_dba_organization(dba_organizations)
19
+ end
20
+
21
+ # apply filters
22
+ work_efforts = WorkEffort.apply_filters(query_filter, work_efforts)
23
+
24
+ work_efforts = work_efforts.order("sequence ASC").uniq
25
+
26
+ render :json => {success: true,
27
+ total: work_efforts.count,
28
+ work_efforts: work_efforts.map { |work_effort| work_effort.to_data_hash }}
29
+ end
30
+
31
+ def show
32
+ work_effort = WorkEffort.find(params[:id])
33
+
34
+ respond_to do |format|
35
+ # if a tree format was requested then respond with the children of this WorkEffort
36
+ format.tree do
37
+ render :json => {success: true, work_efforts: WorkEffort.where(parent_id: work_effort).order("sequence ASC").collect { |child| child.to_data_hash }}
38
+ end
39
+
40
+ # if a json format was requested then respond with the WorkEffort in json format
41
+ format.json do
42
+ render :json => {success: true, work_effort: work_effort.to_data_hash}
43
+ end
44
+ end
45
+ end
46
+
47
+ def create
48
+ begin
49
+ ActiveRecord::Base.connection.transaction do
50
+ work_efforts = []
51
+
52
+ if params[:work_efforts]
53
+ params[:work_efforts].each do |work_effort_data|
54
+ work_efforts << create_work_effort(work_effort_data)
55
+ end
56
+ else
57
+ work_efforts << create_work_effort(params)
58
+ end
59
+
60
+ render :json => {success: true, work_efforts: work_efforts.map { |work_effort| work_effort.to_data_hash }}
61
+
62
+ end
63
+ rescue ActiveRecord::RecordInvalid => invalid
64
+ Rails.logger.error invalid.record.errors
65
+
66
+ render :json => {:success => false, :message => invalid.record.errors}
67
+ rescue StandardError => ex
68
+ Rails.logger.error ex.message
69
+ Rails.logger.error ex.backtrace.join("\n")
70
+
71
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
72
+
73
+ render json: {success: false, message: 'Error creating Work Effort'}
74
+ end
75
+ end
76
+
77
+ def update
78
+ begin
79
+ ActiveRecord::Base.connection.transaction do
80
+ work_efforts = []
81
+
82
+ if params[:work_efforts]
83
+ params[:work_efforts].each do |work_effort_data|
84
+ work_efforts << update_work_effort(work_effort_data)
85
+ end
86
+ else
87
+ work_efforts << update_work_effort(params)
88
+ end
89
+
90
+ render :json => {success: true, work_efforts: work_efforts.map { |work_effort| work_effort.to_data_hash }}
91
+
92
+ end
93
+ rescue ActiveRecord::RecordInvalid => invalid
94
+ Rails.logger.error invalid.record.errors
95
+
96
+ render :json => {:success => false, :message => invalid.record.errors}
97
+ rescue StandardError => ex
98
+ Rails.logger.error ex.message
99
+ Rails.logger.error ex.backtrace.join("\n")
100
+
101
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
102
+
103
+ render json: {success: false, message: 'Error updating Work Effort'}
104
+ end
105
+ end
106
+
107
+ def destroy
108
+ work_effort = WorkEffort.find(params[:id])
109
+
110
+ begin
111
+ ActiveRecord::Base.connection.transaction do
112
+
113
+ render json: {success: work_effort.destroy}
114
+
115
+ end
116
+ rescue StandardError => ex
117
+ Rails.logger.error ex.message
118
+ Rails.logger.error ex.backtrace.join("\n")
119
+
120
+ ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier
121
+
122
+ render json: {success: false, message: 'Error destroying Work Effort'}
123
+ end
124
+ end
125
+
126
+ def time_entries_allowed
127
+ work_effort = WorkEffort.find(params[:id])
128
+ party = params[:party_id].blank? ? current_user.party : Party.find(params[:party_id])
129
+
130
+ render json: {success: true, allowed: work_effort.time_entries_allowed?(party)}
131
+ end
132
+
133
+ protected
134
+
135
+ def create_work_effort(data)
136
+ work_effort = WorkEffort.new
137
+ work_effort.description = data[:description].strip
138
+
139
+ if params[:project_id].present?
140
+ if params[:project_id].to_i != 0
141
+ work_effort.project_id = params[:project_id]
142
+ end
143
+ end
144
+
145
+ if data[:start_at].present?
146
+ work_effort.start_at = Time.parse(data[:start_at]).in_time_zone.utc
147
+ end
148
+
149
+ if data[:end_at].present?
150
+ work_effort.end_at = Time.parse(data[:end_at]).in_time_zone.utc
151
+ end
152
+
153
+ if data[:percent_done].present?
154
+ work_effort.percent_done = data[:percent_done]
155
+ end
156
+
157
+ if data[:duration].present?
158
+ work_effort.duration = data[:duration]
159
+ end
160
+
161
+ if data[:duration_unit].present?
162
+ work_effort.duration_unit = data[:duration_unit]
163
+ end
164
+
165
+ if data[:effort].present?
166
+ work_effort.effort = data[:effort]
167
+ end
168
+
169
+ if data[:effort_unit].present?
170
+ work_effort.effort_unit = data[:effort_unit]
171
+ end
172
+
173
+ if data[:comments].present?
174
+ work_effort.comments = data[:comments].strip
175
+ end
176
+
177
+ if data[:sequence].present?
178
+ work_effort.sequence = data[:sequence]
179
+ end
180
+
181
+ if data[:status].present?
182
+ work_effort.current_status = TrackedStatusType.iid(data[:status][:tracked_status_type][:internal_identifier])
183
+ end
184
+
185
+ if data[:work_effort_type].present?
186
+ work_effort.work_effort_type = WorkEffortType.iid(data[:work_effort_type][:internal_identifier])
187
+ end
188
+
189
+ work_effort.created_by_party = current_user.party
190
+
191
+ work_effort.save!
192
+
193
+ # set dba_org
194
+ work_effort.add_party_with_role(current_user.party.dba_organization, RoleType.iid('dba_org'))
195
+
196
+ # if scope by user set the current user relationship
197
+ # scope by user if present
198
+ if params[:scope_by_user].present? and params[:scope_by_user].to_bool
199
+ work_resource_role_type = RoleType.find_or_create("work_resource", "Work Resource", RoleType.iid("application_composer"))
200
+ WorkEffortPartyAssignment.create(work_effort: work_effort,
201
+ role_type: work_resource_role_type,
202
+ party: current_user.party)
203
+ end
204
+
205
+ if data[:parent_id].present? and data[:parent_id] != 0
206
+ parent = WorkEffort.find(data[:parent_id])
207
+ work_effort.move_to_child_of(parent)
208
+ work_effort.reload
209
+ end
210
+
211
+ work_effort
212
+ end
213
+
214
+ def update_work_effort(data)
215
+ work_effort = WorkEffort.find(data[:id])
216
+
217
+ if data[:description].present?
218
+ work_effort.description = data[:description].strip
219
+ end
220
+
221
+ if data[:start_at].present?
222
+ work_effort.start_at = Time.parse(data[:start_at])
223
+ end
224
+
225
+ if data[:end_at].present?
226
+ work_effort.end_at = Time.parse(data[:end_at])
227
+ end
228
+
229
+ if data[:percent_done].present?
230
+ work_effort.percent_done = data[:percent_done]
231
+ end
232
+
233
+ if data[:duration].present?
234
+ work_effort.duration = data[:duration]
235
+ end
236
+
237
+ if data[:duration_unit].present?
238
+ work_effort.duration_unit = data[:duration_unit]
239
+ end
240
+
241
+ if data[:effort].present?
242
+ work_effort.effort = data[:effort]
243
+ end
244
+
245
+ if data[:effort_unit].present?
246
+ work_effort.effort_unit = data[:effort_unit]
247
+ end
248
+
249
+ if data[:comments].present?
250
+ work_effort.comments = data[:comments].strip
251
+ end
252
+
253
+ if data[:sequence].present?
254
+ work_effort.sequence = data[:sequence]
255
+ end
256
+
257
+ if data[:status].present?
258
+ work_effort.current_status = TrackedStatusType.iid(data[:status][:tracked_status_type][:internal_identifier])
259
+ end
260
+
261
+ if data[:work_effort_type].present?
262
+ work_effort.work_effort_type = WorkEffortType.iid(data[:work_effort_type][:internal_identifier])
263
+ end
264
+
265
+ work_effort.updated_by_party = current_user.party
266
+
267
+ work_effort.save!
268
+
269
+ # if there is a parent move the node under that parent
270
+ if data[:parent_id].present? and data[:parent_id] != 0
271
+ parent = WorkEffort.find(data[:parent_id])
272
+ work_effort.move_to_child_of(parent)
273
+
274
+ # if there is no parent then move to root
275
+ else
276
+ work_effort.move_to_root
277
+ end
278
+
279
+ work_effort
280
+ end
281
+
282
+ end # WorkEffortsController
283
+ end # V1
284
+ end # Api