Browse Source

Merge 65beeee8e9 into c54204af53

pull/3181/merge
Samuel Young 2 days ago committed by GitHub
parent
commit
7c5e38fa59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 29
      app/services/bulk_upload/lettings/year2025/row_parser.rb
  2. 29
      app/services/bulk_upload/lettings/year2026/row_parser.rb
  3. 31
      app/services/bulk_upload/sales/year2025/row_parser.rb
  4. 31
      app/services/bulk_upload/sales/year2026/row_parser.rb
  5. 9
      spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb
  6. 11
      spec/services/bulk_upload/lettings/year2026/row_parser_spec.rb
  7. 9
      spec/services/bulk_upload/sales/year2025/row_parser_spec.rb
  8. 9
      spec/services/bulk_upload/sales/year2026/row_parser_spec.rb

29
app/services/bulk_upload/lettings/year2025/row_parser.rb

@ -148,6 +148,26 @@ class BulkUpload::Lettings::Year2025::RowParser
ERROR_BASE_KEY = "validations.lettings.2025.bulk_upload".freeze
CASE_INSENSITIVE_FIELDS = [
:field_42, # What is the lead tenant’s age?
:field_48, # What is person 2’s age?
:field_52, # What is person 3’s age?
:field_56, # What is person 4’s age?
:field_60, # What is person 5’s age?
:field_64, # What is person 6’s age?
:field_68, # What is person 7’s age?
:field_72, # What is person 8’s age?
:field_43, # Which of these best describes the lead tenant’s gender identity?
:field_49, # Which of these best describes person 2’s gender identity?
:field_53, # Which of these best describes person 3’s gender identity?
:field_57, # Which of these best describes person 4’s gender identity?
:field_61, # Which of these best describes person 5’s gender identity?
:field_65, # Which of these best describes person 6’s gender identity?
:field_69, # Which of these best describes person 7’s gender identity?
:field_73, # Which of these best describes person 8’s gender identity?
].freeze
attribute :bulk_upload
attribute :block_log_creation, :boolean, default: -> { false }
@ -459,6 +479,8 @@ class BulkUpload::Lettings::Year2025::RowParser
return @valid = true if blank_row?
normalise_case_insensitive_fields
super(:before_log)
@before_errors = errors.dup
@ -560,6 +582,13 @@ class BulkUpload::Lettings::Year2025::RowParser
private
def normalise_case_insensitive_fields
CASE_INSENSITIVE_FIELDS.each do |field|
value = send(field)
send("#{field}=", value.upcase) if value.present?
end
end
def validate_valid_radio_option
log.attributes.each do |question_id, _v|
question = log.form.get_question(question_id, log)

29
app/services/bulk_upload/lettings/year2026/row_parser.rb

@ -173,6 +173,26 @@ class BulkUpload::Lettings::Year2026::RowParser
ERROR_BASE_KEY = "validations.lettings.2026.bulk_upload".freeze
CASE_INSENSITIVE_FIELDS = [
:field_42, # What is the lead tenant’s age?
:field_48, # What is person 2’s age?
:field_52, # What is person 3’s age?
:field_56, # What is person 4’s age?
:field_60, # What is person 5’s age?
:field_64, # What is person 6’s age?
:field_68, # What is person 7’s age?
:field_72, # What is person 8’s age?
:field_130, # What is the lead tenant's sex?
:field_131, # What is person 2's sex?
:field_132, # What is person 3's sex?
:field_133, # What is person 4's sex?
:field_134, # What is person 5's sex?
:field_135, # What is person 6's sex?
:field_136, # What is person 7's sex?
:field_137, # What is person 8's sex?
].freeze
attribute :bulk_upload
attribute :block_log_creation, :boolean, default: -> { false }
@ -509,6 +529,8 @@ class BulkUpload::Lettings::Year2026::RowParser
return @valid = true if blank_row?
normalise_case_insensitive_fields
super(:before_log)
@before_errors = errors.dup
@ -615,6 +637,13 @@ class BulkUpload::Lettings::Year2026::RowParser
private
def normalise_case_insensitive_fields
CASE_INSENSITIVE_FIELDS.each do |field|
value = send(field)
send("#{field}=", value.upcase) if value.present?
end
end
def validate_valid_radio_option
log.attributes.each do |question_id, _v|
question = log.form.get_question(question_id, log)

31
app/services/bulk_upload/sales/year2025/row_parser.rb

@ -139,6 +139,28 @@ class BulkUpload::Sales::Year2025::RowParser
ERROR_BASE_KEY = "validations.sales.2025.bulk_upload".freeze
CASE_INSENSITIVE_FIELDS = [
:field_28, # Age of buyer 1
:field_35, # Age of person 2
:field_43, # Age of person 3
:field_47, # Age of person 4
:field_51, # Age of person 5
:field_55, # Age of person 6
:field_29, # Gender identity of buyer 1
:field_36, # Gender identity of person 2
:field_44, # Gender identity of person 3
:field_48, # Gender identity of person 4
:field_52, # Gender identity of person 5
:field_56, # Gender identity of person 6
:field_64, # What was buyer 2’s previous tenure?
:field_75, # What is the total amount the buyers had in savings before they paid any deposit for the property?
:field_70, # What is buyer 1’s gross annual income?
:field_72, # What is buyer 2’s gross annual income?
].freeze
attribute :bulk_upload
attribute :block_log_creation, :boolean, default: -> { false }
@ -454,6 +476,8 @@ class BulkUpload::Sales::Year2025::RowParser
return true if blank_row?
normalise_case_insensitive_fields
super(:before_log)
@before_errors = errors.dup
@ -525,6 +549,13 @@ class BulkUpload::Sales::Year2025::RowParser
private
def normalise_case_insensitive_fields
CASE_INSENSITIVE_FIELDS.each do |field|
value = send(field)
send("#{field}=", value.upcase) if value.present?
end
end
def prevtenbuy2
case field_64
when "R"

