Browse Source

validate general needs cannot be referred by LA (#1281)

pull/1278/head
Phil Lee 2 years ago committed by GitHub
parent
commit
f86544bfe6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/bulk_upload.rb
  2. 7
      app/services/bulk_upload/lettings/row_parser.rb
  3. 1
      config/locales/en.yml
  4. 19
      spec/services/bulk_upload/lettings/row_parser_spec.rb

4
app/models/bulk_upload.rb

@ -30,6 +30,10 @@ class BulkUpload < ApplicationRecord
end
end
def general_needs?
needstype == 1
end
private
def generate_identifier

7
app/services/bulk_upload/lettings/row_parser.rb

@ -147,6 +147,7 @@ class BulkUpload::Lettings::RowParser
validate :validate_nulls
validate :validate_relevant_collection_window
validate :validate_la_with_local_housing_referral
validate :validate_cannot_be_la_referral_if_general_needs
def valid?
errors.clear
@ -169,6 +170,12 @@ class BulkUpload::Lettings::RowParser
private
def validate_cannot_be_la_referral_if_general_needs
if field_78 == 4 && bulk_upload.general_needs?
errors.add :field_78, I18n.t("validations.household.referral.la_general_needs.prp_referred_by_la")
end
end
def validate_la_with_local_housing_referral
if field_78 == 3 && owning_organisation && owning_organisation.la?
errors.add(:field_78, I18n.t("validations.household.referral.nominated_by_local_ha_but_la"))

1
config/locales/en.yml

@ -359,6 +359,7 @@ en:
nominated_by_local_ha_but_la: The source of the referral cannot be Nominated by local housing authority as your organisation is a local authority
la_general_needs:
internal_transfer: "Answer cannot be internal transfer as it’s the same landlord on the tenancy agreement and the household had either a fixed-term or lifetime local authority general needs tenancy immediately before this letting"
prp_referred_by_la: "The source of the referral cannot be referred by local authority housing department for a general needs log"
prp:
local_housing_referral: "Answer cannot be ‘nominated by a local housing authority’ as a local authority is on the tenancy agreement"
homeless:

19
spec/services/bulk_upload/lettings/row_parser_spec.rb

@ -250,7 +250,7 @@ RSpec.describe BulkUpload::Lettings::RowParser do
end
end
describe "#field_78" do
describe "#field_78" do # referral
context "when 3 ie PRP nominated by LA and owning org is LA" do
let(:attributes) { { bulk_upload:, field_78: "3", field_111: owning_org.old_visible_id } }
@ -258,6 +258,23 @@ RSpec.describe BulkUpload::Lettings::RowParser do
expect(parser.errors[:field_78]).to be_present
end
end
context "when 4 ie referred by LA and is general needs" do
let(:attributes) { { bulk_upload:, field_78: "4" } }
it "is not permitted" do
expect(parser.errors[:field_78]).to be_present
end
end
context "when 4 ie referred by LA and is not general needs" do
let(:bulk_upload) { create(:bulk_upload, :lettings, user:, needstype: 2) }
let(:attributes) { { bulk_upload:, field_78: "4" } }
it "is permitted" do
expect(parser.errors[:field_78]).to be_blank
end
end
end
describe "fields 96, 97, 98 => startdate" do

Loading…
Cancel
Save