[#4182] Display the Labor and Overhead spent on the Contract page.
This commit is contained in:
@@ -6,10 +6,9 @@ module ContractsHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_budget_for_deliverable(deliverable, total)
|
def format_budget_for_deliverable(deliverable, spent, total)
|
||||||
# TODO LATER: calculate amount used
|
if total > 0 || spent > 0
|
||||||
if total > 0
|
content_tag(:span, h(number_to_currency(spent, :unit => '')), :class => 'spent-amount') +
|
||||||
content_tag(:span, "0", :class => 'spent-amount') +
|
|
||||||
" " +
|
" " +
|
||||||
content_tag(:span, h(number_to_currency(total, :unit => '')), :class => 'total-amount')
|
content_tag(:span, h(number_to_currency(total, :unit => '')), :class => 'total-amount')
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -43,10 +43,10 @@
|
|||||||
<%# TODO: Status %>
|
<%# TODO: Status %>
|
||||||
<td class="manager"><%= h deliverable.manager.try(:name) %></td>
|
<td class="manager"><%= h deliverable.manager.try(:name) %></td>
|
||||||
<td class="labor">
|
<td class="labor">
|
||||||
<%= format_budget_for_deliverable(deliverable, deliverable.labor_budget_total) %>
|
<%= format_budget_for_deliverable(deliverable, deliverable.labor_budget_spent, deliverable.labor_budget_total) %>
|
||||||
</td>
|
</td>
|
||||||
<td class="overhead">
|
<td class="overhead">
|
||||||
<%= format_budget_for_deliverable(deliverable, deliverable.overhead_budget_total) %>
|
<%= format_budget_for_deliverable(deliverable, deliverable.overhead_spent, deliverable.overhead_budget_total) %>
|
||||||
</td>
|
</td>
|
||||||
<td class="fixed">---</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_edit), edit_contract_deliverable_path(@project, resource, deliverable), :class => 'icon icon-edit') %></td>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class ContractsShowTest < ActionController::IntegrationTest
|
|||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@project = Project.generate!(:identifier => 'main')
|
@project = Project.generate!(:identifier => 'main').reload
|
||||||
@contract = Contract.generate!(:project => @project)
|
@contract = Contract.generate!(:project => @project)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -92,4 +92,72 @@ class ContractsShowTest < ActionController::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "show the total labor budget spent for a Deliverable" do
|
||||||
|
configure_overhead_plugin
|
||||||
|
|
||||||
|
@manager = User.generate!
|
||||||
|
|
||||||
|
@deliverable1 = FixedDeliverable.generate!(:contract => @contract, :manager => @manager)
|
||||||
|
OverheadBudget.generate!(:deliverable => @deliverable1,
|
||||||
|
:hours => 100,
|
||||||
|
:budget => 4000.5)
|
||||||
|
|
||||||
|
@issue1 = Issue.generate_for_project!(@project)
|
||||||
|
@time_entry1 = TimeEntry.generate!(:issue => @issue1,
|
||||||
|
:project => @project,
|
||||||
|
:activity => @billable_activity,
|
||||||
|
:spent_on => Date.today,
|
||||||
|
:hours => 10,
|
||||||
|
:user => @manager)
|
||||||
|
|
||||||
|
@rate = Rate.generate!(:project => @project,
|
||||||
|
:user => @manager,
|
||||||
|
:date_in_effect => Date.yesterday,
|
||||||
|
:amount => 100)
|
||||||
|
|
||||||
|
@deliverable1.issues << @issue1
|
||||||
|
|
||||||
|
assert_equal 1, @deliverable1.issues.count
|
||||||
|
|
||||||
|
visit_contract_page(@contract)
|
||||||
|
assert_select "table#deliverables" do
|
||||||
|
assert_select "td.labor", :text => /1,000.00/
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
should "show the total overhead budget spent for a Deliverable" do
|
||||||
|
configure_overhead_plugin
|
||||||
|
|
||||||
|
@manager = User.generate!
|
||||||
|
|
||||||
|
@deliverable1 = FixedDeliverable.generate!(:contract => @contract, :manager => @manager)
|
||||||
|
OverheadBudget.generate!(:deliverable => @deliverable1,
|
||||||
|
:hours => 100,
|
||||||
|
:budget => 4000.5)
|
||||||
|
|
||||||
|
@issue1 = Issue.generate_for_project!(@project)
|
||||||
|
@time_entry1 = TimeEntry.generate!(:issue => @issue1,
|
||||||
|
:project => @project,
|
||||||
|
:activity => @non_billable_activity,
|
||||||
|
:spent_on => Date.today,
|
||||||
|
:hours => 20,
|
||||||
|
:user => @manager)
|
||||||
|
|
||||||
|
@rate = Rate.generate!(:project => @project,
|
||||||
|
:user => @manager,
|
||||||
|
:date_in_effect => Date.yesterday,
|
||||||
|
:amount => 100)
|
||||||
|
|
||||||
|
@deliverable1.issues << @issue1
|
||||||
|
|
||||||
|
assert_equal 1, @deliverable1.issues.count
|
||||||
|
|
||||||
|
visit_contract_page(@contract)
|
||||||
|
assert_select "table#deliverables" do
|
||||||
|
assert_select "td.overhead", :text => /2,000.00/
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user