Browse Source

feat: improve currency interruption screen display

pull/1225/head
natdeanlewissoftwire 2 years ago
parent
commit
cdae8964c6
  1. 8
      app/helpers/interruption_screen_helper.rb
  2. 2
      app/models/form/sales/pages/about_price_shared_ownership_value_check.rb

8
app/helpers/interruption_screen_helper.rb

@ -7,10 +7,12 @@ module InterruptionScreenHelper
value = if argument["label"] value = if argument["label"]
pre_casing_value = lettings_log.form.get_question(argument["key"], lettings_log).answer_label(lettings_log) pre_casing_value = lettings_log.form.get_question(argument["key"], lettings_log).answer_label(lettings_log)
pre_casing_value.downcase pre_casing_value.downcase
elsif argument["currency"]
["£", ActionController::Base.helpers.number_to_currency(lettings_log.public_send(argument["key"]), delimiter: ",", format: "%n")].join("")
else else
lettings_log.public_send(argument["key"]) lettings_log.public_send(argument["key"])
end end
translation_params[argument["i18n_template"].to_sym] = argument["prefix"] == "£" ? "£#{ActionController::Base.helpers.number_to_currency(value, delimiter: ',', format: '%n')}" : value translation_params[argument["i18n_template"].to_sym] = value
end end
begin begin
@ -30,10 +32,12 @@ module InterruptionScreenHelper
arguments.each do |argument| arguments.each do |argument|
value = if argument["label"] value = if argument["label"]
lettings_log.form.get_question(argument["key"], lettings_log).answer_label(lettings_log).downcase lettings_log.form.get_question(argument["key"], lettings_log).answer_label(lettings_log).downcase
elsif argument["currency"]
["£", ActionController::Base.helpers.number_to_currency(lettings_log.public_send(argument["key"]), delimiter: ",", format: "%n")].join("")
else else
lettings_log.public_send(argument["key"]) lettings_log.public_send(argument["key"])
end end
translation_params[argument["i18n_template"].to_sym] = argument["prefix"] == "£" ? "£#{ActionController::Base.helpers.number_to_currency(value, delimiter: ',', format: '%n')}" : value translation_params[argument["i18n_template"].to_sym] = value
end end
I18n.t(title_text["translation"], **translation_params).to_s I18n.t(title_text["translation"], **translation_params).to_s
end end

2
app/models/form/sales/pages/about_price_shared_ownership_value_check.rb

@ -24,7 +24,7 @@ class Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck < ::Form::Page
"key" => "purchase_price_soft_min_or_soft_max", "key" => "purchase_price_soft_min_or_soft_max",
"label" => false, "label" => false,
"i18n_template" => "soft_min_or_soft_max", "i18n_template" => "soft_min_or_soft_max",
"prefix" => "£", "currency" => true,
}, },
{ {
"key" => "purchase_price_min_or_max_text", "key" => "purchase_price_min_or_max_text",

Loading…
Cancel
Save