From 6e843730b074b097f59808dba9038e96b5a252bc Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 8 Mar 2018 13:26:36 +0100 Subject: [PATCH] Replace format_price for Budget#formatted_amount ApplicationHelper#format_price and Budget#formatted_amount has the same objective and code, but the Budget#formatted_amount method also uses the currency of the Budget to correctly give currencies format. By replacing usage of format_price with formatted_amount we can remove format_price and have a single location for currency format logic. --- app/helpers/application_helper.rb | 4 ---- app/views/budgets/results/_results_table.html.erb | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c676b052d..486759e03 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -57,10 +57,6 @@ module ApplicationHelper SiteCustomization::ContentBlock.block_for(name, locale) end - def format_price(number) - number_to_currency(number, precision: 0, locale: I18n.locale) - end - def kaminari_path(url) "#{root_url.chomp("\/")}#{url}" end diff --git a/app/views/budgets/results/_results_table.html.erb b/app/views/budgets/results/_results_table.html.erb index ebd3c2b15..48983a858 100644 --- a/app/views/budgets/results/_results_table.html.erb +++ b/app/views/budgets/results/_results_table.html.erb @@ -21,7 +21,7 @@ <% if results_type == :compatible %> <%= t("budgets.results.amount_available") %>
- <%= format_price(heading_price) %>
+ <%= @budget.formatted_amount(heading_price) %>
<% end %> @@ -53,12 +53,12 @@ <%= investment.ballot_lines_count %> - <%= format_price investment.price %> + <%= @budget.formatted_amount(investment.price) %> <% if results_type == :compatible %> - <%= format_price amount_available - investment.price %> + title="<%= @budget.formatted_amount(amount_available) %> - <%= @budget.formatted_amount(investment.price) %>"> + <%= @budget.formatted_amount(amount_available - investment.price) %> <% amount_available -= investment.price if investment.winner? %> <% end %>