[#6636] Add table for issue categories to the deliverable finance report

This commit is contained in:
Eric Davis
2011-10-13 15:54:53 -07:00
parent bbf5d70170
commit 63cc58a459
2 changed files with 176 additions and 15 deletions
+113 -2
View File
@@ -7,7 +7,9 @@
<h2><%= h(deliverable.title) %></h2>
<div id="deliverable-activities" class="deliverable-finance-report" style="<%= css_width_calculator(2) %>">
<% has_categories = deliverable.project.issue_categories.count > 0 %>
<div id="deliverable-activities" class="deliverable-finance-report" style="<%= css_width_calculator( has_categories ? 3 : 2) %>">
<h3>Activities</h3>
<table id="deliverable-labor-activities" class="striped-contract-style">
@@ -113,7 +115,7 @@
</div><%# /div#activities %>
<div id="deliverable-users" class="deliverable-finance-report" style="<%= css_width_calculator(2) %>" >
<div id="deliverable-users" class="deliverable-finance-report" style="<%= css_width_calculator( has_categories ? 3 : 2) %>" >
<h3>Users</h3>
<table id="deliverable-labor-users" class="striped-contract-style">
@@ -193,3 +195,112 @@
</table>
</div><%# /div.users %>
<% if has_categories %>
<div id="deliverable-issue-categories" class="deliverable-finance-report" style="<%= css_width_calculator( has_categories ? 3 : 2) %>" >
<h3>Issue Categories</h3>
<table id="deliverable-labor-issue-categories" class="striped-contract-style">
<thead>
<th><%= l(:field_labor) %></th>
<th><%= l(:field_cost) %></th>
<th><%= l(:field_hours) %></th>
</thead>
<tbody>
<% deliverable.issue_categories_with_billable_time.sort.each do |category| %>
<% content_tag_for(:tr, category, :class => 'labor ' + cycle('even','')) do %>
<td class="">
<%= h(category.name) %>
</td>
<td class="financial amount-cost">
<%= number_to_currency(deliverable.spent_for_issue_category(category, true), :precision => Deliverable::ViewPrecision) %>
</td>
<td class="numeric time-cost">
<%= number_with_precision(deliverable.hours_spent_for_issue_category(category, true), :precision => Deliverable::ViewPrecision) %>
</td>
<% end %>
<% end %>
<% content_tag_for(:tr, IssueCategory.new, :class => 'labor ' + cycle('even','')) do %>
<td class="">
<%= l(:label_none) %>
</td>
<td class="financial amount-cost">
<%= number_to_currency(deliverable.spent_for_issue_category(nil, true), :precision => Deliverable::ViewPrecision) %>
</td>
<td class="numeric time-cost">
<%= number_with_precision(deliverable.hours_spent_for_issue_category(nil, true), :precision => Deliverable::ViewPrecision) %>
</td>
<% end %>
<tr class="total summary-row labor">
<td class="">
Totals
</td>
<td class="financial amount-cost">
<%= number_to_currency(deliverable.labor_budget_spent, :precision => Deliverable::ViewPrecision) %>
</td>
<td class="numeric time-cost">
<%= number_with_precision(deliverable.labor_hours_spent_total, :precision => Deliverable::ViewPrecision) %>
</td>
</tr>
</tbody>
</table>
<table id="deliverable-overhead-issue-categories" class="striped-contract-style">
<thead>
<th><%= l(:field_overhead) %></th>
<th><%= l(:field_cost) %></th>
<th><%= l(:field_hours) %></th>
</thead>
<tbody>
<% deliverable.issue_categories_with_non_billable_time.sort.each do |category| %>
<% content_tag_for(:tr, category, :class => 'overhead ' + cycle('even','')) do %>
<td class="">
<%= h(category.name) %>
</td>
<td class="financial amount-cost">
<%= number_to_currency(deliverable.spent_for_issue_category(category, false), :precision => Deliverable::ViewPrecision) %>
</td>
<td class="numeric time-cost">
<%= number_with_precision(deliverable.hours_spent_for_issue_category(category, false), :precision => Deliverable::ViewPrecision) %>
</td>
<% end %>
<% end %>
<% content_tag_for(:tr, IssueCategory.new, :class => 'labor ' + cycle('even','')) do %>
<td class="">
<%= l(:label_none) %>
</td>
<td class="financial amount-cost">
<%= number_to_currency(deliverable.spent_for_issue_category(nil, false), :precision => Deliverable::ViewPrecision) %>
</td>
<td class="numeric time-cost">
<%= number_with_precision(deliverable.hours_spent_for_issue_category(nil, false), :precision => Deliverable::ViewPrecision) %>
</td>
<% end %>
<tr class="total summary-row overhead">
<td class="">
Totals
</td>
<td class="financial amount-cost">
<%= number_to_currency(deliverable.overhead_spent, :precision => Deliverable::ViewPrecision) %>
</td>
<td class="numeric time-cost">
<%= number_with_precision(deliverable.overhead_hours_spent_total, :precision => Deliverable::ViewPrecision) %>
</td>
</tr>
</tbody>
</table>
</div><%# /div.users %>
<% end %>
+63 -13
View File
@@ -14,20 +14,31 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest
@deliverable1.save!
@user = User.generate_user_with_permission_to_manage_budget(:project => @project)
@category_on_billable = IssueCategory.generate!(:project => @project).reload
@category_on_non_billable = IssueCategory.generate!(:project => @project).reload
# 2 hours of $100 billable work
create_issue_with_time_for_deliverable(@deliverable1, {
:activity => @billable_activity,
:user => @manager,
:hours => 2,
:amount => 100
:amount => 100,
:issue_category => @category_on_billable
})
# 1 hour of $100 billable work with no category
create_issue_with_time_for_deliverable(@deliverable1, {
:activity => @billable_activity,
:user => @manager,
:hours => 1,
:amount => 100,
:issue_category => nil
})
# 5 hours of $100 nonbillable work
create_issue_with_time_for_deliverable(@deliverable1, {
:activity => @non_billable_activity,
:user => @manager,
:hours => 5,
:amount => 100
:amount => 100,
:issue_category => @category_on_non_billable
})
@user.reload
@@ -72,9 +83,9 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest
assert_select "h2", :text => /#{@deliverable1.title}/
assert_select "div#finance-summary" do
assert_select "span.spent", :text => /\$200/ # $100 * 2
assert_select "span.spent", :text => /\$300/ # ($100 * 2) + ($100 * 1)
assert_select "span.total", :text => /\$300/ # $100 * 3
assert_select "span.hours", :text => /2/
assert_select "span.hours", :text => /3/
end
end
@@ -82,17 +93,17 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest
assert_select "table#deliverable-labor-activities" do
assert_select "tr.labor" do
assert_select "td", :text => /#{@billable_activity.name}/
assert_select "td.spent-amount", :text => /\$200/
assert_select "td.spent-amount", :text => /\$300/
assert_select "td.total-amount", :text => /\$300/
assert_select "td.spent-hours", :text => /2/
assert_select "td.spent-hours", :text => /3/
assert_select "td.total-deliverable-hours", :text => /30/ # 3 month retainer * 10
end
assert_select "tr.summary-row.labor" do
assert_select "td", :text => /Totals/
assert_select "td.spent-amount", :text => /\$200/
assert_select "td.spent-amount", :text => /\$300/
assert_select "td.total-amount", :text => /\$300/
assert_select "td.spent-hours", :text => /2/
assert_select "td.spent-hours", :text => /3/
assert_select "td.total-deliverable-hours", :text => /30/
end
@@ -124,14 +135,14 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest
assert_select "table#deliverable-labor-users" do
assert_select "tr.labor" do
assert_select "td", :text => /#{@manager.name}/
assert_select "td.amount-cost", :text => /\$200/
assert_select "td.time-cost", :text => /2/
assert_select "td.amount-cost", :text => /\$300/
assert_select "td.time-cost", :text => /3/
end
assert_select "tr.summary-row" do
assert_select "td", :text => /Totals/
assert_select "td.amount-cost", :text => /\$200/
assert_select "td.time-cost", :text => /2/
assert_select "td.amount-cost", :text => /\$300/
assert_select "td.time-cost", :text => /3/
end
end
@@ -154,5 +165,44 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest
end
end
should "render the labor finances for each Issue Category for the deliverable" do
assert_select "table#deliverable-labor-issue-categories" do
assert_select "tr.labor" do
assert_select "td", :text => /#{@category_on_billable.name}/
assert_select "td.amount-cost", :text => /\$200/
assert_select "td.time-cost", :text => /2/
end
assert_select "tr.labor" do
assert_select "td", :text => /none/
assert_select "td.amount-cost", :text => /\$100/
assert_select "td.time-cost", :text => /1/
end
assert_select "tr.summary-row" do
assert_select "td", :text => /Totals/
assert_select "td.amount-cost", :text => /\$300/
assert_select "td.time-cost", :text => /3/
end
end
end
should "render the overhead finances for each Issue Category for the deliverable" do
assert_select "table#deliverable-overhead-issue-categories" do
assert_select "tr.overhead" do
assert_select "td", :text => /#{@category_on_non_billable.name}/
assert_select "td.amount-cost", :text => /\$500/
assert_select "td.time-cost", :text => /5/
end
assert_select "tr.summary-row.overhead" do
assert_select "td", :text => /Totals/
assert_select "td.amount-cost", :text => /\$500/
assert_select "td.time-cost", :text => /5/
end
end
end
end
end