diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index d1bab1056..cf7cd4cee 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -125,8 +125,8 @@ module Imports attributes["supcharg"] = safe_string_as_decimal(xml_doc, "Q18aiv") attributes["tcharge"] = safe_string_as_decimal(xml_doc, "Q18av") - attributes["hbrentshortfall"] = unsafe_string_as_integer(xml_doc, "Q18d") - attributes["tshortfall"] = tshortfall(xml_doc, attributes) + attributes["tshortfall"] = safe_string_as_decimal(xml_doc, "Q18dyes") + attributes["hbrentshortfall"] = hbshortfall(xml_doc, attributes) attributes["voiddate"] = compose_date(xml_doc, "VDAY", "VMONTH", "VYEAR") 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 end - def tshortfall(xml_doc, attributes) - shortfall = safe_string_as_decimal(xml_doc, "Q18dyes") - return 0 if shortfall.blank? && attributes["hbrentshortfall"] == 1 && overridden?(xml_doc, "xmlns", "Q18dyes") - - shortfall + def hbshortfall(xml_doc, attributes) + shortfall = unsafe_string_as_integer(xml_doc, "Q18d") + 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 + end end end end