Browse Source

Confirm soft validations when importing

pull/1912/head
Kat 3 years ago
parent
commit
ed669fa73e
  1. 5
      app/services/imports/lettings_logs_import_service.rb
  2. 135
      config/forms/2022_2023.json
  3. 41
      spec/services/imports/lettings_logs_import_service_spec.rb

5
app/services/imports/lettings_logs_import_service.rb

@ -243,6 +243,9 @@ module Imports
attributes["net_income_value_check"] = 0 attributes["net_income_value_check"] = 0
attributes["carehome_charges_value_check"] = 0 attributes["carehome_charges_value_check"] = 0
attributes["referral_value_check"] = 0 attributes["referral_value_check"] = 0
attributes["scharge_value_check"] = 0
attributes["pscharge_value_check"] = 0
attributes["supcharg_value_check"] = 0
# Sets the log creator # Sets the log creator
owner_id = meta_field_value(xml_doc, "owner-user-id").strip owner_id = meta_field_value(xml_doc, "owner-user-id").strip
@ -402,7 +405,7 @@ module Imports
end end
def fields_not_present_in_softwire_data def fields_not_present_in_softwire_data
%w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check major_repairs_date_value_check void_date_value_check carehome_charges_value_check referral_value_check housingneeds_type housingneeds_other created_by uprn_known uprn_confirmed] %w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check major_repairs_date_value_check void_date_value_check carehome_charges_value_check referral_value_check scharge_value_check pscharge_value_check supcharg_value_check housingneeds_type housingneeds_other created_by uprn_known uprn_confirmed]
end end
def check_status_completed(lettings_log, previous_status) def check_status_completed(lettings_log, previous_status)

135
config/forms/2022_2023.json

