Browse Source

enable currency formatting of numbers for inserting into informative_text or title_text

pull/1101/head
Arthur Campbell 3 years ago
parent
commit
428eae8c8f
  1. 3
      app/models/form/sales/pages/buyer1_income_value_check.rb
  2. 3
      app/models/form/sales/pages/buyer2_income_value_check.rb
  3. 4
      app/models/log.rb
  4. 8
      app/models/sales_log.rb
  5. 2
      config/locales/en.yml

3
app/models/form/sales/pages/buyer1_income_value_check.rb

@ -10,7 +10,8 @@ class Form::Sales::Pages::Buyer1IncomeValueCheck < ::Form::Page
"translation" => "soft_validations.income.under_soft_min_for_economic_status",
"arguments" => [
{
"key" => "income1",
"key" => "field_formatted_as_currency",
"arguments_for_public_send" => "income1",
"i18n_template" => "income",
},
{

3
app/models/form/sales/pages/buyer2_income_value_check.rb

@ -13,7 +13,8 @@ class Form::Sales::Pages::Buyer2IncomeValueCheck < ::Form::Page
"translation" => "soft_validations.income.under_soft_min_for_economic_status",
"arguments" => [
{
"key" => "income2",
"key" => "field_formatted_as_currency",
"arguments_for_public_send" => "income2",
"i18n_template" => "income",
},
{

4
app/models/log.rb

@ -143,4 +143,8 @@ private
self[is_inferred_key] = false
self[postcode_key] = nil
end
def format_as_currency(num_string)
ActionController::Base.helpers.number_to_currency(num_string, unit: "£")
end
end

8
app/models/sales_log.rb

@ -254,6 +254,12 @@ class SalesLog < Log
return unless ALLOWED_INCOME_RANGES_SALES
ALLOWED_INCOME_RANGES_SALES[economic_status_code]&.soft_min
soft_min = ALLOWED_INCOME_RANGES_SALES[economic_status_code]&.soft_min
format_as_currency(soft_min)
end
def field_formatted_as_currency(field_name)
field_value = public_send(field_name)
format_as_currency(field_value)
end
end

2
config/locales/en.yml

@ -459,7 +459,7 @@ en:
in_soft_max_range:
message: "Net income is higher than expected based on the lead tenant’s working situation. Are you sure this is correct?"
income:
under_soft_min_for_economic_status: "You said income was £%{income}, which is below this working situation's minimum (£%{minimum})"
under_soft_min_for_economic_status: "You said income was %{income}, which is below this working situation's minimum (%{minimum})"
rent:
outside_range_title: "You told us the rent is %{brent}"
min_hint_text: "The minimum rent expected for this type of property in this local authority is £%{soft_min_for_period}."

Loading…
Cancel
Save