diff --git a/app/models/budget.rb b/app/models/budget.rb index 3f9822964..ae5bdf71e 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -61,5 +61,9 @@ class Budget < ActiveRecord::Base def formatted_heading_price(heading) formatted_amount(heading_price(heading)) end + + def formatted_heading_amount_spent(heading) + formatted_amount(amount_spent(heading)) + end end diff --git a/app/models/budget/ballot.rb b/app/models/budget/ballot.rb index fa7317dc8..79aa56ce7 100644 --- a/app/models/budget/ballot.rb +++ b/app/models/budget/ballot.rb @@ -16,12 +16,20 @@ class Budget investments.sum(:price).to_i end - def amount_spent(heading_id) - investments.by_heading(heading_id).sum(:price).to_i + def amount_spent(heading) + investments.by_heading(heading.id).sum(:price).to_i + end + + def formatted_amount_spent(heading) + budget.formatted_amount(amount_spent(heading)) end def amount_available(heading) - budget.heading_price(heading) - amount_spent(heading.id) + budget.heading_price(heading) - amount_spent(heading) + end + + def formatted_amount_available(heading) + budget.formatted_amount(amount_available(heading)) end def has_lines_in_group?(group) diff --git a/app/views/budgets/ballot/_ballot.html.erb b/app/views/budgets/ballot/_ballot.html.erb index 99fdcd5cd..7ed6851ae 100644 --- a/app/views/budgets/ballot/_ballot.html.erb +++ b/app/views/budgets/ballot/_ballot.html.erb @@ -28,7 +28,7 @@
- <%= @budget.format_amount(@ballot.amount_spent(@heading.id)) %> + <%= @ballot.formatted_amount_spent(@heading) %> <%= t("budget.progress_bar.available") %> - <%= @budget.format_amount(@ballot.amount_available(@heading)) %> + <%= @ballot.formatted_amount_available(@heading) %>
diff --git a/app/views/budgets/investments/_sidebar.html.erb b/app/views/budgets/investments/_sidebar.html.erb index baeb72bd6..5dc6c1aad 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: @budget.format_amount(@ballot.amount_spent(@heading))) %> + amount_spent: @ballot.formatted_amount_spent(@heading)) %> <% else %>