diff --git a/app/views/deliverables/_finances.html.erb b/app/views/deliverables/_finances.html.erb index 2ff292d..c3f2a9a 100644 --- a/app/views/deliverables/_finances.html.erb +++ b/app/views/deliverables/_finances.html.erb @@ -7,7 +7,9 @@

<%= h(deliverable.title) %>

-
+<% has_categories = deliverable.project.issue_categories.count > 0 %> + +

Activities

@@ -113,7 +115,7 @@ <%# /div#activities %> -
+

Users

@@ -193,3 +195,112 @@
<%# /div.users %> + +<% if has_categories %> +
+

Issue Categories

+ + + + + + + + + + <% deliverable.issue_categories_with_billable_time.sort.each do |category| %> + + <% content_tag_for(:tr, category, :class => 'labor ' + cycle('even','')) do %> + + + + <% end %> + + <% end %> + + <% content_tag_for(:tr, IssueCategory.new, :class => 'labor ' + cycle('even','')) do %> + + + + <% end %> + + + + + + + + +
<%= l(:field_labor) %><%= l(:field_cost) %><%= l(:field_hours) %>
+ <%= h(category.name) %> + + <%= number_to_currency(deliverable.spent_for_issue_category(category, true), :precision => Deliverable::ViewPrecision) %> + + <%= number_with_precision(deliverable.hours_spent_for_issue_category(category, true), :precision => Deliverable::ViewPrecision) %> + + <%= l(:label_none) %> + + <%= number_to_currency(deliverable.spent_for_issue_category(nil, true), :precision => Deliverable::ViewPrecision) %> + + <%= number_with_precision(deliverable.hours_spent_for_issue_category(nil, true), :precision => Deliverable::ViewPrecision) %> +
+ Totals + + <%= number_to_currency(deliverable.labor_budget_spent, :precision => Deliverable::ViewPrecision) %> + + <%= number_with_precision(deliverable.labor_hours_spent_total, :precision => Deliverable::ViewPrecision) %> +
+ + + + + + + + + + <% deliverable.issue_categories_with_non_billable_time.sort.each do |category| %> + + <% content_tag_for(:tr, category, :class => 'overhead ' + cycle('even','')) do %> + + + + <% end %> + + <% end %> + + <% content_tag_for(:tr, IssueCategory.new, :class => 'labor ' + cycle('even','')) do %> + + + + <% end %> + + + + + + + + +
<%= l(:field_overhead) %><%= l(:field_cost) %><%= l(:field_hours) %>
+ <%= h(category.name) %> + + <%= number_to_currency(deliverable.spent_for_issue_category(category, false), :precision => Deliverable::ViewPrecision) %> + + <%= number_with_precision(deliverable.hours_spent_for_issue_category(category, false), :precision => Deliverable::ViewPrecision) %> + + <%= l(:label_none) %> + + <%= number_to_currency(deliverable.spent_for_issue_category(nil, false), :precision => Deliverable::ViewPrecision) %> + + <%= number_with_precision(deliverable.hours_spent_for_issue_category(nil, false), :precision => Deliverable::ViewPrecision) %> +
+ Totals + + <%= number_to_currency(deliverable.overhead_spent, :precision => Deliverable::ViewPrecision) %> + + <%= number_with_precision(deliverable.overhead_hours_spent_total, :precision => Deliverable::ViewPrecision) %> +
+ +
<%# /div.users %> +<% end %> diff --git a/test/integration/deliverable_finances_test.rb b/test/integration/deliverable_finances_test.rb index 3d83d98..f6db682 100644 --- a/test/integration/deliverable_finances_test.rb +++ b/test/integration/deliverable_finances_test.rb @@ -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