Skip to content

Commit

Permalink
i
Browse files Browse the repository at this point in the history
  • Loading branch information
tlocke committed Oct 22, 2024
1 parent 3c603b5 commit 13e1ea3
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions chellow/reports/report_g_monthly_duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,34 +93,27 @@ def _process_era(
f"Problem with virtual bill for g_supplier_contrat {contract.id}."
) from e

try:
gbp = bill["net_gbp"]
except KeyError:
gbp = 0
bill["problem"] += (
f"For the supply {ss.mprn} the virtual bill {bill} "
f"from the contract {contract.name} does not contain "
f"the net_gbp key."
)
try:
kwh = bill["kwh"]
except KeyError:
kwh = 0
bill["problem"] += (
f"For the supply {ss.mprn} the virtual bill "
f"{bill} from the contract {contract.name} does not "
f"contain the 'kwh' key."
)

summary_data = {
"kwh": kwh,
"gbp": gbp,
"kwh": 0,
"net_gbp": 0,
"vat_gbp": 0,
"gross_gbp": 0,
"billed_kwh": 0,
"billed_net_gbp": 0,
"billed_vat_gbp": 0,
"billed_gross_gbp": 0,
}

for key in ("kwh", "net_gbp", "vat_gbp", "gross_gbp"):
try:
summary_data[key] += bill[key]
except KeyError:
bill["problem"] += (
f"For the supply {ss.mprn} the virtual bill {bill} "
f"from the contract {contract.name} does not contain "
f"the {key} key."
)

associated_site_codes = {
s.site.code for s in g_era.site_g_eras if not s.is_physical
}
Expand Down Expand Up @@ -249,7 +242,9 @@ def content(scenario_props, user_id, compression, now, base_name):
]
summary_titles = [
"kwh",
"gbp",
"net_gbp",
"vat_gbp",
"gross_gbp",
"billed_kwh",
"billed_net_gbp",
"billed_vat_gbp",
Expand Down Expand Up @@ -315,7 +310,9 @@ def content(scenario_props, user_id, compression, now, base_name):
"creation_date": now,
"month": month_start,
"kwh": 0,
"gbp": 0,
"net_gbp": 0,
"vat_gbp": 0,
"gross_gbp": 0,
"billed_kwh": 0,
"billed_net_gbp": 0,
"billed_vat_gbp": 0,
Expand All @@ -337,7 +334,9 @@ def content(scenario_props, user_id, compression, now, base_name):
"associated_site_codes": linked_sites,
"month": month_finish,
"kwh": 0,
"gbp": 0,
"net_gbp": 0,
"vat_gbp": 0,
"gross_gbp": 0,
"billed_kwh": 0,
"billed_net_gbp": 0,
"billed_vat_gbp": 0,
Expand Down

0 comments on commit 13e1ea3

Please sign in to comment.