Permalink
Browse files

Only count current and past estimated/actual hours when calculating t…

…he delta. Preserve desired behavior of not counting future estimates when calculating diffs to actuals while properly totaling both. #146
  • Loading branch information...
1 parent 7e6b562 commit f6c2f1a858f064aaec4fd03105873a19af7044b0 @fermion fermion committed Dec 12, 2013
View
11 app/assets/javascripts/views/_shared/assignment.totals.js.coffee
@@ -8,12 +8,17 @@ class window.StaffPlan.Views.StaffPlans.AssignmentTotals extends Support.Composi
render: ->
hours = _.reduce(@model.work_weeks.models, (memo, ww) ->
+
+ unless ww.inFuture()
+ memo.currentAndPastActual += parseInt(ww.get('estimated_hours', 10) || 0)
+ memo.currentAndPastEstimated += parseInt(ww.get('actual_hours', 10) || 0)
+
memo.estimated += parseInt(ww.get('estimated_hours'), 10) || 0
- memo.actual += parseInt(ww.get('actual_hours'), 10) || 0
+ memo.actual += parseInt(ww.get('actual_hours'), 10) || 0
memo
- , {estimated: 0, actual: 0})
+ , {estimated: 0, actual: 0, currentAndPastEstimated: 0, currentAndPastActual: 0})
- hours.delta = hours.actual - hours.estimated
+ hours.delta = hours.currentAndPastActual - hours.currentAndPastEstimated
@$el.html StaffPlan.Templates.StaffPlans.assignment_totals
hours: hours
View
7 app/assets/javascripts/views/_shared/totals.js.coffee
@@ -7,12 +7,15 @@ class window.StaffPlan.Views.Shared.Totals extends Support.CompositeView
render: ->
hours = @weeks.reduce (memo, ww) ->
+ unless ww.inFuture()
+ memo.currentAndPastActual += parseInt(ww.get('estimated_hours', 10) || 0)
+ memo.currentAndPastEstimated += parseInt(ww.get('actual_hours', 10) || 0)
memo.estimated += parseInt(ww.get('estimated_hours'), 10) || 0
memo.actual += parseInt(ww.get('actual_hours'), 10) || 0
memo
- , {estimated: 0, actual: 0}
+ , {estimated: 0, actual: 0, currentAndPastEstimated: 0, currentAndPastActual: 0}
- hours.delta = hours.actual - hours.estimated
+ hours.delta = hours.currentAndPastActual - hours.currentAndPastEstimated
@$el.html StaffPlan.Templates.StaffPlans.assignment_totals
hours: hours

0 comments on commit f6c2f1a

Please sign in to comment.