Browse Source

correct minor bug found in PO

pull/1448/head
Arthur Campbell 3 years ago
parent
commit
18690ceae2
  1. 4
      app/models/derived_variables/sales_log_variables.rb
  2. 2
      app/models/form/sales/questions/leasehold_charges_known.rb
  3. 4
      app/models/sales_log.rb
  4. 2
      spec/models/form/sales/questions/leasehold_charges_known_spec.rb

4
app/models/derived_variables/sales_log_variables.rb

@ -1,6 +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?
if exdate.present? if exdate.present?
self.exday = exdate.day self.exday = exdate.day
self.exmonth = exdate.month self.exmonth = exdate.month
@ -12,9 +13,6 @@ module DerivedVariables::SalesLogVariables
self.hoyear = hodate.year self.hoyear = hodate.year
end end
self.deposit = value if outright_sale? && mortgage_not_used? self.deposit = value if outright_sale? && mortgage_not_used?
if mscharge_known.present? && mscharge_known.zero?
self.mscharge = 0
end
if mortgage_not_used? if mortgage_not_used?
self.mortgage = 0 self.mortgage = 0
end end

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

@ -3,7 +3,7 @@ class Form::Sales::Questions::LeaseholdChargesKnown < ::Form::Question
super(id, hsh, subsection) super(id, hsh, subsection)
@id = "mscharge_known" @id = "mscharge_known"
@check_answer_label = "Monthly leasehold charges known?" @check_answer_label = "Monthly leasehold charges known?"
@header = "Does the property have any monthly leasehold charges?" @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"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS

4
app/models/sales_log.rb

@ -299,6 +299,10 @@ class SalesLog < Log
companybuy == 1 companybuy == 1
end end
def monthly_leasehold_charges_unknown?
mscharge_known&.zero?
end
def buyers_age_for_old_persons_shared_ownership_invalid? def buyers_age_for_old_persons_shared_ownership_invalid?
return unless old_persons_shared_ownership? return unless old_persons_shared_ownership?

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

@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Questions::LeaseholdChargesKnown, type: :model do
end end
it "has the correct header" do it "has the correct header" do
expect(question.header).to eq("Does the property have any monthly leasehold charges?") expect(question.header).to eq("Do you know the monthly leasehold charges for the property?")
end end
it "has the correct check_answer_label" do it "has the correct check_answer_label" do

Loading…
Cancel
Save