31
app/services/bulk_upload/sales/year2026/row_parser.rb

@ -146,6 +146,28 @@ class BulkUpload::Sales::Year2026::RowParser
ERROR_BASE_KEY = "validations.sales.2026.bulk_upload".freeze
CASE_INSENSITIVE_FIELDS = [
:field_28, # Age of buyer 1
:field_35, # Age of person 2
:field_43, # Age of person 3
:field_47, # Age of person 4
:field_51, # Age of person 5
:field_55, # Age of person 6
:field_122, # Buyer 1's sex, as registered at birth
:field_123, # Buyer/Person 2's sex, as registered at birth
:field_124, # Person 3's sex, as registered at birth
:field_125, # Person 4's sex, as registered at birth
:field_126, # Person 5's sex, as registered at birth
:field_127, # Person 6's sex, as registered at birth
:field_64, # What was buyer 2’s previous tenure?
:field_75, # What is the total amount the buyers had in savings before they paid any deposit for the property?
:field_70, # What is buyer 1’s gross annual income?
:field_72, # What is buyer 2’s gross annual income?
].freeze
attribute :bulk_upload
attribute :block_log_creation, :boolean, default: -> { false }
@ -468,6 +490,8 @@ class BulkUpload::Sales::Year2026::RowParser
return true if blank_row?
normalise_case_insensitive_fields
super(:before_log)
@before_errors = errors.dup
@ -540,6 +564,13 @@ class BulkUpload::Sales::Year2026::RowParser
private
def normalise_case_insensitive_fields
CASE_INSENSITIVE_FIELDS.each do |field|
value = send(field)
send("#{field}=", value.upcase) if value.present?
end
end
def prevtenbuy2
case field_64
when "R"

9
spec/services/bulk_upload/lettings/year2025/row_parser_spec.rb

@ -541,6 +541,15 @@ RSpec.describe BulkUpload::Lettings::Year2025::RowParser do
end
end
end
context "and case insensitive fields are set to lowercase" do
let(:case_insensitive_fields) { %w[field_42 field_48 field_52 field_56 field_60 field_64 field_68 field_72 field_43 field_49 field_53 field_57 field_61 field_65 field_69 field_73] }
let(:attributes) { valid_attributes.merge(case_insensitive_fields.each_with_object({}) { |field, h| h[field.to_sym] = valid_attributes[field.to_sym]&.downcase }) }
it "is still valid" do
expect(parser).to be_valid
end
end
end
context "when valid row with valid decimal (integer) field_11" do

11
spec/services/bulk_upload/lettings/year2026/row_parser_spec.rb

@ -151,7 +151,7 @@ RSpec.describe BulkUpload::Lettings::Year2026::RowParser do
field_15: "1",
field_42: "42",
field_48: "41",
field_48: "R",
field_52: "17",
field_56: "18",
field_60: "16",
@ -569,6 +569,15 @@ RSpec.describe BulkUpload::Lettings::Year2026::RowParser do
end
end
end
context "and case insensitive fields are set to lowercase" do
let(:case_insensitive_fields) { %w[field_42 field_48 field_52 field_56 field_60 field_64 field_68 field_72 field_130 field_131 field_132 field_133 field_134 field_135 field_136 field_137] }
let(:attributes) { valid_attributes.merge(case_insensitive_fields.each_with_object({}) { |field, h| h[field.to_sym] = valid_attributes[field.to_sym]&.downcase }) }
it "is still valid" do
expect(parser).to be_valid
end
end
end
context "when valid row with valid decimal (integer) field_11" do

9
spec/services/bulk_upload/sales/year2025/row_parser_spec.rb

@ -292,6 +292,15 @@ RSpec.describe BulkUpload::Sales::Year2025::RowParser do
expect(questions.map(&:id).size).to eq(0)
expect(questions.map(&:id)).to eql([])
end
context "and case insensitive fields are set to lowercase" do
let(:case_insensitive_fields) { %w[field_28 field_35 field_43 field_47 field_51 field_55 field_29 field_36 field_44 field_48 field_52 field_56 field_58 field_64 field_75 field_70 field_72] }
let(:attributes) { valid_attributes.merge(case_insensitive_fields.each_with_object({}) { |field, h| h[field.to_sym] = valid_attributes[field.to_sym]&.downcase }) }
it "is still valid" do
expect(parser).to be_valid
end
end
end
describe "#validate_nulls" do

9
spec/services/bulk_upload/sales/year2026/row_parser_spec.rb

@ -298,6 +298,15 @@ RSpec.describe BulkUpload::Sales::Year2026::RowParser do
expect(questions.map(&:id).size).to eq(0)
expect(questions.map(&:id)).to eql([])
end
context "and case insensitive fields are set to lowercase" do
let(:case_insensitive_fields) { %w[field_28 field_35 field_43 field_47 field_51 field_55 field_122 field_123 field_124 field_125 field_126 field_127 field_58 field_64 field_75 field_70 field_72] }
let(:attributes) { valid_attributes.merge(case_insensitive_fields.each_with_object({}) { |field, h| h[field.to_sym] = valid_attributes[field.to_sym]&.downcase }) }
it "is still valid" do
expect(parser).to be_valid
end
end
end
describe "#validate_nulls" do

Loading…
Cancel
Save