Browse Source

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.
pull/55/head
MadeTech Dushan 3 years ago
parent
commit
e32779104c
  1. 4
      app/models/case_log.rb
  2. 4
      spec/fixtures/complete_case_log.json

4
app/models/case_log.rb

@ -105,6 +105,10 @@ private
dynamically_not_required << "other_reason_for_leaving_last_settled_home" dynamically_not_required << "other_reason_for_leaving_last_settled_home"
end end
if net_income.to_i == 0
dynamically_not_required << "net_income_frequency"
end
required.delete_if { |key, _value| dynamically_not_required.include?(key) } required.delete_if { |key, _value| dynamically_not_required.include?(key) }
end end
end end

4
spec/fixtures/complete_case_log.json vendored

@ -68,8 +68,8 @@
"property_major_repairs_date": "05/05/2020", "property_major_repairs_date": "05/05/2020",
"property_number_of_times_relet": 2, "property_number_of_times_relet": 2,
"property_wheelchair_accessible": true, "property_wheelchair_accessible": true,
"net_income": 1000, "net_income": 0,
"net_income_frequency": "Monthly", "net_income_frequency": null,
"net_income_uc_proportion": "Some", "net_income_uc_proportion": "Some",
"housing_benefit": "Universal Credit with housing element, but not Housing Benefit", "housing_benefit": "Universal Credit with housing element, but not Housing Benefit",
"rent_frequency": "Weekly", "rent_frequency": "Weekly",

Loading…
Cancel
Save