Skip to content

Commit

Permalink
DNO rate parser: Cope with blank EHV band
Browse files Browse the repository at this point in the history
  • Loading branch information
tlocke committed Aug 9, 2024
1 parent db4c6f3 commit 38e8e9f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
9 changes: 8 additions & 1 deletion chellow/e/dno_rate_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,14 @@ def tab_ehv(sheet, gsp_rates):
llfc = None if llfc_val is None else str(llfc_val).strip()
if llfc not in (None, ""):
band_col = col_find(title_row, "residual")
band = "" if band_col is None else int(get_decimal(row, band_col))
if band_col is None:
band = 0
else:
band_val = get_value(row, band_col)
if band_val is None:
band = 0
else:
band = int(band_val)
tariffs[llfc] = {
"super-red-gbp-per-kwh": get_rate(
row, col_match(title_row, f"{polarity} super red")
Expand Down
37 changes: 37 additions & 0 deletions test/e/test_dno_rate_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,40 @@ def test_tab_ehv():
},
"super_red": [],
}


def test_tab_ehv_null_band():
wb = Workbook()
wb.create_sheet("Annex 2 EHV charges")
sheet = wb.worksheets[1]
sheet.insert_rows(0, 10)
sheet.insert_cols(0, 15)
sheet["A10"].value = "Import Unique Identifier"
sheet["B10"].value = "LLFC"
sheet["E10"].value = "LLFC"
sheet["H10"].value = "Residual Charging Band"
sheet["I10"].value = "Import Super Red unit charge (p/kWh)"
sheet["J10"].value = "Import fixed charge (p/day)"
sheet["K10"].value = "Import capacity charge (p/kVA/day)"
sheet["L10"].value = "Import exceeded capacity charge (p/kVA/day)"
sheet["B11"].value = "198"
sheet["H11"].value = None
sheet["I11"].value = "4.124"
sheet["J11"].value = "18767.69"
sheet["K11"].value = "1.40"
sheet["L11"].value = "1.40"

rates = {}
tab_ehv(sheet, rates)
assert rates == {
"tariffs": {
"198": {
"super-red-gbp-per-kwh": Decimal("0.04124"),
"gbp-per-mpan-per-day": Decimal("187.67690"),
"gbp-per-kva-per-day": Decimal("0.01400"),
"excess-gbp-per-kva-per-day": Decimal("0.01400"),
"description": "Designated EHV0",
}
},
"super_red": [],
}

0 comments on commit 38e8e9f

Please sign in to comment.