[#6636] Add Users/Labor table to the deliverable finance report

This commit is contained in:
Eric Davis
2011-10-13 11:16:24 -07:00
parent f972efffbf
commit 084ab1dd96
2 changed files with 61 additions and 1 deletions

View File

@@ -112,3 +112,46 @@
</table>
</div><%# /div#activities %>
<div id="deliverable-users" style="width: 33%">
<h3>Users</h3>
<table id="deliverable-labor-users" class="striped-contract-style">
<thead>
<th><%= l(:field_labor) %></th>
<th><%= l(:field_cost) %></th>
<th><%= l(:field_hours) %></th>
</thead>
<tbody>
<% deliverable.users_with_billable_time.sort.each do |user| %>
<% content_tag_for(:tr, user, :class => 'labor ' + cycle('even','')) do %>
<td class="labor">
<%= h(user.name) %>
</td>
<td class="amount-cost labor">
<%= number_to_currency(deliverable.spent_for_user(user, true), :precision => 0) %>
</td>
<td class="time-cost labor">
<%= number_with_precision(deliverable.hours_spent_for_user(user, true), :precision => 0) %>
</td>
<% end %>
<% end %>
<tr class="total summary-row labor">
<td class="labor">
Totals
</td>
<td class="amount-cost labor">
<%= number_to_currency(deliverable.labor_budget_spent, :precision => 0) %>
</td>
<td class="time-cost labor">
<%= number_with_precision(deliverable.labor_hours_spent_total, :precision => 0) %>
</td>
</tr>
</tbody>
</table>
</div><%# /div.users %>

View File

@@ -7,7 +7,7 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest
configure_overhead_plugin
@project = Project.generate!(:identifier => 'main').reload
@contract = Contract.generate!(:project => @project, :billable_rate => 10)
@manager = User.generate!
@manager = User.generate!.reload
@deliverable1 = RetainerDeliverable.spawn(:contract => @contract, :manager => @manager, :title => "Retainer Title", :start_date => '2010-01-01', :end_date => '2010-03-31')
@deliverable1.labor_budgets << LaborBudget.spawn(:budget => 100, :hours => 10, :time_entry_activity => @billable_activity)
@deliverable1.overhead_budgets << OverheadBudget.spawn(:budget => 200, :hours => 10)
@@ -120,5 +120,22 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest
end
end
should "render the labor finances for each user for the deliverable" do
assert_select "table#deliverable-labor-users" do
assert_select "tr" do
assert_select "td.labor", :text => /#{@manager.name}/
assert_select "td.amount-cost.labor", :text => /\$200/
assert_select "td.time-cost.labor", :text => /2/
end
assert_select "tr.summary-row" do
assert_select "td.labor", :text => /Totals/
assert_select "td.amount-cost.labor", :text => /\$200/
assert_select "td.time-cost.labor", :text => /2/
end
end
end
end
end