[#4552] Add the Total hours to the Deliverable details

This commit is contained in:
Eric Davis
2010-09-29 11:29:04 -07:00
parent f37306aace
commit 632cff8f7f
5 changed files with 133 additions and 7 deletions
+7 -6
View File
@@ -85,9 +85,8 @@ class Deliverable < ActiveRecord::Base
end
# Total number of hours estimated in the Deliverable's budgets
def estimated_hour_budget_total
(labor_budgets.sum(:hours) || 0.0) +
(overhead_budgets.sum(:hours) || 0.0)
def estimated_hour_budget_total(date=nil)
labor_budget_hours(date) + overhead_budget_hours(date)
end
# OPTIMIZE: N+1
@@ -100,9 +99,11 @@ class Deliverable < ActiveRecord::Base
issues.inject(0) {|total, issue| total += issue.overhead_time_spent } # From redmine_overhead
end
# OPTIMIZE: N+1
def hours_spent_total
issues.inject(0) {|total, issue| total += issue.spent_hours }
def hours_spent_total(date=nil)
return 0 if issues.empty?
# Don't count subissues
TimeEntry.sum(:hours, :conditions => { :issue_id => issues.collect(&:id) })
end
def fixed_budget_total(date=nil)
+17
View File
@@ -159,6 +159,23 @@ class RetainerDeliverable < HourlyDeliverable
end
end
def hours_spent_total(date=nil)
case scope_date_status(date)
when :in
return 0 if issues.empty?
TimeEntry.sum(:hours, :conditions => {
:issue_id => issues.collect(&:id),
:tyear => date.year,
:tmonth => date.month
})
when :out
0
else
super
end
end
def fixed_budget_total(date=nil)
case scope_date_status(date)
when :in