[#4557] Hide markup displays when it's 0

This commit is contained in:
Eric Davis
2010-09-23 11:11:50 -07:00
parent 7bc31d6be0
commit 83e3023d85
4 changed files with 19 additions and 2 deletions

View File

@@ -128,4 +128,19 @@ module ContractsHelper
return period
end
end
# Should the markup be display?
#
# On Contracts and Deliverables, markup is hidden if both the spent
# and budget is 0.
def show_markup_for?(object, date=nil)
if object.is_a?(Contract)
!(object.fixed_markup_spent == 0 && object.fixed_markup_budget == 0)
elsif object.is_a?(Deliverable)
!(object.fixed_markup_budget_total_spent(date) == 0 && object.fixed_markup_budget_total(date) == 0)
else
true
end
end
end

View File

@@ -44,7 +44,9 @@
<%= show_budget_field(resource, :labor_spent, :labor_budget, :format => :format_value_field_for_contracts, :html_options => {:class => 'contract-labor'}, :label_html_options => {:width => '46%'}) %>
<%= show_budget_field(resource, :overhead_spent, :overhead_budget, :format => :format_value_field_for_contracts, :html_options => {:class => 'contract-overhead'}) %>
<%= show_budget_field(resource, :fixed_spent, :fixed_budget, :format => :format_value_field_for_contracts, :html_options => {:class => 'contract-fixed'}) %>
<% if show_markup_for?(resource) %>
<%= show_budget_field(resource, :fixed_markup_spent, :fixed_markup_budget, :format => :format_value_field_for_contracts, :html_options => {:class => 'contract-markup'}) %>
<% end %>
<%= show_budget_field(resource, :profit_spent, :profit_budget, :format => :format_value_field_for_contracts, :html_options => {:class => 'contract-profit'}) %>
<%= show_budget_field(resource, :discount_spent, :discount_budget, :format => :format_value_field_for_contracts, :html_options => {:class => 'contract-discount'}) %>

View File

@@ -73,12 +73,14 @@
</tr>
<% end %>
<% if show_markup_for?(deliverable, validated_period) %>
<tr>
<td class="l"><%= l(:field_markup) %></td>
<td class="fixed_markup_budget_spent"><%= h(format_value_field_for_contracts(deliverable.fixed_markup_budget_total_spent(validated_period))) %></td>
<td class="fixed_markup_budget_total"><%= h(format_value_field_for_contracts(deliverable.fixed_markup_budget_total(validated_period))) %></td>
<td></td>
</tr>
<% end %>
<tr>
<td class="l">Profit</td>

View File

@@ -52,8 +52,6 @@ class ContractsShowTest < ActionController::IntegrationTest
assert_select '.contract-overhead .budget'
assert_select '.contract-fixed .spent'
assert_select '.contract-fixed .budget'
assert_select '.contract-markup .spent'
assert_select '.contract-markup .budget'
assert_select '.contract-profit .spent'
assert_select '.contract-profit .budget'
assert_select '.contract-discount .spent'