chellow 1723041465.0.0__py3-none-any.whl → 1723459091.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chellow might be problematic. Click here for more details.
- chellow/e/computer.py +22 -22
- chellow/e/dno_rate_parser.py +8 -1
- chellow/e/scenario.py +68 -68
- chellow/e/views.py +8 -8
- chellow/models.py +40 -28
- chellow/reports/report_109.py +6 -5
- chellow/reports/report_247.py +146 -151
- chellow/reports/report_59.py +134 -87
- chellow/templates/e/csv_sites_hh_data.html +2 -2
- chellow/templates/e/em_months.html +18 -18
- chellow/templates/e/scenario_docs.html +6 -6
- chellow/templates/site.html +2 -2
- chellow/templates/site_months.html +18 -18
- chellow/views.py +11 -11
- {chellow-1723041465.0.0.dist-info → chellow-1723459091.0.0.dist-info}/METADATA +1 -1
- {chellow-1723041465.0.0.dist-info → chellow-1723459091.0.0.dist-info}/RECORD +17 -17
- {chellow-1723041465.0.0.dist-info → chellow-1723459091.0.0.dist-info}/WHEEL +0 -0
chellow/reports/report_109.py
CHANGED
|
@@ -66,7 +66,8 @@ def content(contract_id, end_year, end_month, months, user):
|
|
|
66
66
|
or_(Era.finish_date == null(), Era.finish_date >= start_date),
|
|
67
67
|
Era.start_date <= finish_date,
|
|
68
68
|
or_(
|
|
69
|
-
Source.code.in_(("gen", "gen-
|
|
69
|
+
Source.code.in_(("gen", "gen-grid")),
|
|
70
|
+
Era.exp_mpan_core != null(),
|
|
70
71
|
),
|
|
71
72
|
)
|
|
72
73
|
.distinct()
|
|
@@ -153,7 +154,7 @@ def content(contract_id, end_year, end_month, months, user):
|
|
|
153
154
|
"channel.era_id = era.id and era.supply_id = "
|
|
154
155
|
"supply.id and supply.source_id = source.id and "
|
|
155
156
|
"channel.channel_type = 'ACTIVE' and not "
|
|
156
|
-
"(source.code = '
|
|
157
|
+
"(source.code = 'grid' and channel.imp_related "
|
|
157
158
|
"is true) and hh_datum.start_date >= "
|
|
158
159
|
":month_start and hh_datum.start_date "
|
|
159
160
|
"<= :month_finish and "
|
|
@@ -181,17 +182,17 @@ def content(contract_id, end_year, end_month, months, user):
|
|
|
181
182
|
gen_breakdown = {}
|
|
182
183
|
exported = 0
|
|
183
184
|
while hh_start == hh_date:
|
|
184
|
-
if not imp_related and source_code in ("
|
|
185
|
+
if not imp_related and source_code in ("grid", "gen-grid"):
|
|
185
186
|
exported += hh_val
|
|
186
187
|
if (imp_related and source_code == "gen") or (
|
|
187
|
-
not imp_related and source_code == "gen-
|
|
188
|
+
not imp_related and source_code == "gen-grid"
|
|
188
189
|
):
|
|
189
190
|
gen_breakdown[gen_type_code] = (
|
|
190
191
|
gen_breakdown.setdefault(gen_type_code, 0) + hh_val
|
|
191
192
|
)
|
|
192
193
|
|
|
193
194
|
if (not imp_related and source_code == "gen") or (
|
|
194
|
-
imp_related and source_code == "gen-
|
|
195
|
+
imp_related and source_code == "gen-grid"
|
|
195
196
|
):
|
|
196
197
|
gen_breakdown[gen_type_code] = (
|
|
197
198
|
gen_breakdown.setdefault(gen_type_code, 0) - hh_val
|
chellow/reports/report_247.py
CHANGED
|
@@ -80,6 +80,42 @@ def make_bill_row(titles, bill):
|
|
|
80
80
|
return [bill.get(t) for t in titles]
|
|
81
81
|
|
|
82
82
|
|
|
83
|
+
def _add_bills(month_data, era, bills, chunk_start, chunk_finish):
|
|
84
|
+
for bill in bills:
|
|
85
|
+
contract = bill.batch.contract
|
|
86
|
+
bill_role_code = contract.market_role.code
|
|
87
|
+
bill_start = bill.start_date
|
|
88
|
+
bill_finish = bill.finish_date
|
|
89
|
+
bill_duration = (bill_finish - bill_start).total_seconds() + (30 * 60)
|
|
90
|
+
overlap_duration = (
|
|
91
|
+
min(bill_finish, chunk_finish) - max(bill_start, chunk_start)
|
|
92
|
+
).total_seconds() + (30 * 60)
|
|
93
|
+
proportion = overlap_duration / bill_duration
|
|
94
|
+
bill_prop_kwh = proportion * float(bill.kwh)
|
|
95
|
+
bill_prop_net_gbp = proportion * float(bill.net)
|
|
96
|
+
bill_prop_vat_gbp = proportion * float(bill.vat)
|
|
97
|
+
bill_prop_gross_gbp = proportion * float(bill.gross)
|
|
98
|
+
if bill_role_code == "X":
|
|
99
|
+
role_name = "supplier"
|
|
100
|
+
polarity = "export" if contract == era.exp_supplier_contract else "import"
|
|
101
|
+
elif bill_role_code == "C":
|
|
102
|
+
role_name = "dc"
|
|
103
|
+
polarity = "import"
|
|
104
|
+
elif bill_role_code == "M":
|
|
105
|
+
role_name = "mop"
|
|
106
|
+
polarity = "import"
|
|
107
|
+
else:
|
|
108
|
+
raise BadRequest("Role code not recognized.")
|
|
109
|
+
|
|
110
|
+
month_data[f"billed-{polarity}-kwh"] += bill_prop_kwh
|
|
111
|
+
month_data[f"billed-{polarity}-net-gbp"] += bill_prop_net_gbp
|
|
112
|
+
month_data[f"billed-{polarity}-vat-gbp"] += bill_prop_vat_gbp
|
|
113
|
+
month_data[f"billed-{polarity}-gross-gbp"] += bill_prop_gross_gbp
|
|
114
|
+
month_data[f"billed-{role_name}-{polarity}-net-gbp"] += bill_prop_net_gbp
|
|
115
|
+
month_data[f"billed-{role_name}-{polarity}-vat-gbp"] += bill_prop_vat_gbp
|
|
116
|
+
month_data[f"billed-{role_name}-{polarity}-gross-gbp"] += bill_prop_gross_gbp
|
|
117
|
+
|
|
118
|
+
|
|
83
119
|
def _process_site(
|
|
84
120
|
sess,
|
|
85
121
|
report_context,
|
|
@@ -125,8 +161,8 @@ def _process_site(
|
|
|
125
161
|
if imp_mpan_core == "displaced":
|
|
126
162
|
month_data = {}
|
|
127
163
|
for sname in (
|
|
128
|
-
"import-
|
|
129
|
-
"export-
|
|
164
|
+
"import-grid",
|
|
165
|
+
"export-grid",
|
|
130
166
|
"import-gen",
|
|
131
167
|
"export-gen",
|
|
132
168
|
"import-3rd-party",
|
|
@@ -134,13 +170,17 @@ def _process_site(
|
|
|
134
170
|
"msp",
|
|
135
171
|
"used",
|
|
136
172
|
"used-3rd-party",
|
|
137
|
-
"billed-
|
|
173
|
+
"billed-export",
|
|
138
174
|
):
|
|
139
|
-
for xname in ("kwh", "gbp"):
|
|
140
|
-
month_data[sname
|
|
141
|
-
month_data["billed-
|
|
142
|
-
|
|
143
|
-
|
|
175
|
+
for xname in ("kwh", "net-gbp"):
|
|
176
|
+
month_data[f"{sname}-{xname}"] = 0
|
|
177
|
+
month_data["billed-import-kwh"] = 0
|
|
178
|
+
for suf in ("net-gbp", "vat-gbp", "gross-gbp"):
|
|
179
|
+
month_data[f"billed-import-{suf}"] = 0
|
|
180
|
+
month_data[f"billed-supplier-import-{suf}"] = None
|
|
181
|
+
month_data[f"billed-dc-import-{suf}"] = None
|
|
182
|
+
month_data[f"billed-mop-import-{suf}"] = None
|
|
183
|
+
month_data[f"billed-export-{suf}"] = 0
|
|
144
184
|
|
|
145
185
|
month_data["used-kwh"] = month_data["displaced-kwh"] = sum(
|
|
146
186
|
hh["msp-kwh"] for hh in imp_ss.hh_data
|
|
@@ -150,7 +190,7 @@ def _process_site(
|
|
|
150
190
|
|
|
151
191
|
gbp = disp_supplier_bill.get("net-gbp", 0)
|
|
152
192
|
|
|
153
|
-
month_data["used-gbp"] = month_data["displaced-gbp"] = gbp
|
|
193
|
+
month_data["used-net-gbp"] = month_data["displaced-net-gbp"] = gbp
|
|
154
194
|
|
|
155
195
|
out = (
|
|
156
196
|
[
|
|
@@ -206,8 +246,8 @@ def _process_site(
|
|
|
206
246
|
site_sources.add(source_code)
|
|
207
247
|
month_data = {}
|
|
208
248
|
for name in (
|
|
209
|
-
"import-
|
|
210
|
-
"export-
|
|
249
|
+
"import-grid",
|
|
250
|
+
"export-grid",
|
|
211
251
|
"import-gen",
|
|
212
252
|
"export-gen",
|
|
213
253
|
"import-3rd-party",
|
|
@@ -215,13 +255,16 @@ def _process_site(
|
|
|
215
255
|
"displaced",
|
|
216
256
|
"used",
|
|
217
257
|
"used-3rd-party",
|
|
218
|
-
"billed-
|
|
258
|
+
"billed-export",
|
|
219
259
|
):
|
|
220
|
-
for sname in ("kwh", "gbp"):
|
|
221
|
-
month_data[name
|
|
222
|
-
month_data["billed-
|
|
223
|
-
|
|
224
|
-
|
|
260
|
+
for sname in ("kwh", "net-gbp"):
|
|
261
|
+
month_data[f"{name}-{sname}"] = 0
|
|
262
|
+
month_data["billed-import-kwh"] = 0
|
|
263
|
+
for suf in ("net-gbp", "vat-gbp", "gross-gbp"):
|
|
264
|
+
month_data[f"billed-import-{suf}"] = 0
|
|
265
|
+
month_data[f"billed-supplier-import-{suf}"] = 0
|
|
266
|
+
month_data[f"billed-dc-import-{suf}"] = 0
|
|
267
|
+
month_data[f"billed-mop-import-{suf}"] = 0
|
|
225
268
|
|
|
226
269
|
if imp_ss is not None:
|
|
227
270
|
imp_supplier_contract = imp_ss.supplier_contract
|
|
@@ -231,26 +274,26 @@ def _process_site(
|
|
|
231
274
|
|
|
232
275
|
gbp = imp_supplier_bill.get("net-gbp", 0)
|
|
233
276
|
|
|
234
|
-
if source_code in ("
|
|
235
|
-
month_data["import-net-gbp"] += gbp
|
|
236
|
-
month_data["import-
|
|
237
|
-
month_data["used-gbp"] += gbp
|
|
277
|
+
if source_code in ("grid", "gen-grid"):
|
|
278
|
+
month_data["import-grid-net-gbp"] += gbp
|
|
279
|
+
month_data["import-grid-kwh"] += kwh
|
|
280
|
+
month_data["used-net-gbp"] += gbp
|
|
238
281
|
month_data["used-kwh"] += kwh
|
|
239
|
-
if source_code == "gen-
|
|
282
|
+
if source_code == "gen-grid":
|
|
240
283
|
month_data["export-gen-kwh"] += kwh
|
|
241
284
|
elif source_code == "3rd-party":
|
|
242
|
-
month_data["import-3rd-party-gbp"] += gbp
|
|
285
|
+
month_data["import-3rd-party-net-gbp"] += gbp
|
|
243
286
|
month_data["import-3rd-party-kwh"] += kwh
|
|
244
|
-
month_data["used-3rd-party-gbp"] += gbp
|
|
287
|
+
month_data["used-3rd-party-net-gbp"] += gbp
|
|
245
288
|
month_data["used-3rd-party-kwh"] += kwh
|
|
246
289
|
month_data["used-gbp"] += gbp
|
|
247
290
|
month_data["used-kwh"] += kwh
|
|
248
291
|
elif source_code == "3rd-party-reverse":
|
|
249
|
-
month_data["export-3rd-party-gbp"] += gbp
|
|
292
|
+
month_data["export-3rd-party-net-gbp"] += gbp
|
|
250
293
|
month_data["export-3rd-party-kwh"] += kwh
|
|
251
|
-
month_data["used-3rd-party-gbp"] -= gbp
|
|
294
|
+
month_data["used-3rd-party-net-gbp"] -= gbp
|
|
252
295
|
month_data["used-3rd-party-kwh"] -= kwh
|
|
253
|
-
month_data["used-gbp"] -= gbp
|
|
296
|
+
month_data["used-net-gbp"] -= gbp
|
|
254
297
|
month_data["used-kwh"] -= kwh
|
|
255
298
|
elif source_code == "gen":
|
|
256
299
|
month_data["import-gen-kwh"] += kwh
|
|
@@ -263,25 +306,25 @@ def _process_site(
|
|
|
263
306
|
|
|
264
307
|
gbp = exp_supplier_bill.get("net-gbp", 0)
|
|
265
308
|
|
|
266
|
-
if source_code in ("
|
|
267
|
-
month_data["export-net-gbp"] += gbp
|
|
268
|
-
month_data["export-
|
|
269
|
-
if source_code == "gen-
|
|
309
|
+
if source_code in ("grid", "gen-grid"):
|
|
310
|
+
month_data["export-grid-net-gbp"] += gbp
|
|
311
|
+
month_data["export-grid-kwh"] += kwh
|
|
312
|
+
if source_code == "gen-grid":
|
|
270
313
|
month_data["import-gen-kwh"] += kwh
|
|
271
314
|
|
|
272
315
|
elif source_code == "3rd-party":
|
|
273
|
-
month_data["export-3rd-party-gbp"] += gbp
|
|
316
|
+
month_data["export-3rd-party-net-gbp"] += gbp
|
|
274
317
|
month_data["export-3rd-party-kwh"] += kwh
|
|
275
|
-
month_data["used-3rd-party-gbp"] -= gbp
|
|
318
|
+
month_data["used-3rd-party-net-gbp"] -= gbp
|
|
276
319
|
month_data["used-3rd-party-kwh"] -= kwh
|
|
277
|
-
month_data["used-gbp"] -= gbp
|
|
320
|
+
month_data["used-net-gbp"] -= gbp
|
|
278
321
|
month_data["used-kwh"] -= kwh
|
|
279
322
|
elif source_code == "3rd-party-reverse":
|
|
280
|
-
month_data["import-3rd-party-gbp"] += gbp
|
|
323
|
+
month_data["import-3rd-party-net-gbp"] += gbp
|
|
281
324
|
month_data["import-3rd-party-kwh"] += kwh
|
|
282
|
-
month_data["used-3rd-party-gbp"] += gbp
|
|
325
|
+
month_data["used-3rd-party-net-gbp"] += gbp
|
|
283
326
|
month_data["used-3rd-party-kwh"] += kwh
|
|
284
|
-
month_data["used-gbp"] += gbp
|
|
327
|
+
month_data["used-net-gbp"] += gbp
|
|
285
328
|
month_data["used-kwh"] += kwh
|
|
286
329
|
elif source_code == "gen":
|
|
287
330
|
month_data["export-gen-kwh"] += kwh
|
|
@@ -312,14 +355,14 @@ def _process_site(
|
|
|
312
355
|
gbp += mop_bill["net-gbp"]
|
|
313
356
|
|
|
314
357
|
if source_code in ("3rd-party", "3rd-party-reverse"):
|
|
315
|
-
month_data["import-3rd-party-gbp"] += gbp
|
|
316
|
-
month_data["used-3rd-party-gbp"] += gbp
|
|
358
|
+
month_data["import-3rd-party-net-gbp"] += gbp
|
|
359
|
+
month_data["used-3rd-party-net-gbp"] += gbp
|
|
317
360
|
else:
|
|
318
|
-
month_data["import-net-gbp"] += gbp
|
|
319
|
-
month_data["used-gbp"] += gbp
|
|
361
|
+
month_data["import-grid-net-gbp"] += gbp
|
|
362
|
+
month_data["used-net-gbp"] += gbp
|
|
320
363
|
|
|
321
364
|
generator_type = sss.generator_type_code
|
|
322
|
-
if source_code in ("gen", "gen-
|
|
365
|
+
if source_code in ("gen", "gen-grid"):
|
|
323
366
|
site_gen_types.add(generator_type)
|
|
324
367
|
|
|
325
368
|
era_category = sss.measurement_type
|
|
@@ -329,31 +372,14 @@ def _process_site(
|
|
|
329
372
|
era_associates = {
|
|
330
373
|
s.site.code for s in sss.era.site_eras if not s.is_physical
|
|
331
374
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
bill_finish = bill.finish_date
|
|
341
|
-
bill_duration = (bill_finish - bill_start).total_seconds() + (30 * 60)
|
|
342
|
-
overlap_duration = (
|
|
343
|
-
min(bill_finish, sss.finish_date) - max(bill_start, sss.start_date)
|
|
344
|
-
).total_seconds() + (30 * 60)
|
|
345
|
-
proportion = overlap_duration / bill_duration
|
|
346
|
-
month_data["billed-import-net-kwh"] += proportion * float(bill.kwh)
|
|
347
|
-
bill_prop_gbp = proportion * float(bill.net)
|
|
348
|
-
month_data["billed-import-net-gbp"] += bill_prop_gbp
|
|
349
|
-
if bill_role_code == "X":
|
|
350
|
-
month_data["billed-supplier-import-net-gbp"] += bill_prop_gbp
|
|
351
|
-
elif bill_role_code == "C":
|
|
352
|
-
month_data["billed-dc-import-net-gbp"] += bill_prop_gbp
|
|
353
|
-
elif bill_role_code == "M":
|
|
354
|
-
month_data["billed-mop-import-net-gbp"] += bill_prop_gbp
|
|
355
|
-
else:
|
|
356
|
-
raise BadRequest("Role code not recognized.")
|
|
375
|
+
bills = sess.scalars(
|
|
376
|
+
select(Bill).where(
|
|
377
|
+
Bill.supply == supply,
|
|
378
|
+
Bill.start_date <= sss.finish_date,
|
|
379
|
+
Bill.finish_date >= sss.start_date,
|
|
380
|
+
)
|
|
381
|
+
).all()
|
|
382
|
+
_add_bills(month_data, sss.era, bills, sss.start_date, sss.finish_date)
|
|
357
383
|
|
|
358
384
|
if imp_ss is None:
|
|
359
385
|
imp_supplier_contract_name = imp_voltage_level_code = None
|
|
@@ -472,8 +498,8 @@ def _process_site(
|
|
|
472
498
|
if len(bills) > 0:
|
|
473
499
|
month_data = {}
|
|
474
500
|
for name in (
|
|
475
|
-
"import-
|
|
476
|
-
"export-
|
|
501
|
+
"import-grid",
|
|
502
|
+
"export-grid",
|
|
477
503
|
"import-gen",
|
|
478
504
|
"export-gen",
|
|
479
505
|
"import-3rd-party",
|
|
@@ -481,41 +507,18 @@ def _process_site(
|
|
|
481
507
|
"displaced",
|
|
482
508
|
"used",
|
|
483
509
|
"used-3rd-party",
|
|
484
|
-
"billed-
|
|
510
|
+
"billed-export",
|
|
485
511
|
):
|
|
486
|
-
for sname in ("kwh", "gbp"):
|
|
487
|
-
month_data[name
|
|
488
|
-
month_data["billed-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
bill_duration = (bill_finish - bill_start).total_seconds() + (
|
|
497
|
-
30 * 60
|
|
498
|
-
)
|
|
499
|
-
overlap_duration = (
|
|
500
|
-
min(bill_finish, chunk_finish)
|
|
501
|
-
- max(bill_start, chunk_start)
|
|
502
|
-
).total_seconds() + (30 * 60)
|
|
503
|
-
proportion = overlap_duration / bill_duration
|
|
504
|
-
bill_prop_kwh = proportion * float(bill.kwh)
|
|
505
|
-
bill_prop_gbp = proportion * float(bill.net)
|
|
506
|
-
if bill_role_code == "X":
|
|
507
|
-
key = "billed-supplier-import-net-gbp"
|
|
508
|
-
elif bill_role_code == "C":
|
|
509
|
-
key = "billed-dc-import-net-gbp"
|
|
510
|
-
elif bill_role_code == "M":
|
|
511
|
-
key = "billed-mop-import-net-gbp"
|
|
512
|
-
else:
|
|
513
|
-
raise BadRequest("Role code not recognized.")
|
|
514
|
-
|
|
515
|
-
for data in month_data, site_month_data:
|
|
516
|
-
data["billed-import-net-kwh"] += bill_prop_kwh
|
|
517
|
-
data["billed-import-net-gbp"] += bill_prop_gbp
|
|
518
|
-
data[key] += bill_prop_gbp
|
|
512
|
+
for sname in ("kwh", "net-gbp"):
|
|
513
|
+
month_data[f"{name}-{sname}"] = 0
|
|
514
|
+
month_data["billed-import-kwh"] = 0
|
|
515
|
+
for suf in ("net-gbp", "vat-gbp", "gross-gbp"):
|
|
516
|
+
month_data[f"billed-import-{suf}"] = 0
|
|
517
|
+
month_data[f"billed-supplier-import-{suf}"] = 0
|
|
518
|
+
month_data[f"billed-dc-import-{suf}"] = 0
|
|
519
|
+
month_data[f"billed-mop-import-{suf}"] = 0
|
|
520
|
+
|
|
521
|
+
_add_bills(month_data, last_era, bills, chunk_start, chunk_finish)
|
|
519
522
|
|
|
520
523
|
imp_supplier_contract = last_era.imp_supplier_contract
|
|
521
524
|
imp_llfc = last_era.imp_llfc
|
|
@@ -577,6 +580,9 @@ def _process_site(
|
|
|
577
580
|
] + [month_data[t] for t in summary_titles]
|
|
578
581
|
|
|
579
582
|
era_rows.append([make_val(v) for v in out])
|
|
583
|
+
for k, v in month_data.items():
|
|
584
|
+
if v is not None:
|
|
585
|
+
site_month_data[k] += v
|
|
580
586
|
first_era = (
|
|
581
587
|
sess.execute(
|
|
582
588
|
select(Era).where(Era.supply == supply).order_by(Era.start_date)
|
|
@@ -609,8 +615,8 @@ def _process_site(
|
|
|
609
615
|
if len(bills) > 0:
|
|
610
616
|
month_data = {}
|
|
611
617
|
for name in (
|
|
612
|
-
"import-
|
|
613
|
-
"export-
|
|
618
|
+
"import-grid",
|
|
619
|
+
"export-grid",
|
|
614
620
|
"import-gen",
|
|
615
621
|
"export-gen",
|
|
616
622
|
"import-3rd-party",
|
|
@@ -618,41 +624,17 @@ def _process_site(
|
|
|
618
624
|
"displaced",
|
|
619
625
|
"used",
|
|
620
626
|
"used-3rd-party",
|
|
621
|
-
"billed-
|
|
627
|
+
"billed-export",
|
|
622
628
|
):
|
|
623
|
-
for sname in ("kwh", "gbp"):
|
|
624
|
-
month_data[name
|
|
625
|
-
month_data["billed-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
bill_finish = bill.finish_date
|
|
633
|
-
bill_duration = (bill_finish - bill_start).total_seconds() + (
|
|
634
|
-
30 * 60
|
|
635
|
-
)
|
|
636
|
-
overlap_duration = (
|
|
637
|
-
min(bill_finish, chunk_finish)
|
|
638
|
-
- max(bill_start, chunk_start)
|
|
639
|
-
).total_seconds() + (30 * 60)
|
|
640
|
-
proportion = overlap_duration / bill_duration
|
|
641
|
-
bill_prop_kwh = proportion * float(bill.kwh)
|
|
642
|
-
bill_prop_gbp = proportion * float(bill.net)
|
|
643
|
-
if bill_role_code == "X":
|
|
644
|
-
key = "billed-supplier-import-net-gbp"
|
|
645
|
-
elif bill_role_code == "C":
|
|
646
|
-
key = "billed-dc-import-net-gbp"
|
|
647
|
-
elif bill_role_code == "M":
|
|
648
|
-
key = "billed-mop-import-net-gbp"
|
|
649
|
-
else:
|
|
650
|
-
raise BadRequest("Role code not recognized.")
|
|
651
|
-
|
|
652
|
-
for data in month_data, site_month_data:
|
|
653
|
-
data["billed-import-net-kwh"] += bill_prop_kwh
|
|
654
|
-
data["billed-import-net-gbp"] += bill_prop_gbp
|
|
655
|
-
data[key] += bill_prop_gbp
|
|
629
|
+
for sname in ("kwh", "net-gbp"):
|
|
630
|
+
month_data[f"{name}-{sname}"] = 0
|
|
631
|
+
month_data["billed-import-kwh"] = 0
|
|
632
|
+
for suf in ("net-gbp", "vat-gbp", "gross-gbp"):
|
|
633
|
+
month_data[f"billed-import-{suf}"] = 0
|
|
634
|
+
month_data[f"billed-supplier-import-{suf}"] = 0
|
|
635
|
+
month_data[f"billed-dc-import-{suf}"] = 0
|
|
636
|
+
month_data[f"billed-mop-import-{suf}"] = 0
|
|
637
|
+
_add_bills(month_data, first_era, bills, chunk_start, chunk_finish)
|
|
656
638
|
|
|
657
639
|
imp_supplier_contract = first_era.imp_supplier_contract
|
|
658
640
|
imp_llfc = last_era.imp_llfc
|
|
@@ -714,6 +696,9 @@ def _process_site(
|
|
|
714
696
|
] + [month_data[t] for t in summary_titles]
|
|
715
697
|
|
|
716
698
|
era_rows.append([make_val(v) for v in out])
|
|
699
|
+
for k, v in month_data.items():
|
|
700
|
+
if v is not None:
|
|
701
|
+
site_month_data[k] += v
|
|
717
702
|
site_row = [
|
|
718
703
|
now,
|
|
719
704
|
site.code,
|
|
@@ -931,8 +916,8 @@ def content(
|
|
|
931
916
|
"generator-types",
|
|
932
917
|
]
|
|
933
918
|
summary_titles = [
|
|
934
|
-
"import-
|
|
935
|
-
"export-
|
|
919
|
+
"import-grid-kwh",
|
|
920
|
+
"export-grid-kwh",
|
|
936
921
|
"import-gen-kwh",
|
|
937
922
|
"export-gen-kwh",
|
|
938
923
|
"import-3rd-party-kwh",
|
|
@@ -940,20 +925,30 @@ def content(
|
|
|
940
925
|
"displaced-kwh",
|
|
941
926
|
"used-kwh",
|
|
942
927
|
"used-3rd-party-kwh",
|
|
943
|
-
"import-net-gbp",
|
|
944
|
-
"export-net-gbp",
|
|
945
|
-
"import-gen-gbp",
|
|
946
|
-
"export-gen-gbp",
|
|
947
|
-
"import-3rd-party-gbp",
|
|
948
|
-
"export-3rd-party-gbp",
|
|
949
|
-
"displaced-gbp",
|
|
950
|
-
"used-gbp",
|
|
951
|
-
"used-3rd-party-gbp",
|
|
952
|
-
"billed-import-
|
|
928
|
+
"import-grid-net-gbp",
|
|
929
|
+
"export-grid-net-gbp",
|
|
930
|
+
"import-gen-net-gbp",
|
|
931
|
+
"export-gen-net-gbp",
|
|
932
|
+
"import-3rd-party-net-gbp",
|
|
933
|
+
"export-3rd-party-net-gbp",
|
|
934
|
+
"displaced-net-gbp",
|
|
935
|
+
"used-net-gbp",
|
|
936
|
+
"used-3rd-party-net-gbp",
|
|
937
|
+
"billed-import-kwh",
|
|
953
938
|
"billed-import-net-gbp",
|
|
939
|
+
"billed-import-vat-gbp",
|
|
940
|
+
"billed-import-gross-gbp",
|
|
954
941
|
"billed-supplier-import-net-gbp",
|
|
942
|
+
"billed-supplier-import-vat-gbp",
|
|
943
|
+
"billed-supplier-import-gross-gbp",
|
|
955
944
|
"billed-dc-import-net-gbp",
|
|
945
|
+
"billed-dc-import-vat-gbp",
|
|
946
|
+
"billed-dc-import-gross-gbp",
|
|
956
947
|
"billed-mop-import-net-gbp",
|
|
948
|
+
"billed-mop-import-vat-gbp",
|
|
949
|
+
"billed-mop-import-gross-gbp",
|
|
950
|
+
"billed-export-kwh",
|
|
951
|
+
"billed-export-net-gbp",
|
|
957
952
|
]
|
|
958
953
|
|
|
959
954
|
title_dict = {}
|