Introduces budget.translated_phase

This commit is contained in:
kikito
2016-12-06 17:52:14 +01:00
parent 350d79d20a
commit 5538c70931
2 changed files with 7 additions and 2 deletions

View File

@@ -14,10 +14,11 @@ class Budget < ActiveRecord::Base
has_many :groups, dependent: :destroy
has_many :headings, through: :groups
scope :open, -> { where.not(phase: "finished") }
scope :current, -> { where.not(phase: "finished") }
scope :finished, -> { where(phase: "finished") }
scope :valuating, -> { where(valuating: true) }
scope :accepting, -> { where(phase: "accepting") }
scope :balloting, -> { where(phase: "balloting") }
def on_hold?
phase == "on_hold"
@@ -43,6 +44,10 @@ class Budget < ActiveRecord::Base
heading_ids.include?(heading.id) ? heading.price : -1
end
def translated_phase
I18n.t "budget.phase.#{phase}"
end
def formatted_amount(amount)
ActionController::Base.helpers.number_to_currency(amount,
precision: 0,

View File

@@ -20,7 +20,7 @@
<%= link_to budget.name, budget %>
</td>
<td>
<%= t("budgets.phases.#{budget.phase}") %>
<%= budget.translated_phase %>
</td>
</tr>
<% end %>