diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index c1a19ef93..508ddea90 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -893,10 +893,10 @@ private owning_organisation_id: [:field_1], managing_organisation_id: [:field_2], renewal: [:field_6], - scheme_id: [scheme_field], - scheme: [scheme_field], - location_id: [location_field], - location: [location_field], + scheme_id: (scheme_field.present? ? [scheme_field] : nil), + scheme: (scheme_field.present? ? [scheme_field] : nil), + location_id: (location_field.present? ? [location_field] : nil), + location: (location_field.present? ? [location_field] : nil), created_by: [:field_3], needstype: [:field_4], rent_type: %i[field_5 field_10 field_11], @@ -1040,7 +1040,7 @@ private address_line2: [:field_20], town_or_city: [:field_21], county: [:field_22], - } + }.compact end def attribute_set diff --git a/config/locales/en.yml b/config/locales/en.yml index 0c7d3c58f..ef28a05a3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -353,7 +353,7 @@ en: financial: tshortfall: outstanding_amount_not_expected: "You cannot answer the outstanding amount question if you don’t have outstanding rent or charges" - more_than_rent: "Enter a value less less than the basic rent amount" + more_than_rent: "Enter a value less than the basic rent amount" must_be_positive: "Enter a value over £0.01 as you told us there is an outstanding amount" hbrentshortfall: outstanding_amount_not_expected: "Answer must be ‘yes’ as you have answered the outstanding amount question" diff --git a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb index 63531deb5..04044655d 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -617,6 +617,24 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end end + context "when the rent range validation is triggered but the log has no scheme or location id" do + let(:attributes) do + setup_section_params.merge({ field_15: nil, + field_16: nil, + field_17: nil, + field_128: 300, + field_126: 1, + field_32: 1, + field_4: 1, + field_5: "3", + field_25: "E09000008" }) + end + + it "is not a valid row" do + expect(parser).not_to be_valid + end + end + context "when a hidden log already exists in db" do before do parser.log.status = "pending"