Browse Source

Set tshortfall to 0 if it should exists but is not provided

pull/550/head
Kat 3 years ago
parent
commit
3e5cc0acd3
  1. 9
      app/services/imports/case_logs_import_service.rb
  2. 2
      spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml

9
app/services/imports/case_logs_import_service.rb

@ -125,7 +125,7 @@ module Imports
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["voiddate"] = compose_date(xml_doc, "VDAY", "VMONTH", "VYEAR")
attributes["mrcdate"] = compose_date(xml_doc, "MRCDAY", "MRCMONTH", "MRCYEAR")
@ -513,5 +513,12 @@ module Imports
def people_with_details(xml_doc)
((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
shortfall
end
end
end

2
spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml vendored

@ -166,7 +166,7 @@
<Q18aiv override-field=""/>
<Q18av override-field="">438.11</Q18av>
<Q18d>1 Yes</Q18d>
<Q18dyes override-field="">7.00</Q18dyes>
<Q18dyes override-field="true"/>
<Q19void>2021-09-30</Q19void>
<Q19repair/>
<Q20 override-field="">0</Q20>

Loading…
Cancel
Save