[#4182] Show the total Labor and Overhead values on the Contract details page.
This commit is contained in:
@@ -5,4 +5,15 @@ module ContractsHelper
|
||||
d.overhead_budgets.build if d.overhead_budgets.empty?
|
||||
end
|
||||
end
|
||||
|
||||
def format_budget_for_deliverable(deliverable, total)
|
||||
# TODO LATER: calculate amount used
|
||||
if total > 0
|
||||
content_tag(:span, "0", :class => 'spent-amount') +
|
||||
" " +
|
||||
content_tag(:span, h(number_to_currency(total, :unit => '')), :class => 'total-amount')
|
||||
else
|
||||
'---'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,7 +32,15 @@ class Deliverable < ActiveRecord::Base
|
||||
write_attribute(:total, v)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def labor_budget_total
|
||||
labor_budgets.sum(:budget)
|
||||
end
|
||||
|
||||
def overhead_budget_total
|
||||
overhead_budgets.sum(:budget)
|
||||
end
|
||||
|
||||
if Rails.env.test?
|
||||
generator_for :title, :method => :next_title
|
||||
|
||||
|
||||
@@ -42,9 +42,12 @@
|
||||
<td class="title"><%= h deliverable.title %></td>
|
||||
<%# TODO: Status %>
|
||||
<td class="manager"><%= h deliverable.manager.try(:name) %></td>
|
||||
<%# TODO: deliverable calculations %>
|
||||
<td class="labor">---</td>
|
||||
<td class="overhead">---</td>
|
||||
<td class="labor">
|
||||
<%= format_budget_for_deliverable(deliverable, deliverable.labor_budget_total) %>
|
||||
</td>
|
||||
<td class="overhead">
|
||||
<%= format_budget_for_deliverable(deliverable, deliverable.overhead_budget_total) %>
|
||||
</td>
|
||||
<td class="fixed">---</td>
|
||||
<td><%= link_to(l(:button_edit), edit_contract_deliverable_path(@project, resource, deliverable), :class => 'icon icon-edit') %></td>
|
||||
<td><%= link_to(l(:button_delete), contract_deliverable_path(@project, resource, deliverable), :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %></td>
|
||||
|
||||
@@ -56,4 +56,40 @@ class ContractsShowTest < ActionController::IntegrationTest
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
should "show the total labor budget for a Deliverable" do
|
||||
@manager = User.generate!
|
||||
|
||||
@deliverable1 = FixedDeliverable.generate!(:contract => @contract, :manager => @manager)
|
||||
LaborBudget.generate!(:deliverable => @deliverable1,
|
||||
:hours => 100,
|
||||
:budget => 4000.5)
|
||||
LaborBudget.generate!(:deliverable => @deliverable1,
|
||||
:hours => 100,
|
||||
:budget => 200.0)
|
||||
|
||||
visit_contract_page(@contract)
|
||||
assert_select "table#deliverables" do
|
||||
assert_select "td.labor", :text => /4,200.50/
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
should "show the total overhead budget for a Deliverable" do
|
||||
@manager = User.generate!
|
||||
|
||||
@deliverable1 = FixedDeliverable.generate!(:contract => @contract, :manager => @manager)
|
||||
OverheadBudget.generate!(:deliverable => @deliverable1,
|
||||
:hours => 100,
|
||||
:budget => 4000.5)
|
||||
OverheadBudget.generate!(:deliverable => @deliverable1,
|
||||
:hours => 100,
|
||||
:budget => 200.0)
|
||||
|
||||
visit_contract_page(@contract)
|
||||
assert_select "table#deliverables" do
|
||||
assert_select "td.overhead", :text => /4,200.50/
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user