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.
This commit is contained in:
@@ -57,10 +57,6 @@ module ApplicationHelper
|
|||||||
SiteCustomization::ContentBlock.block_for(name, locale)
|
SiteCustomization::ContentBlock.block_for(name, locale)
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_price(number)
|
|
||||||
number_to_currency(number, precision: 0, locale: I18n.locale)
|
|
||||||
end
|
|
||||||
|
|
||||||
def kaminari_path(url)
|
def kaminari_path(url)
|
||||||
"#{root_url.chomp("\/")}#{url}"
|
"#{root_url.chomp("\/")}#{url}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<% if results_type == :compatible %>
|
<% if results_type == :compatible %>
|
||||||
<th scope="col" class="text-right">
|
<th scope="col" class="text-right">
|
||||||
<small><%= t("budgets.results.amount_available") %></small><br>
|
<small><%= t("budgets.results.amount_available") %></small><br>
|
||||||
<%= format_price(heading_price) %><br>
|
<%= @budget.formatted_amount(heading_price) %><br>
|
||||||
</th>
|
</th>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -53,12 +53,12 @@
|
|||||||
<%= investment.ballot_lines_count %>
|
<%= investment.ballot_lines_count %>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<%= format_price investment.price %>
|
<%= @budget.formatted_amount(investment.price) %>
|
||||||
</td>
|
</td>
|
||||||
<% if results_type == :compatible %>
|
<% if results_type == :compatible %>
|
||||||
<td class="small text-right"
|
<td class="small text-right"
|
||||||
title="<%= format_price(amount_available) %> - <%= format_price(investment.price) %>">
|
title="<%= @budget.formatted_amount(amount_available) %> - <%= @budget.formatted_amount(investment.price) %>">
|
||||||
<%= format_price amount_available - investment.price %>
|
<%= @budget.formatted_amount(amount_available - investment.price) %>
|
||||||
<% amount_available -= investment.price if investment.winner? %>
|
<% amount_available -= investment.price if investment.winner? %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user