Skip to content

Commit

Permalink
i
Browse files Browse the repository at this point in the history
  • Loading branch information
tlocke committed Oct 15, 2024
1 parent 2a134df commit 018c74c
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions chellow/gas/bill_parser_total_edi.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,15 @@ def _process_CCD2(elements, headers):
units_billed = to_decimal(nuct) / units_divisor
breakdown[key] += units_billed

if tpref == "standing" or "start_date" not in headers:
headers["start_date"] = to_date(csdt[0])
start_date = to_date(csdt[0])
if start_date is not None and (tpref == "standing" or "start_date" not in headers):
headers["start_date"] = start_date

if tpref == "standing" or "finish_date" not in headers:
headers["finish_date"] = _to_finish_date(cedt[0])
finish_date = _to_finish_date(cedt[0])
if finish_date is not None and (
tpref == "standing" or "finish_date" not in headers
):
headers["finish_date"] = finish_date

mprn = mloc[0]
if "mprn" not in headers and len(mprn) > 0:
Expand Down Expand Up @@ -192,11 +196,15 @@ def _process_CCD3(elements, headers):
units_billed = to_decimal(nuct) / units_divisor
breakdown[key] += units_billed

if tpref == "standing" or "start_date" not in headers:
headers["start_date"] = to_date(csdt[0])
start_date = to_date(csdt[0])
if start_date is not None and (tpref == "standing" or "start_date" not in headers):
headers["start_date"] = start_date

if tpref == "standing" or "finish_date" not in headers:
headers["finish_date"] = _to_finish_date(cedt[0])
finish_date = _to_finish_date(cedt[0])
if finish_date is not None and (
tpref == "standing" or "finish_date" not in headers
):
headers["finish_date"] = finish_date

mprn = mloc[0]
if "mprn" not in headers and len(mprn) > 0:
Expand Down Expand Up @@ -265,6 +273,9 @@ def _process_MTR(elements, headers):
else:
mprn = g_era.g_supply.mprn

start_date = headers["start_date"]
if "finish_date" not in headers:
finish_date = start_date
return {
"raw_lines": "\n".join(headers["raw_lines"]),
"mprn": mprn,
Expand All @@ -277,8 +288,8 @@ def _process_MTR(elements, headers):
"vat_gbp": headers["vat"],
"gross_gbp": headers["gross"],
"bill_type_code": headers["bill_type_code"],
"start_date": headers["start_date"],
"finish_date": headers["finish_date"],
"start_date": start_date,
"finish_date": finish_date,
"issue_date": headers["issue_date"],
}

Expand Down

0 comments on commit 018c74c

Please sign in to comment.