diff --git a/app/helpers/budget_helper.rb b/app/helpers/budget_helper.rb index b78cc19f7..65e7ea683 100644 --- a/app/helpers/budget_helper.rb +++ b/app/helpers/budget_helper.rb @@ -1,10 +1,4 @@ module BudgetHelper - def format_price(budget, number) - number_to_currency(number, - precision: 0, - locale: I18n.default_locale, - unit: budget.currency_symbol) - end def heading_name(heading) heading.present? ? heading.name : t("budget.headings.none") diff --git a/app/models/budget.rb b/app/models/budget.rb index 9c4f9e7e1..d1945bc61 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -42,5 +42,16 @@ class Budget < ActiveRecord::Base def heading_price(heading) heading_ids.include?(heading.id) ? heading.price : -1 end + + def formatted_amount(amount) + ActionController::Base.helpers.number_to_currency(amount, + precision: 0, + locale: I18n.default_locale, + unit: currency_symbol) + end + + def formatted_heading_price(heading) + formatted_ammount(heading_price(heading)) + end end diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 5f986cc82..a8ced8d49 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -203,6 +203,10 @@ class Budget budget.balloting? end + def formatted_price + budget.formatted_amount(price) + end + private def set_denormalized_ids diff --git a/app/views/budgets/ballot/_ballot.html.erb b/app/views/budgets/ballot/_ballot.html.erb index a6529306b..99fdcd5cd 100644 --- a/app/views/budgets/ballot/_ballot.html.erb +++ b/app/views/budgets/ballot/_ballot.html.erb @@ -28,7 +28,7 @@

<%= t("budgets.ballots.show.amount_spent") %> - <%= format_price(@budget, @ballot.amount_spent(@ballot.heading_for_group(group).id)) %> + <%= @budget.formatted_amount(@ballot.amount_spent(@ballot.heading_for_group(group).id))) %>

<% else %> @@ -47,9 +47,9 @@

<%= t("budgets.ballots.show.remaining", - amount_city: format_price(@budget, @ballot.amount_available(@ballot.heading_for_group(group)))).html_safe %> + amount_city: @budget.formatted_amount(@ballot.amount_available(@ballot.heading_for_group(group))))).html_safe %>

<% end %> - \ No newline at end of file + diff --git a/app/views/budgets/ballot/_investment.html.erb b/app/views/budgets/ballot/_investment.html.erb index db30e4167..7f2bafcb8 100644 --- a/app/views/budgets/ballot/_investment.html.erb +++ b/app/views/budgets/ballot/_investment.html.erb @@ -1,6 +1,6 @@
  • <%= link_to investment.title, budget_investment_path(@budget, investment) %> - <%= format_price(@budget, investment.price) %> + <%= investment.formatted_price %> <% if @budget.balloting? %> <%= link_to budget_ballot_line_path(@budget, id: investment.id), diff --git a/app/views/budgets/ballot/_investment_for_sidebar.html.erb b/app/views/budgets/ballot/_investment_for_sidebar.html.erb index d9b3d9e69..c172e6146 100644 --- a/app/views/budgets/ballot/_investment_for_sidebar.html.erb +++ b/app/views/budgets/ballot/_investment_for_sidebar.html.erb @@ -1,6 +1,6 @@
  • <%= investment.title %> - <%= format_price(@budget, investment.price) %> + <%= investment.formatted_price %> <% if @budget.balloting? %> <%= link_to budget_ballot_line_url(id: investment.id, diff --git a/app/views/budgets/ballot/_progress_bar.html.erb b/app/views/budgets/ballot/_progress_bar.html.erb index 58214bbb3..a01d8395e 100644 --- a/app/views/budgets/ballot/_progress_bar.html.erb +++ b/app/views/budgets/ballot/_progress_bar.html.erb @@ -1,5 +1,5 @@ - <%= format_price(@budget, @budget.heading_price(@heading)) %> + <%= @budget.formatted_heading_price(@heading) %>
    ">

    - <%= format_price(@budget, @ballot.amount_spent(@heading.id)) %> + <%= @budget.format_amount(@ballot.amount_spent(@heading.id)) %> <%= t("spending_proposals.index.available") %> - <%= format_price(@budget, @ballot.amount_available(@heading)) %> + <%= @budget.format_amount(@ballot.amount_available(@heading)) %>

    diff --git a/app/views/budgets/investments/_sidebar.html.erb b/app/views/budgets/investments/_sidebar.html.erb index d9981d6c7..baeb72bd6 100644 --- a/app/views/budgets/investments/_sidebar.html.erb +++ b/app/views/budgets/investments/_sidebar.html.erb @@ -13,7 +13,7 @@ <%= t("budget.investments.index.sidebar.voted_html", count: @ballot.investments.by_heading(@heading.id).count, - amount_spent: format_price(@budget, @ballot.amount_spent(@heading))) %> + amount_spent: @budget.format_amount(@ballot.amount_spent(@heading))) %>

    <% else %>