[#4552] Add the Overhead hours spent to the Deliverable details
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -62,7 +62,9 @@
|
||||
<td class="l"><a href="#"><strong>Overhead</strong></a></td>
|
||||
<td class="overhead_budget_spent"><%= h(format_value_field_for_contracts(deliverable.overhead_spent(validated_period))) %></td>
|
||||
<td class="overhead_budget_total"><%= h(format_value_field_for_contracts(deliverable.overhead_budget_total(validated_period))) %></td>
|
||||
<td class="overhead_hours"> TODO: Release 2 / TODO hrs </td>
|
||||
<td class="overhead_hours">
|
||||
<%= h(format_value_field_for_contracts(deliverable.overhead_hours_spent_total(validated_period))) %>/<%= h(format_value_field_for_contracts(deliverable.overhead_budget_hours(validated_period))) %> <%= l(:text_short_hours) %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% deliverable.fixed_budgets.by_period(validated_period).each do |fixed_budget| %>
|
||||
|
||||
Reference in New Issue
Block a user