Browse Source

CLDC-1218: Fix hbrentshortfall import (#558)

* Infer hbrentshortfall not known if tshortfall not provided and overridden

* Reorder import
pull/619/head
baarkerlounger 3 years ago committed by baarkerlounger
parent
commit
d17075fc44
  1. 16
      app/services/imports/case_logs_import_service.rb

16
app/services/imports/case_logs_import_service.rb

@ -125,8 +125,8 @@ module Imports
attributes["supcharg"] = safe_string_as_decimal(xml_doc, "Q18aiv") attributes["supcharg"] = safe_string_as_decimal(xml_doc, "Q18aiv")
attributes["tcharge"] = safe_string_as_decimal(xml_doc, "Q18av") attributes["tcharge"] = safe_string_as_decimal(xml_doc, "Q18av")
attributes["hbrentshortfall"] = unsafe_string_as_integer(xml_doc, "Q18d") attributes["tshortfall"] = safe_string_as_decimal(xml_doc, "Q18dyes")
attributes["tshortfall"] = tshortfall(xml_doc, attributes) attributes["hbrentshortfall"] = hbshortfall(xml_doc, attributes)
attributes["voiddate"] = compose_date(xml_doc, "VDAY", "VMONTH", "VYEAR") attributes["voiddate"] = compose_date(xml_doc, "VDAY", "VMONTH", "VYEAR")
attributes["mrcdate"] = compose_date(xml_doc, "MRCDAY", "MRCMONTH", "MRCYEAR") attributes["mrcdate"] = compose_date(xml_doc, "MRCDAY", "MRCMONTH", "MRCYEAR")
@ -520,11 +520,15 @@ module Imports
((2..8).map { |x| string_or_nil(xml_doc, "P#{x}Rel") } + [string_or_nil(xml_doc, "P1Sex")]).compact ((2..8).map { |x| string_or_nil(xml_doc, "P#{x}Rel") } + [string_or_nil(xml_doc, "P1Sex")]).compact
end end
def tshortfall(xml_doc, attributes) def hbshortfall(xml_doc, attributes)
shortfall = safe_string_as_decimal(xml_doc, "Q18dyes") shortfall = unsafe_string_as_integer(xml_doc, "Q18d")
return 0 if shortfall.blank? && attributes["hbrentshortfall"] == 1 && overridden?(xml_doc, "xmlns", "Q18dyes") if attributes["tshortfall"].blank? && shortfall == 1 && overridden?(xml_doc, "xmlns", "Q18dyes")
# If they have said there is a shortfall but then not entered one, and that has been
# manually overridden we instead infer that they actually didn't know whether there is a shortfall.
3
else
shortfall shortfall
end end
end end
end end
end

Loading…
Cancel
Save