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

This commit is contained in:
Eric Davis
2010-09-29 10:44:54 -07:00
parent 7a5599b4f9
commit 38f2bcb17f
5 changed files with 116 additions and 2 deletions
+5
View File
@@ -86,6 +86,11 @@ class Deliverable < ActiveRecord::Base
(overhead_budgets.sum(:hours) || 0.0)
end
# OPTIMIZE: N+1
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 hours_spent_total
issues.inject(0) {|total, issue| total += issue.spent_hours }
+13
View File
@@ -133,6 +133,19 @@ class RetainerDeliverable < HourlyDeliverable
end
end
def labor_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
billable_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
+4 -2
View File
@@ -54,13 +54,15 @@
<td class="l"><a href="#"><strong>Labor</strong></a></td>
<td class="labor_budget_spent"><%= h(format_value_field_for_contracts(deliverable.labor_budget_spent(validated_period))) %></td>
<td class="labor_budget_total"><%= h(format_value_field_for_contracts(deliverable.labor_budget_total(validated_period))) %></td>
<td> TODO: Release 2 / TODO hrs </td>
<td class="labor_hours">
<%= h(format_value_field_for_contracts(deliverable.labor_hours_spent_total(validated_period))) %>/<%= h(format_value_field_for_contracts(deliverable.labor_budget_hours(validated_period))) %> <%= l(:text_short_hours) %>
</td>
</tr>
<tr>
<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> TODO: Release 2 / TODO hrs </td>
<td class="overhead_hours"> TODO: Release 2 / TODO hrs </td>
</tr>
<% deliverable.fixed_budgets.by_period(validated_period).each do |fixed_budget| %>