[#4552] Add the Overhead hours spent to the Deliverable details

This commit is contained in:
Eric Davis
2010-09-29 10:54:33 -07:00
parent 38f2bcb17f
commit f37306aace
6 changed files with 129 additions and 3 deletions
+10 -1
View File
@@ -80,6 +80,10 @@ class Deliverable < ActiveRecord::Base
labor_budgets.sum(:hours)
end
def overhead_budget_hours(date=nil)
overhead_budgets.sum(:hours)
end
# Total number of hours estimated in the Deliverable's budgets
def estimated_hour_budget_total
(labor_budgets.sum(:hours) || 0.0) +
@@ -90,7 +94,12 @@ class Deliverable < ActiveRecord::Base
def labor_hours_spent_total(date=nil)
issues.inject(0) {|total, issue| total += issue.billable_time_spent } # From redmine_overhead
end
# OPTIMIZE: N+1
def overhead_hours_spent_total(date=nil)
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 }
+9 -1
View File
@@ -50,8 +50,16 @@ class HourlyDeliverable < Deliverable
protected
def billable_hours_on_time_entries(time_entries)
hours_on_time_entries_with_billable_option(true, time_entries)
end
def nonbillable_hours_on_time_entries(time_entries)
hours_on_time_entries_with_billable_option(false, time_entries)
end
def hours_on_time_entries_with_billable_option(billable, time_entries)
time_entries.inject(0) {|total, time_entry|
total += time_entry.hours if time_entry.billable?
total += time_entry.hours if (time_entry.billable? == billable)
total
}
end
+13
View File
@@ -146,6 +146,19 @@ class RetainerDeliverable < HourlyDeliverable
end
end
def overhead_hours_spent_total(date=nil)
case scope_date_status(date)
when :in
time_entries = issues.collect {|issue| issue.time_entries.all(:conditions => {:tyear => date.year, :tmonth => date.month}) }.flatten
nonbillable_hours_on_time_entries(time_entries)
when :out
0
else
super
end
end
def fixed_budget_total(date=nil)
case scope_date_status(date)
when :in