From 1bbce5457f6b95bf261a153bcea506b02f17c56c Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Wed, 12 Oct 2011 15:58:19 -0700 Subject: [PATCH] [#6636] Show deliverable calculations for Labor in the finance lightbox --- app/views/deliverables/_finances.html.erb | 53 +++++++++++++++++++ config/locales/en.yml | 2 + test/integration/deliverable_finances_test.rb | 30 ++++++++++- 3 files changed, 83 insertions(+), 2 deletions(-) diff --git a/app/views/deliverables/_finances.html.erb b/app/views/deliverables/_finances.html.erb index 26aeae5..2d1f9b3 100644 --- a/app/views/deliverables/_finances.html.erb +++ b/app/views/deliverables/_finances.html.erb @@ -6,3 +6,56 @@

<%= h(deliverable.title) %>

+ +

Activities

+ + + + + + + + + + <%# Each labor activity + non-budgeted activities %> + <% deliverable.billable_time_entry_activities.each do |activity| %> + + <% content_tag_for(:tr, activity, :class => 'labor ' + cycle('even','')) do %> + + + + + + <% end %> + + <% end %> + + + + + + + + + +
<%= l(:field_labor) %><%= l(:field_cost) %><%= l(:field_hours) %>
+ <%= h(activity.name) %> + + <%= number_to_currency(deliverable.spent_for_activity(activity), :precision => 0) %> + + <%= number_to_currency(deliverable.budget_for_activity(activity), :precision => 0) %> + + <%= number_with_precision(deliverable.hours_spent_for_activity(activity), :precision => 0) %> + + <%= number_with_precision(deliverable.hours_budget_for_activity(activity), :precision => 0) %> +
+ Totals + + $80 + + $100 + + 1.5 + + 2 +
diff --git a/config/locales/en.yml b/config/locales/en.yml index e846dda..c441e05 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -102,3 +102,5 @@ en: text_contract_closed_warning: "This contract is closed and cannot be saved without changing it's status to Open." field_time_entry_activity: "Activity" text_deliverable_spending_summary: "You've spent %{spent} / %{total} and %{hours} Billable Hours" + field_cost: "Cost" + diff --git a/test/integration/deliverable_finances_test.rb b/test/integration/deliverable_finances_test.rb index c0e2715..4c99068 100644 --- a/test/integration/deliverable_finances_test.rb +++ b/test/integration/deliverable_finances_test.rb @@ -9,7 +9,7 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest @contract = Contract.generate!(:project => @project, :billable_rate => 10) @manager = User.generate! @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) + @deliverable1.labor_budgets << LaborBudget.spawn(:budget => 100, :hours => 10, :time_entry_activity => @billable_activity) @deliverable1.overhead_budgets << OverheadBudget.spawn(:budget => 200, :hours => 10) @deliverable1.save! @@ -54,10 +54,13 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest context "for an authorized request" do - should "render the finance report title section for the deliverable" do + setup do visit "/projects/#{@project.id}/contracts/#{@contract.id}/deliverables/#{@deliverable1.id}/finances" assert_response :success + end + + should "render the finance report title section for the deliverable" do assert_select "h2", :text => /#{@deliverable1.title}/ assert_select "div#summary" do @@ -67,5 +70,28 @@ class DeliverableFinancesShowTest < ActionController::IntegrationTest end end + should "render the activities table for the deliverable" do + assert_select "h3", :text => /Activities/ + + assert_select "table#deliverable-labor-activities" do + assert_select "tr" do + assert_select "td.labor", :text => /#{@billable_activity.name}/ + assert_select "td.spent-amount.labor", :text => /\$200/ + assert_select "td.total-amount.labor", :text => /\$300/ + assert_select "td.spent-hours.labor", :text => /2/ + assert_select "td.total-hours.labor", :text => /30/ # 3 month retainer * 10 + end + + assert_select "tr.total" do + assert_select "td.labor", :text => /Totals/ + assert_select "td.spent-amount.labor", :text => /\$200/ + assert_select "td.total-amount.labor", :text => /\$300/ + assert_select "td.spent-hours.labor", :text => /2/ + assert_select "td.total-hours.labor", :text => /30/ + end + + end + end + end end