@ -8364,6 +8364,141 @@
}, },
"interruption_screen_question_ids": ["brent", "startdate", "la", "beds", "rent_type", "needstype"] "interruption_screen_question_ids": ["brent", "startdate", "la", "beds", "rent_type", "needstype"]
}, },
"scharge_value_check": {
"depends_on": [
{
"scharge_over_soft_max?": true
}
],
"title_text": {
"translation": "soft_validations.scharge.over_soft_max_title",
"arguments": [
{
"key": "scharge",
"label": true,
"i18n_template": "scharge"
}
]
},
"informative_text": {},
"questions": {
"scharge_value_check": {
"check_answer_label": "Service charge confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"scharge_value_check": 0
},
{
"scharge_value_check": 1
}
]
},
"header": "Are you sure?",
"hint_text": "This is higher than we would expect. Check:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>",
"type": "interruption_screen",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
}
},
"interruption_screen_question_ids": ["period", "needstype", "scharge"]
},
"pscharge_value_check": {
"depends_on": [
{
"pscharge_over_soft_max?": true
}
],
"title_text": {
"translation": "soft_validations.pscharge.over_soft_max_title",
"arguments": [
{
"key": "pscharge",
"label": true,
"i18n_template": "pscharge"
}
]
},
"informative_text": {},
"questions": {
"pscharge_value_check": {
"check_answer_label": "Personal service charge confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"pscharge_value_check": 0
},
{
"pscharge_value_check": 1
}
]
},
"header": "Are you sure?",
"hint_text": "This is higher than we would expect. Check:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>",
"type": "interruption_screen",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
}
},
"interruption_screen_question_ids": ["period", "needstype", "pscharge"]
},
"supcharg_value_check": {
"depends_on": [
{
"supcharg_over_soft_max?": true
}
],
"title_text": {
"translation": "soft_validations.supcharg.over_soft_max_title",
"arguments": [
{
"key": "supcharg",
"label": true,
"i18n_template": "supcharg"
}
]
},
"informative_text": {},
"questions": {
"supcharg_value_check": {
"check_answer_label": "Personal service charge confirmation",
"hidden_in_check_answers": {
"depends_on": [
{
"supcharg_value_check": 0
},
{
"supcharg_value_check": 1
}
]
},
"header": "Are you sure?",
"hint_text": "This is higher than we would expect. Check:<ul class=\"govuk-body-l app-panel--interruption\"><li>the decimal point</li><li>the frequency, for example every week or every calendar month</li><li>the rent type is correct, for example affordable or social rent</li></ul>",
"type": "interruption_screen",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
}
},
"interruption_screen_question_ids": ["period", "needstype", "supcharg"]
},
"outstanding": { "outstanding": {
"header": "", "header": "",
"description": "", "description": "",

41
spec/services/imports/lettings_logs_import_service_spec.rb

@ -891,7 +891,7 @@ RSpec.describe Imports::LettingsLogsImportService do
context "and pscharge is out of range" do context "and pscharge is out of range" do
before do before do
lettings_log_xml.at_xpath("//xmlns:Q17").content = "1" lettings_log_xml.at_xpath("//xmlns:Q17").content = "1"
lettings_log_xml.at_xpath("//xmlns:Q18aiii").content = "36" lettings_log_xml.at_xpath("//xmlns:Q18aiii").content = "701"
end end
it "intercepts the relevant validation error" do it "intercepts the relevant validation error" do
@ -914,7 +914,7 @@ RSpec.describe Imports::LettingsLogsImportService do
context "and supcharg is out of range" do context "and supcharg is out of range" do
before do before do
lettings_log_xml.at_xpath("//xmlns:Q17").content = "1" lettings_log_xml.at_xpath("//xmlns:Q17").content = "1"
lettings_log_xml.at_xpath("//xmlns:Q18aiv").content = "46" lettings_log_xml.at_xpath("//xmlns:Q18aiv").content = "801"
end end
it "intercepts the relevant validation error" do it "intercepts the relevant validation error" do
@ -937,7 +937,7 @@ RSpec.describe Imports::LettingsLogsImportService do
context "and scharge is out of range" do context "and scharge is out of range" do
before do before do
lettings_log_xml.at_xpath("//xmlns:Q17").content = "1" lettings_log_xml.at_xpath("//xmlns:Q17").content = "1"
lettings_log_xml.at_xpath("//xmlns:Q18aii").content = "156" lettings_log_xml.at_xpath("//xmlns:Q18aii").content = "801"
end end
it "intercepts the relevant validation error" do it "intercepts the relevant validation error" do
@ -2068,5 +2068,40 @@ RSpec.describe Imports::LettingsLogsImportService do
expect(lettings_log.status).to eq("completed") expect(lettings_log.status).to eq("completed")
end end
end end
context "and the scharge/pscharge/supcharg soft validations are triggered" do
let(:lettings_log_id) { "00d2343e-d5fa-4c89-8400-ec3854b0f2b4" }
let(:lettings_log_file) { open_file(fixture_directory, lettings_log_id) }
let(:lettings_log_xml) { Nokogiri::XML(lettings_log_file) }
around do |example|
Timecop.freeze(Time.zone.local(2023, 4, 1)) do
Singleton.__init__(FormHandler)
example.run
end
Timecop.return
Singleton.__init__(FormHandler)
end
before do
lettings_log_xml.at_xpath("//xmlns:AddressLine1").content = "address 1"
lettings_log_xml.at_xpath("//xmlns:TownCity").content = "towncity"
lettings_log_xml.at_xpath("//xmlns:DAY").content = "10"
lettings_log_xml.at_xpath("//xmlns:MONTH").content = "4"
lettings_log_xml.at_xpath("//xmlns:YEAR").content = "2023"
lettings_log_xml.at_xpath("//xmlns:P1Nat").content = "18"
lettings_log_xml.at_xpath("//xmlns:Q17").content = "1"
lettings_log_xml.at_xpath("//xmlns:Q18aii").content = "800"
lettings_log_xml.at_xpath("//xmlns:Q18aiii").content = "300"
lettings_log_xml.at_xpath("//xmlns:Q18aiv").content = "300"
end
it "completes the log" do
lettings_log_service.send(:create_log, lettings_log_xml)
lettings_log = LettingsLog.find_by(old_id: lettings_log_id)
expect(lettings_log.status).to eq("completed")
end
end
end end
end end

Loading…
Cancel
Save