Browse Source

Merge branch 'main' into VisibleChildParentOrgIds

pull/2274/head
Rachael Booth 2 years ago committed by GitHub
parent
commit
a100252a40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      app/models/form/sales/questions/living_before_purchase_years.rb
  2. 5
      app/models/form/sales/questions/mortgage_length.rb
  3. 16
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  4. BIN
      public/files/2024_25_lettings_paper_form.pdf
  5. BIN
      public/files/bulk-upload-lettings-specification-2024-25.xlsx
  6. BIN
      public/files/bulk-upload-lettings-template-2024-25.xlsx
  7. 25
      spec/models/form/sales/questions/living_before_purchase_years_spec.rb
  8. 20
      spec/models/form/sales/questions/mortgage_length_spec.rb
  9. 10
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

5
app/models/form/sales/questions/living_before_purchase_years.rb

@ -10,7 +10,6 @@ class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question
@max = 80 @max = 80
@step = 1 @step = 1
@width = 5 @width = 5
@suffix = " years"
@ownershipsch = ownershipsch @ownershipsch = ownershipsch
@question_number = question_number @question_number = question_number
end end
@ -39,4 +38,8 @@ class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question
99 99
end end
end end
def suffix_label(log)
" #{'year'.pluralize(log[id])}"
end
end end

5
app/models/form/sales/questions/mortgage_length.rb

@ -9,7 +9,6 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question
@max = 60 @max = 60
@step = 1 @step = 1
@width = 5 @width = 5
@suffix = " years"
@hint_text = "You should round up to the nearest year. Value should not exceed 60 years." @hint_text = "You should round up to the nearest year. Value should not exceed 60 years."
@ownershipsch = ownershipsch @ownershipsch = ownershipsch
@question_number = question_number @question_number = question_number
@ -25,4 +24,8 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question
114 114
end end
end end
def suffix_label(log)
" #{'year'.pluralize(log[id])}"
end
end end

16
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -121,8 +121,8 @@ class BulkUpload::Lettings::Year2024::RowParser
field_115: "Was the letting made under the Accessible Register?", field_115: "Was the letting made under the Accessible Register?",
field_116: "What was the source of referral for this letting?", field_116: "What was the source of referral for this letting?",
field_117: "Do you know the household's combined total income after tax?", field_117: "Do you know the household's combined total income after tax?",
field_119: "How often does the household receive income?", field_118: "How often does the household receive income?",
field_118: "How much income does the household have in total?", field_119: "How much income does the household have in total?",
field_120: "Is the tenant likely to be receiving any of these housing-related benefits?", field_120: "Is the tenant likely to be receiving any of these housing-related benefits?",
field_121: "How much of the household's income is from Universal Credit, state pensions or benefits?", field_121: "How much of the household's income is from Universal Credit, state pensions or benefits?",
field_122: "Does the household pay rent or other charges for the accommodation?", field_122: "Does the household pay rent or other charges for the accommodation?",
@ -258,8 +258,8 @@ class BulkUpload::Lettings::Year2024::RowParser
attribute :field_115, :integer attribute :field_115, :integer
attribute :field_116, :integer attribute :field_116, :integer
attribute :field_117, :integer attribute :field_117, :integer
attribute :field_119, :integer attribute :field_118, :integer
attribute :field_118, :decimal attribute :field_119, :decimal
attribute :field_120, :integer attribute :field_120, :integer
attribute :field_121, :integer attribute :field_121, :integer
attribute :field_122, :integer attribute :field_122, :integer
@ -968,8 +968,8 @@ private
referral: %i[field_116], referral: %i[field_116],
net_income_known: %i[field_117], net_income_known: %i[field_117],
earnings: %i[field_118], incfreq: %i[field_118],
incfreq: %i[field_119], earnings: %i[field_119],
hb: %i[field_120], hb: %i[field_120],
benefits: %i[field_121], benefits: %i[field_121],
@ -1156,7 +1156,7 @@ private
attributes["net_income_known"] = net_income_known attributes["net_income_known"] = net_income_known
attributes["earnings"] = earnings attributes["earnings"] = earnings
attributes["incfreq"] = field_119 attributes["incfreq"] = field_118
attributes["hb"] = field_120 attributes["hb"] = field_120
attributes["benefits"] = field_121 attributes["benefits"] = field_121
@ -1442,7 +1442,7 @@ private
end end
def earnings def earnings
field_118.round if field_118.present? field_119.round if field_119.present?
end end
def tshortfall_known def tshortfall_known

