From e32779104c3928ebef3ef5240d3cf3a4cb11f44a Mon Sep 17 00:00:00 2001 From: MadeTech Dushan Date: Wed, 20 Oct 2021 16:01:29 +0100 Subject: [PATCH] Make net income frequency not required dynamically No errors need to be added if the net income is given as 0 but no frequency is provided. It just needs to be made not required if the net income is refused (given as 0) so that the record can still be added. --- app/models/case_log.rb | 4 ++++ spec/fixtures/complete_case_log.json | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 9a84c633e..ae16a4945 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -105,6 +105,10 @@ private dynamically_not_required << "other_reason_for_leaving_last_settled_home" end + if net_income.to_i == 0 + dynamically_not_required << "net_income_frequency" + end + required.delete_if { |key, _value| dynamically_not_required.include?(key) } end end diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index da2e0da20..050246722 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -68,8 +68,8 @@ "property_major_repairs_date": "05/05/2020", "property_number_of_times_relet": 2, "property_wheelchair_accessible": true, - "net_income": 1000, - "net_income_frequency": "Monthly", + "net_income": 0, + "net_income_frequency": null, "net_income_uc_proportion": "Some", "housing_benefit": "Universal Credit with housing element, but not Housing Benefit", "rent_frequency": "Weekly",