[#4552] Add the Total hours to the Deliverable details
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -96,7 +96,11 @@
|
||||
<td class="l"><strong>Total:</strong></td>
|
||||
<td class="total_spent"><strong><%= h(format_value_field_for_contracts(deliverable.total_spent(validated_period))) %></strong></td>
|
||||
<td class="total"><strong><%= h(format_value_field_for_contracts(deliverable.total(validated_period))) %></strong></td>
|
||||
<td><strong>TODO: Release 2</strong></td>
|
||||
<td class="total_hours">
|
||||
<strong>
|
||||
<%= h(format_value_field_for_contracts(deliverable.hours_spent_total(validated_period))) %>/<%= h(format_value_field_for_contracts(deliverable.estimated_hour_budget_total(validated_period))) %> <%= l(:text_short_hours) %>
|
||||
</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user