BIN
public/files/2024_25_lettings_paper_form.pdf

Binary file not shown.

BIN
public/files/bulk-upload-lettings-specification-2024-25.xlsx

Binary file not shown.

BIN
public/files/bulk-upload-lettings-template-2024-25.xlsx

Binary file not shown.

25
spec/models/form/sales/questions/living_before_purchase_years_spec.rb

@ -5,6 +5,7 @@ RSpec.describe Form::Sales::Questions::LivingBeforePurchaseYears, type: :model d
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }
let(:start_date) { Time.utc(2024, 2, 8) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) } let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date:)) }
let(:page) { instance_double(Form::Page, subsection:) } let(:page) { instance_double(Form::Page, subsection:) }
@ -47,10 +48,6 @@ RSpec.describe Form::Sales::Questions::LivingBeforePurchaseYears, type: :model d
expect(question.step).to eq(1) expect(question.step).to eq(1)
end end
it "has correct suffix" do
expect(question.suffix).to eq(" years")
end
it "has correct min" do it "has correct min" do
expect(question.min).to eq(0) expect(question.min).to eq(0)
end end
@ -99,10 +96,6 @@ RSpec.describe Form::Sales::Questions::LivingBeforePurchaseYears, type: :model d
expect(question.step).to eq(1) expect(question.step).to eq(1)
end end
it "has correct suffix" do
expect(question.suffix).to eq(" years")
end
it "has correct min" do it "has correct min" do
expect(question.min).to eq(0) expect(question.min).to eq(0)
end end
@ -111,4 +104,20 @@ RSpec.describe Form::Sales::Questions::LivingBeforePurchaseYears, type: :model d
expect(question.max).to eq(80) expect(question.max).to eq(80)
end end
end end
context "when 1 year" do
let(:sales_log) { FactoryBot.build(:sales_log, proplen: 1) }
it "has correct suffix" do
expect(question.suffix_label(sales_log)).to eq(" year")
end
end
context "when multiple years" do
let(:sales_log) { FactoryBot.build(:sales_log, proplen: 5) }
it "has correct suffix" do
expect(question.suffix_label(sales_log)).to eq(" years")
end
end
end end

20
spec/models/form/sales/questions/mortgage_length_spec.rb

@ -41,10 +41,6 @@ RSpec.describe Form::Sales::Questions::MortgageLength, type: :model do
expect(question.width).to eq(5) expect(question.width).to eq(5)
end end
it "has correct suffix" do
expect(question.suffix).to eq(" years")
end
it "has correct min" do it "has correct min" do
expect(question.min).to eq(0) expect(question.min).to eq(0)
end end
@ -52,4 +48,20 @@ RSpec.describe Form::Sales::Questions::MortgageLength, type: :model do
it "has correct max" do it "has correct max" do
expect(question.max).to eq(60) expect(question.max).to eq(60)
end end
context "when 1 year" do
let(:sales_log) { FactoryBot.build(:sales_log, mortlen: 1) }
it "has correct suffix" do
expect(question.suffix_label(sales_log)).to eq(" year")
end
end
context "when multiple years" do
let(:sales_log) { FactoryBot.build(:sales_log, mortlen: 5) }
it "has correct suffix" do
expect(question.suffix_label(sales_log)).to eq(" years")
end
end
end end

10
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -206,8 +206,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
field_116: "2", field_116: "2",
field_117: "1", field_117: "1",
field_118: "2300", field_118: "2",
field_119: "2", field_119: "2300",
field_120: "1", field_120: "1",
field_121: "1", field_121: "1",
@ -1122,8 +1122,8 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
end end
describe "#field_112, 117, 118" do describe "#field_112, 117, 119" do
context "when none of field_112, 117, 118 are given" do context "when none of field_112, 117, 119 are given" do
let(:attributes) { { bulk_upload:, field_112: "", field_113: "", field_114: "", field_85: "1" } } let(:attributes) { { bulk_upload:, field_112: "", field_113: "", field_114: "", field_85: "1" } }
it "sets correct errors" do it "sets correct errors" do
@ -2117,7 +2117,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
describe "#earnings" do describe "#earnings" do
let(:attributes) { { bulk_upload:, field_118: "104.50" } } let(:attributes) { { bulk_upload:, field_119: "104.50" } }
it "rounds to the nearest whole pound" do it "rounds to the nearest whole pound" do
expect(parser.log.earnings).to eq(105) expect(parser.log.earnings).to eq(105)

Loading…
Cancel
Save