Browse Source

add void_date_value_check and fix some namings

pull/820/head
Kat 3 years ago
parent
commit
64e8fea52f
  1. 2
      app/models/validations/soft_validations.rb
  2. 3
      app/services/imports/case_logs_import_service.rb
  3. 23
      config/forms/2021_2022.json
  4. 23
      config/forms/2022_2023.json
  5. 3
      config/locales/en.yml
  6. 5
      db/migrate/20220808093035_add_void_date_value_check.rb
  7. 1
      db/schema.rb
  8. 2
      spec/factories/case_log.rb
  9. 4
      spec/models/validations/soft_validations_spec.rb

2
app/models/validations/soft_validations.rb

@ -66,7 +66,7 @@ module Validations::SoftValidations
mrcdate.present? && startdate.present? && mrcdate.between?(startdate.to_date - 3650, startdate.to_date - 730)
end
def voiddate_date_in_soft_range?
def voiddate_in_soft_range?
voiddate.present? && startdate.present? && voiddate.between?(startdate.to_date - 3650, startdate.to_date - 730)
end

3
app/services/imports/case_logs_import_service.rb

@ -210,6 +210,7 @@ module Imports
# Soft validations can become required answers, set them to yes by default
attributes["pregnancy_value_check"] = 0
attributes["major_repairs_date_value_check"] = 0
attributes["void_date_value_check"] = 0
attributes["retirement_value_check"] = 0
attributes["rent_value_check"] = 0
attributes["net_income_value_check"] = 0
@ -274,7 +275,7 @@ module Imports
end
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]
%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]
end
def check_status_completed(case_log, previous_status)

23
config/forms/2021_2022.json

@ -771,6 +771,29 @@
}
]
},
"void_date_value_check": {
"depends_on": [{ "voiddate_in_soft_range?": true }],
"title_text": {
"translation": "soft_validations.void_date.title_text"
},
"informative_text": {},
"questions": {
"void_date_value_check": {
"check_answer_label": "Void date soft validation",
"hidden_in_check_answers": true,
"header": "Are you sure the time between these dates is correct?",
"type": "interruption_screen",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
}
}
},
"new_build_handover_date": {
"header": "",
"description": "",

23
config/forms/2022_2023.json

@ -771,6 +771,29 @@
}
]
},
"void_date_value_check": {
"depends_on": [{ "voiddate_in_soft_range?": true }],
"title_text": {
"translation": "soft_validations.void_date.title_text"
},
"informative_text": {},
"questions": {
"void_date_value_check": {
"check_answer_label": "Void date soft validation",
"hidden_in_check_answers": true,
"header": "Are you sure the time between these dates is correct?",
"type": "interruption_screen",
"answer_options": {
"0": {
"value": "Yes"
},
"1": {
"value": "No"
}
}
}
}
},
"new_build_handover_date": {
"header": "",
"description": "",

3
config/locales/en.yml

@ -321,7 +321,8 @@ en:
females_not_in_soft_age_range: "You also told us that any female tenants living at the property are in the following age ranges:<ul><li>11 to 16</li><li>50 to 65</li></ul>"
major_repairs_date:
title_text: "You told us the time between the start of the tenancy and the major repairs completion date is more than 730 days"
hint_text: "Are you sure the time between these dates is correct?"
void_date:
title_text: "You told us the time between the start of the tenancy and the void date is more than 730 days"
devise:
two_factor_authentication:

5
db/migrate/20220808093035_add_void_date_value_check.rb

@ -0,0 +1,5 @@
class AddVoidDateValueCheck < ActiveRecord::Migration[7.0]
def change
add_column :case_logs, :void_date_value_check, :integer
end
end

1
db/schema.rb

@ -201,6 +201,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_08_10_152340) do
t.bigint "scheme_id"
t.bigint "location_id"
t.integer "major_repairs_date_value_check"
t.integer "void_date_value_check"
t.index ["created_by_id"], name: "index_case_logs_on_created_by_id"
t.index ["location_id"], name: "index_case_logs_on_location_id"
t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id"

2
spec/factories/case_log.rb

@ -110,6 +110,8 @@ FactoryBot.define do
rp_dontknow { 0 }
tenancyother { nil }
net_income_value_check { nil }
void_date_value_check { 1 }
major_repairs_date_value_check { 1 }
net_income_known { 0 }
previous_la_known { 1 }
property_owner_organisation { "Test" }

4
spec/models/validations/soft_validations_spec.rb

@ -226,14 +226,14 @@ RSpec.describe Validations::SoftValidations do
context "when the void date is within 10 years of the tenancy start date" do
it "shows the interruption screen" do
record.update!(startdate: Time.zone.local(2022, 2, 1), voiddate: Time.zone.local(2013, 2, 1))
expect(record.voiddate_date_in_soft_range?).to be true
expect(record.voiddate_in_soft_range?).to be true
end
end
context "when the void date is less than 2 years before the tenancy start date" do
it "does not show the interruption screen" do
record.update!(startdate: Time.zone.local(2022, 2, 1), voiddate: Time.zone.local(2021, 2, 1))
expect(record.voiddate_date_in_soft_range?).to be false
expect(record.voiddate_in_soft_range?).to be false
end
end
end

Loading…
Cancel
Save