diff --git a/app/models/case_log.rb b/app/models/case_log.rb
index b6db3cb73..13e65a5e1 100644
--- a/app/models/case_log.rb
+++ b/app/models/case_log.rb
@@ -243,7 +243,8 @@ private
def reset_derived_questions
dependent_questions = { layear: [{ key: :renewal, value: 0 }],
homeless: [{ key: :renewal, value: 0 }],
- referral: [{ key: :renewal, value: 0 }] }
+ referral: [{ key: :renewal, value: 0 }],
+ underoccupation_benefitcap: [{ key: :renewal, value: 0 }] }
dependent_questions.each do |dependent, conditions|
condition_key = conditions.first[:key]
@@ -299,13 +300,14 @@ private
self.underoccupation_benefitcap = 3 if renewal == 1 && year == 2021
self.ethnic = ethnic || ethnic_group
if is_renewal?
+ self.underoccupation_benefitcap = 2 if year == 2021
self.homeless = 2
self.referral = 0
self.layear = 1
- end
- if is_general_needs?
- self.prevten = 32 if managing_organisation.provider_type == "PRP"
- self.prevten = 30 if managing_organisation.provider_type == "LA"
+ if is_general_needs?
+ self.prevten = 32 if managing_organisation.provider_type == "PRP"
+ self.prevten = 30 if managing_organisation.provider_type == "LA"
+ end
end
end
diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml
index 15d9f0300..249d52c4f 100644
--- a/spec/fixtures/exports/case_logs.xml
+++ b/spec/fixtures/exports/case_logs.xml
@@ -10,7 +10,7 @@
F
2
4
- 32
+ 6
0
2
32
diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb
index 2f7c85c44..44672f89d 100644
--- a/spec/models/case_log_spec.rb
+++ b/spec/models/case_log_spec.rb
@@ -623,8 +623,8 @@ RSpec.describe CaseLog do
it "correctly derives and saves underoccupation_benefitcap if year is 2021" do
record_from_db = ActiveRecord::Base.connection.execute("select underoccupation_benefitcap from case_logs where id=#{case_log.id}").to_a[0]
- expect(record_from_db["underoccupation_benefitcap"]).to eq(3)
- expect(case_log["underoccupation_benefitcap"]).to eq(3)
+ expect(record_from_db["underoccupation_benefitcap"]).to eq(2)
+ expect(case_log["underoccupation_benefitcap"]).to eq(2)
end
it "correctly derives and saves prevten" do