[#4648] Remove the overage from Profit calculations

This commit is contained in:
Eric Davis
2010-10-14 12:40:29 -07:00
parent 46a5aaeabe
commit 71c3d114ed
3 changed files with 6 additions and 13 deletions

View File

@@ -55,11 +55,12 @@ module ContractsHelper
spent_content = send(formatter, spent_value)
total_content = send(formatter, total_value)
reverse_overage = spent_field.to_s.match(/profit/i)
# Show overages except for profit fields
overage_css_class = overage_class(spent_value, total_value) unless spent_field.to_s.match(/profit/i)
show_field(object, spent_field, options.merge(:raw => true, :wrap_in_td => false)) do
content_tag(:td, h(spent_content), :class => "spent #{overage_class(spent_value, total_value, :reverse => reverse_overage)}") +
content_tag(:td, h(spent_content), :class => "spent #{overage_css_class}") +
content_tag(:td, h(total_content), :class => 'budget')
end
end
@@ -125,17 +126,11 @@ module ContractsHelper
end
# Overage occurs when spent is negative or spent is greater than budget
#
# :reverse - spent is reverse, it is overage when it's less than budget
def overage?(spent, budget, options={})
return false unless spent && budget
return true if spent < 0
if options[:reverse]
spent.to_f < budget.to_f
else
spent.to_f > budget.to_f
end
spent.to_f > budget.to_f
end
def overage_class(spent, budget, options={})

View File

@@ -107,7 +107,7 @@
<tr>
<td class="l"><%= l(:field_profit) %></td>
<td class="profit_spent <%= overage_class(deliverable.profit_left(validated_period), deliverable.profit_budget(validated_period), :reverse => true) %>">
<td class="profit_spent">
<%= h(format_value_field_for_contracts(deliverable.profit_left(validated_period))) %>
</td>
<td class="profit_total"><%= h(format_value_field_for_contracts(deliverable.profit_budget(validated_period))) %></td>

View File

@@ -481,17 +481,15 @@ class ContractsShowTest < ActionController::IntegrationTest
visit_contract_page(@contract)
# Overages on:
assert_select '.overage', :count => 14
assert_select '.overage', :count => 12
assert_select '.contract-labor .overage', :count => 2
assert_select '.contract-overhead .overage', :count => 2
assert_select '.contract-profit .overage'
assert_select '.contract-estimated-hour.total .overage'
assert_select '#deliverables .spent-amount.labor.overage'
assert_select '#deliverables .spent-amount.overhead.overage'
assert_select '#deliverables .labor_budget_spent.overage'
assert_select '#deliverables .overhead_budget_spent.overage'
assert_select '#deliverables .profit_spent.overage'
assert_select '#deliverables .labor_hours_spent .overage'
assert_select '#deliverables .overhead_hours_spent .overage'
assert_select '#deliverables .total_hours_spent .overage'