Browse Source

Update field name across the codebase

pull/1532/head
Kat 3 years ago
parent
commit
577ad844ba
  1. 2
      app/models/derived_variables/sales_log_variables.rb
  2. 4
      app/models/form/sales/questions/leasehold_charges_known.rb
  3. 4
      app/models/sales_log.rb
  4. 2
      app/services/imports/sales_logs_import_service.rb
  5. 2
      spec/factories/sales_log.rb
  6. 2
      spec/models/form/sales/pages/leasehold_charges_spec.rb
  7. 4
      spec/models/form/sales/questions/leasehold_charges_known_spec.rb

2
app/models/derived_variables/sales_log_variables.rb

@ -1,7 +1,7 @@
module DerivedVariables::SalesLogVariables module DerivedVariables::SalesLogVariables
def set_derived_fields! def set_derived_fields!
self.ethnic = 17 if ethnic_refused? self.ethnic = 17 if ethnic_refused?
self.mscharge = nil if monthly_leasehold_charges_unknown? self.mscharge = nil if no_monthly_leasehold_charges?
if exdate.present? if exdate.present?
self.exday = exdate.day self.exday = exdate.day
self.exmonth = exdate.month self.exmonth = exdate.month

4
app/models/form/sales/questions/leasehold_charges_known.rb

@ -1,7 +1,7 @@
class Form::Sales::Questions::LeaseholdChargesKnown < ::Form::Question class Form::Sales::Questions::LeaseholdChargesKnown < ::Form::Question
def initialize(id, hsh, subsection, ownershipsch:) def initialize(id, hsh, subsection, ownershipsch:)
super(id, hsh, subsection) super(id, hsh, subsection)
@id = "mscharge_known" @id = "has_mscharge"
@check_answer_label = "Monthly leasehold charges known?" @check_answer_label = "Monthly leasehold charges known?"
@header = "Do you know the monthly leasehold charges for the property?" @header = "Do you know the monthly leasehold charges for the property?"
@hint_text = "For example, service and management charges" @hint_text = "For example, service and management charges"
@ -13,7 +13,7 @@ class Form::Sales::Questions::LeaseholdChargesKnown < ::Form::Question
@hidden_in_check_answers = { @hidden_in_check_answers = {
"depends_on" => [ "depends_on" => [
{ {
"mscharge_known" => 1, "has_mscharge" => 1,
}, },
], ],
} }

4
app/models/sales_log.rb

@ -292,8 +292,8 @@ class SalesLog < Log
companybuy == 1 companybuy == 1
end end
def monthly_leasehold_charges_unknown? def no_monthly_leasehold_charges?
mscharge_known&.zero? has_mscharge&.zero?
end end
def buyers_age_for_old_persons_shared_ownership_invalid? def buyers_age_for_old_persons_shared_ownership_invalid?

2
app/services/imports/sales_logs_import_service.rb

@ -107,7 +107,7 @@ module Imports
attributes["hhregresstill"] = still_serving(xml_doc) attributes["hhregresstill"] = still_serving(xml_doc)
attributes["proplen"] = safe_string_as_integer(xml_doc, "Q16aProplen2") || safe_string_as_integer(xml_doc, "Q16aProplensec2") attributes["proplen"] = safe_string_as_integer(xml_doc, "Q16aProplen2") || safe_string_as_integer(xml_doc, "Q16aProplensec2")
attributes["mscharge"] = monthly_charges(xml_doc, attributes) attributes["mscharge"] = monthly_charges(xml_doc, attributes)
attributes["mscharge_known"] = 1 if attributes["mscharge"].present? attributes["has_mscharge"] = 1 if attributes["mscharge"].present?
attributes["prevten"] = unsafe_string_as_integer(xml_doc, "Q6PrevTenure") attributes["prevten"] = unsafe_string_as_integer(xml_doc, "Q6PrevTenure")
attributes["mortlen"] = mortgage_length(xml_doc, attributes) attributes["mortlen"] = mortgage_length(xml_doc, attributes)
attributes["extrabor"] = borrowing(xml_doc, attributes) attributes["extrabor"] = borrowing(xml_doc, attributes)

2
spec/factories/sales_log.rb

@ -92,7 +92,7 @@ FactoryBot.define do
mortgageused { 1 } mortgageused { 1 }
wchair { 1 } wchair { 1 }
armedforcesspouse { 5 } armedforcesspouse { 5 }
mscharge_known { 1 } has_mscharge { 1 }
mscharge { 100 } mscharge { 100 }
mortlen { 10 } mortlen { 10 }
pcodenk { 1 } pcodenk { 1 }

2
spec/models/form/sales/pages/leasehold_charges_spec.rb

@ -12,7 +12,7 @@ RSpec.describe Form::Sales::Pages::LeaseholdCharges, type: :model do
end end
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[mscharge_known mscharge]) expect(page.questions.map(&:id)).to eq(%w[has_mscharge mscharge])
end end
it "has the correct id" do it "has the correct id" do

4
spec/models/form/sales/questions/leasehold_charges_known_spec.rb

@ -12,7 +12,7 @@ RSpec.describe Form::Sales::Questions::LeaseholdChargesKnown, type: :model do
end end
it "has the correct id" do it "has the correct id" do
expect(question.id).to eq("mscharge_known") expect(question.id).to eq("has_mscharge")
end end
it "has the correct header" do it "has the correct header" do
@ -52,7 +52,7 @@ RSpec.describe Form::Sales::Questions::LeaseholdChargesKnown, type: :model do
expect(question.hidden_in_check_answers).to eq({ expect(question.hidden_in_check_answers).to eq({
"depends_on" => [ "depends_on" => [
{ {
"mscharge_known" => 1, "has_mscharge" => 1,
}, },
], ],
}) })

Loading…
Cancel
Save