diff --git a/app/models/case_log.rb b/app/models/case_log.rb
index db0e25069..29293d9a4 100644
--- a/app/models/case_log.rb
+++ b/app/models/case_log.rb
@@ -166,8 +166,8 @@ class CaseLog < ApplicationRecord
end
def has_hbrentshortfall?
- # 0: Yes
- !!hbrentshortfall&.zero?
+ # 1: Yes
+ hbrentshortfall == 1
end
def postcode_known?
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index 861c5e807..66d54e277 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -254,7 +254,7 @@ private
net_income_known: [0],
household_charge: [0],
is_carehome: [1],
- rent_shortfall: [0],
+ hbrentshortfall: [1],
net_income_value_check: [0],
}.freeze
@@ -278,7 +278,7 @@ private
net_income_known: [1],
household_charge: [1],
is_carehome: [0],
- rent_shortfall: [1],
+ hbrentshortfall: [2],
net_income_value_check: [1],
}.freeze
@@ -286,7 +286,7 @@ private
letting_in_sheltered_accommodation: [3],
underoccupation_benefitcap: [3],
reasonpref: [3],
- rent_shortfall: [1],
+ hbrentshortfall: [3],
layear: [7],
reason_for_leaving_last_settled_home: [32],
hb: [5],
diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb
index c42bc476e..4d80f7fb0 100644
--- a/app/services/imports/case_logs_import_service.rb
+++ b/app/services/imports/case_logs_import_service.rb
@@ -149,10 +149,11 @@ module Imports
# Required for our form invalidated questions (not present in import)
attributes["previous_la_known"] = attributes["prevloc"].nil? ? 0 : 1
- attributes["is_la_inferred"] = false # Always keep the given LA
+ attributes["is_la_inferred"] = attributes["postcode_full"].present?
attributes["first_time_property_let_as_social_housing"] = first_time_let(attributes["rsnvac"])
attributes["declaration"] = declaration(xml_doc)
+ # Set charges to 0 if others are partially populated
unless attributes["brent"].nil? &&
attributes["scharge"].nil? &&
attributes["pscharge"].nil? &&
@@ -163,10 +164,18 @@ module Imports
attributes["supcharg"] ||= BigDecimal("0.0")
end
+ # Handles confidential schemes
+ if attributes["postcode_full"] == "******"
+ attributes["postcode_known"] = 0
+ attributes["postcode_full"] = nil
+ end
+
+ previous_status = field_value(xml_doc, "meta", "status")
+
case_log = CaseLog.new(attributes)
save_case_log(case_log, attributes)
compute_differences(case_log, attributes)
- check_status_completed(case_log)
+ check_status_completed(case_log, previous_status)
end
def save_case_log(case_log, attributes)
@@ -190,8 +199,8 @@ module Imports
@logger.warn "Differences found when saving log #{case_log.id}: #{differences}" unless differences.empty?
end
- def check_status_completed(case_log)
- unless case_log.status == "completed"
+ def check_status_completed(case_log, previous_status)
+ if previous_status.include?("submitted") && case_log.status != "completed"
@logger.warn "Case log #{case_log.id} is not completed"
end
end
@@ -338,7 +347,7 @@ module Imports
end
def details_known(index, attributes)
- return nil if attributes["hhmemb"].present? && index > attributes["hhmemb"]
+ return nil if attributes["hhmemb"].nil? || index > attributes["hhmemb"]
if attributes["age#{index}_known"] == 1 &&
attributes["sex#{index}"] == "R" &&
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index 211c29433..4cb087fdf 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -5672,11 +5672,14 @@
"hint_text": "Also known as the ‘outstanding amount’.",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes"
},
- "1": {
+ "2": {
"value": "No"
+ },
+ "3": {
+ "value": "Don’t know"
}
}
}
@@ -5735,19 +5738,19 @@
"depends_on": [
{
"hb": 1,
- "hbrentshortfall": 0
+ "hbrentshortfall": 1
},
{
"hb": 6,
- "hbrentshortfall": 0
+ "hbrentshortfall": 1
},
{
"hb": 7,
- "hbrentshortfall": 0
+ "hbrentshortfall": 1
},
{
"hb": 8,
- "hbrentshortfall": 0
+ "hbrentshortfall": 1
}
]
}
diff --git a/docs/api/DLUHC-CORE-Data.v1.json b/docs/api/DLUHC-CORE-Data.v1.json
index dc709691b..d00ed85a2 100644
--- a/docs/api/DLUHC-CORE-Data.v1.json
+++ b/docs/api/DLUHC-CORE-Data.v1.json
@@ -359,7 +359,7 @@
"cbl": 1,
"chr": 1,
"cap": 0,
- "hbrentshortfall": 0,
+ "hbrentshortfall": 1,
"tshortfall": 12,
"reasonother": null,
"housingneeds_a": 1,
diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb
index 46e9171e7..2b1f780ac 100644
--- a/spec/factories/case_log.rb
+++ b/spec/factories/case_log.rb
@@ -115,7 +115,7 @@ FactoryBot.define do
la { "E09000003" }
prevloc { "E07000105" }
hb { 6 }
- hbrentshortfall { 0 }
+ hbrentshortfall { 1 }
tshortfall { 12 }
property_relet { 0 }
mrcdate { Time.utc(2020, 5, 0o5, 10, 36, 49) }
diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json
index d32fe927f..62d593be7 100644
--- a/spec/fixtures/complete_case_log.json
+++ b/spec/fixtures/complete_case_log.json
@@ -83,7 +83,7 @@
"cbl": 1,
"chr": 1,
"cap": 0,
- "hbrentshortfall": 0,
+ "hbrentshortfall": 1,
"tshortfall": 12,
"reasonother": null,
"housingneeds_a": 1,
diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml
index 27ec5eb92..1d712eed8 100644
--- a/spec/fixtures/exports/case_logs.xml
+++ b/spec/fixtures/exports/case_logs.xml
@@ -96,7 +96,7 @@
E09000003
E07000105
6
- 0
+ 1
0
2020-05-05 10:36:49 UTC
0
diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb
index 0ce9ac85f..840b2188e 100644
--- a/spec/models/case_log_spec.rb
+++ b/spec/models/case_log_spec.rb
@@ -298,7 +298,7 @@ RSpec.describe CaseLog do
context "when the tenant is not in receipt of applicable benefits" do
it "correctly resets total shortfall" do
- case_log.update!(wtshortfall: 100, hb: 9)
+ case_log.update!(hbrentshortfall: 2, wtshortfall: 100, hb: 9)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to be_nil
expect(record_from_db["wtshortfall"]).to be_nil
@@ -344,7 +344,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 2, hb: 1)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 100, period: 2, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(50.0)
expect(record_from_db["wtshortfall"]).to eq(50.0)
@@ -353,7 +353,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 2, hb: 6)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 100, period: 2, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(50.0)
expect(record_from_db["wtshortfall"]).to eq(50.0)
@@ -362,7 +362,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 100, period: 2, hb: 8)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 100, period: 2, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(50.0)
expect(record_from_db["wtshortfall"]).to eq(50.0)
@@ -425,7 +425,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 3, hb: 1)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 120, period: 3, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0)
@@ -434,7 +434,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 3, hb: 6)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 120, period: 3, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0)
@@ -443,7 +443,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 120, period: 3, hb: 8)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 120, period: 3, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0)
@@ -506,7 +506,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 1)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 4, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0)
@@ -515,7 +515,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 6)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 4, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0)
@@ -524,7 +524,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 4, hb: 8)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 4, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(30.0)
expect(record_from_db["wtshortfall"]).to eq(30.0)
@@ -587,7 +587,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 1)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 5, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(125.0)
expect(record_from_db["wtshortfall"]).to eq(125.0)
@@ -596,7 +596,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 6)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 5, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(125.0)
expect(record_from_db["wtshortfall"]).to eq(125.0)
@@ -605,7 +605,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 5, hb: 8)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 5, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(125.0)
expect(record_from_db["wtshortfall"]).to eq(125.0)
@@ -668,7 +668,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 1)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 6, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(122.5)
expect(record_from_db["wtshortfall"]).to eq(122.5)
@@ -677,7 +677,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 6)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 6, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(122.5)
expect(record_from_db["wtshortfall"]).to eq(122.5)
@@ -686,7 +686,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 6, hb: 8)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 6, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(122.5)
expect(record_from_db["wtshortfall"]).to eq(122.5)
@@ -749,7 +749,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 1)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 7, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(120.0)
expect(record_from_db["wtshortfall"]).to eq(120.0)
@@ -758,7 +758,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 6)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 7, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(120.0)
expect(record_from_db["wtshortfall"]).to eq(120.0)
@@ -767,7 +767,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 7, hb: 8)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 7, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(120.0)
expect(record_from_db["wtshortfall"]).to eq(120.0)
@@ -830,7 +830,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 1)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 8, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(117.5)
expect(record_from_db["wtshortfall"]).to eq(117.5)
@@ -839,7 +839,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 6)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 8, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(117.5)
expect(record_from_db["wtshortfall"]).to eq(117.5)
@@ -848,7 +848,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 8, hb: 8)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 8, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(117.5)
expect(record_from_db["wtshortfall"]).to eq(117.5)
@@ -911,7 +911,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 9, hb: 1)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 9, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(115.0)
expect(record_from_db["wtshortfall"]).to eq(115.0)
@@ -920,7 +920,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 9, hb: 6)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 9, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(115.0)
expect(record_from_db["wtshortfall"]).to eq(115.0)
@@ -929,7 +929,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 9, hb: 8)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 9, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(115.0)
expect(record_from_db["wtshortfall"]).to eq(115.0)
@@ -992,7 +992,7 @@ RSpec.describe CaseLog do
context "when the tenant has an outstanding amount after benefits" do
context "when tenant is in receipt of housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 1, hb: 1)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 1, hb: 1)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(130.0)
expect(record_from_db["wtshortfall"]).to eq(130.0)
@@ -1001,7 +1001,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of universal credit with housing element exc. housing benefit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 1, hb: 6)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 1, hb: 6)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(130.0)
expect(record_from_db["wtshortfall"]).to eq(130.0)
@@ -1010,7 +1010,7 @@ RSpec.describe CaseLog do
context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do
- case_log.update!(hbrentshortfall: 0, tshortfall: 130, period: 1, hb: 8)
+ case_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 1, hb: 8)
record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from case_logs where id=#{case_log.id}").to_a[0]
expect(case_log.wtshortfall).to eq(130.0)
expect(record_from_db["wtshortfall"]).to eq(130.0)
diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb
index 7f4eb438c..537986bf5 100644
--- a/spec/models/validations/financial_validations_spec.rb
+++ b/spec/models/validations/financial_validations_spec.rb
@@ -68,7 +68,7 @@ RSpec.describe Validations::FinancialValidations do
describe "outstanding rent amount validations" do
context "when outstanding rent or charges is no" do
it "validates that no shortfall is provided" do
- record.hbrentshortfall = 1
+ record.hbrentshortfall = 2
record.tshortfall = 99
financial_validator.validate_outstanding_rent_amount(record)
expect(record.errors["tshortfall"])
@@ -78,7 +78,7 @@ RSpec.describe Validations::FinancialValidations do
context "when outstanding rent or charges is yes" do
it "expects that a shortfall is provided" do
- record.hbrentshortfall = 0
+ record.hbrentshortfall = 1
record.tshortfall = 99
financial_validator.validate_outstanding_rent_amount(record)
expect(record.errors["tshortfall"]).to be_empty
@@ -111,7 +111,7 @@ RSpec.describe Validations::FinancialValidations do
describe "housing benefit rent shortfall validations" do
context "when shortfall is yes" do
it "validates that housing benefit is not none" do
- record.hbrentshortfall = 0
+ record.hbrentshortfall = 1
record.hb = 9
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"])
@@ -119,7 +119,7 @@ RSpec.describe Validations::FinancialValidations do
end
it "validates that housing benefit is not don't know" do
- record.hbrentshortfall = 0
+ record.hbrentshortfall = 1
record.hb = 3
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"])
@@ -127,7 +127,7 @@ RSpec.describe Validations::FinancialValidations do
end
it "validates that housing benefit is not Universal Credit without housing benefit" do
- record.hbrentshortfall = 0
+ record.hbrentshortfall = 1
record.hb = 7
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"])
@@ -135,7 +135,7 @@ RSpec.describe Validations::FinancialValidations do
end
it "validates that housing benefit is provided" do
- record.hbrentshortfall = 0
+ record.hbrentshortfall = 1
record.hb = 1
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"]).to be_empty
@@ -212,7 +212,7 @@ RSpec.describe Validations::FinancialValidations do
describe "rent and charges validations" do
context "when shortfall amount is provided" do
it "validates that basic rent is no less than double the shortfall" do
- record.hbrentshortfall = 1
+ record.hbrentshortfall = 2
record.tshortfall = 99.50
record.brent = 198
financial_validator.validate_rent_amount(record)
diff --git a/spec/services/imports/case_logs_import_service_spec.rb b/spec/services/imports/case_logs_import_service_spec.rb
index 801d1a065..9fc4e8734 100644
--- a/spec/services/imports/case_logs_import_service_spec.rb
+++ b/spec/services/imports/case_logs_import_service_spec.rb
@@ -28,6 +28,9 @@ RSpec.describe Imports::CaseLogsImportService do
.and_return(open_file(fixture_directory, case_log_id2), open_file(fixture_directory, case_log_id2))
# Stub the form handler to use the real form
allow(FormHandler.instance).to receive(:get_form).with(anything).and_return(real_2021_2022_form)
+
+ WebMock.stub_request(:get, /api.postcodes.io\/postcodes\/LS166FT/)
+ .to_return(status: 200, body: '{"status":200,"result":{"codes":{"admin_district":"E08000035"}}}', headers: {})
end
it "successfully create all case logs" do