diff --git a/app/helpers/contracts_helper.rb b/app/helpers/contracts_helper.rb index fe931a6..318d857 100644 --- a/app/helpers/contracts_helper.rb +++ b/app/helpers/contracts_helper.rb @@ -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 diff --git a/app/views/contracts/show.html.erb b/app/views/contracts/show.html.erb index 7891f8d..df434b1 100644 --- a/app/views/contracts/show.html.erb +++ b/app/views/contracts/show.html.erb @@ -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'}) %> diff --git a/app/views/deliverables/_details_row.html.erb b/app/views/deliverables/_details_row.html.erb index 949b0f1..e41d9f0 100644 --- a/app/views/deliverables/_details_row.html.erb +++ b/app/views/deliverables/_details_row.html.erb @@ -73,12 +73,14 @@ <% end %> + <% if show_markup_for?(deliverable, validated_period) %> <%= l(:field_markup) %> <%= h(format_value_field_for_contracts(deliverable.fixed_markup_budget_total_spent(validated_period))) %> <%= h(format_value_field_for_contracts(deliverable.fixed_markup_budget_total(validated_period))) %> + <% end %> Profit diff --git a/test/integration/contracts_show_test.rb b/test/integration/contracts_show_test.rb index bb3dccd..b517695 100644 --- a/test/integration/contracts_show_test.rb +++ b/test/integration/contracts_show_test.rb @@ -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'