chellow 1754662596.0.0__py3-none-any.whl → 1755011219.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.

@@ -30,6 +30,8 @@ ELEMENT_MAP = {
30
30
  "ADH": {
31
31
  "ADHOC": {
32
32
  "020330": ("eii-gbp", None, None),
33
+ "064305": ("fit-gbp", None, None),
34
+ "590346": ("cfd-operational-gbp", None, None),
33
35
  "637050": ("meter-rental-gbp", "meter-rental-rate", "meter-rental-days"),
34
36
  },
35
37
  },
@@ -88,6 +90,8 @@ ELEMENT_MAP = {
88
90
  "209269": ("tnuos-gbp", "tnuos-rate", "tnuos-days"),
89
91
  },
90
92
  "DUS002": {
93
+ "185913": ("duos-yellow-gbp", "duos-yellow-rate", "duos-yellow-kwh"),
94
+ "517270": ("duos-black-gbp", "duos-black-rate", "duos-black-kwh"),
91
95
  "797790": (
92
96
  "duos-reactive-gbp",
93
97
  "duos-reactive-rate",
@@ -147,13 +151,6 @@ ELEMENT_MAP = {
147
151
  "012069": ("triad-gbp", "triad-rate", "triad-kw"),
148
152
  },
149
153
  },
150
- "064305": ("fit-gbp", None, None),
151
- "590346": ("cfd-operational-gbp", None, None),
152
- "439724": ("eii-gbp", None, None),
153
- "247610": ("eii-gbp", None, None),
154
- "930504": ("eii-gbp", None, None),
155
- "331201": ("eii-gbp", None, None),
156
- "307253": ("eii-gbp", "eii-rate", "eii-kwh"),
157
154
  }
158
155
 
159
156
  TPR_LOOKUP = {
@@ -145,6 +145,204 @@ BAND_WEEKEND = {
145
145
  "notes": None,
146
146
  }
147
147
 
148
+ PERIODS = {
149
+ "monday to friday (including bank holidays) april to march inclusive": [
150
+ {
151
+ "weekend": False,
152
+ "start-month": 4,
153
+ "start-day": 1,
154
+ "finish-month": 12,
155
+ "finish-day": 31,
156
+ },
157
+ {
158
+ "weekend": False,
159
+ "start-month": 1,
160
+ "start-day": 1,
161
+ "finish-month": 3,
162
+ "finish-day": 31,
163
+ },
164
+ ],
165
+ "monday to friday (including bank holidays) april to october inclusive and march": [
166
+ {
167
+ "weekend": False,
168
+ "start-month": 4,
169
+ "start-day": 1,
170
+ "finish-month": 10,
171
+ "finish-day": 31,
172
+ },
173
+ {
174
+ "weekend": False,
175
+ "start-month": 3,
176
+ "start-day": 1,
177
+ "finish-month": 3,
178
+ "finish-day": 31,
179
+ },
180
+ ],
181
+ "monday to friday (including bank holidays) june to august inclusive": [
182
+ {
183
+ "weekend": False,
184
+ "start-month": 6,
185
+ "start-day": 1,
186
+ "finish-month": 8,
187
+ "finish-day": 31,
188
+ },
189
+ ],
190
+ "monday to friday (including bank holidays) november to february inclusive": [
191
+ {
192
+ "weekend": False,
193
+ "start-month": 11,
194
+ "start-day": 1,
195
+ "finish-month": 12,
196
+ "finish-day": 31,
197
+ },
198
+ {
199
+ "weekend": False,
200
+ "start-month": 1,
201
+ "start-day": 1,
202
+ "finish-month": 2,
203
+ "finish-day": "last",
204
+ },
205
+ ],
206
+ "monday to friday (including bank holidays) november to february inclusive "
207
+ "(excluding 22nd dec to 4th jan inclusive)": [
208
+ {
209
+ "weekend": False,
210
+ "start-month": 11,
211
+ "start-day": 1,
212
+ "finish-month": 12,
213
+ "finish-day": 21,
214
+ },
215
+ {
216
+ "weekend": False,
217
+ "start-month": 1,
218
+ "start-day": 5,
219
+ "finish-month": 2,
220
+ "finish-day": "last",
221
+ },
222
+ ],
223
+ "monday to friday (including bank holidays) march to october inclusive": [
224
+ {
225
+ "weekend": False,
226
+ "start-month": 3,
227
+ "start-day": 1,
228
+ "finish-month": 10,
229
+ "finish-day": 31,
230
+ },
231
+ ],
232
+ "monday to friday (including bank holidays) mar to oct inclusive": [
233
+ {
234
+ "weekend": False,
235
+ "start-month": 3,
236
+ "start-day": 1,
237
+ "finish-month": 10,
238
+ "finish-day": 31,
239
+ },
240
+ ],
241
+ "monday to friday (including bank holidays) nov to feb inclusive": [
242
+ {
243
+ "weekend": False,
244
+ "start-month": 11,
245
+ "start-day": 1,
246
+ "finish-month": 12,
247
+ "finish-day": 31,
248
+ },
249
+ {
250
+ "weekend": False,
251
+ "start-month": 1,
252
+ "start-day": 1,
253
+ "finish-month": 2,
254
+ "finish-day": "last",
255
+ },
256
+ ],
257
+ (
258
+ "monday to friday nov to feb (excluding 22nd dec to 4th jan inclusive)"
259
+ "monday to friday (including bank holidays) nov to feb inclusive "
260
+ "(excluding 22nd dec to 4th jan inclusive)"
261
+ ): [
262
+ {
263
+ "weekend": False,
264
+ "start-month": 11,
265
+ "start-day": 1,
266
+ "finish-month": 12,
267
+ "finish-day": 21,
268
+ },
269
+ {
270
+ "weekend": False,
271
+ "start-month": 1,
272
+ "start-day": 5,
273
+ "finish-month": 2,
274
+ "finish-day": "last",
275
+ },
276
+ ],
277
+ (
278
+ "monday to friday (including bank holidays) "
279
+ "mar to oct inclusive (plus 22nd dec to 4th jan inclusive)"
280
+ ): [
281
+ {
282
+ "weekend": False,
283
+ "start-month": 3,
284
+ "start-day": 1,
285
+ "finish-month": 10,
286
+ "finish-day": 31,
287
+ },
288
+ {
289
+ "weekend": False,
290
+ "start-month": 12,
291
+ "start-day": 22,
292
+ "finish-month": 12,
293
+ "finish-day": 31,
294
+ },
295
+ {
296
+ "weekend": False,
297
+ "start-month": 1,
298
+ "start-day": 1,
299
+ "finish-month": 1,
300
+ "finish-day": 4,
301
+ },
302
+ ],
303
+ (
304
+ "monday to friday "
305
+ "(including bank holidays) "
306
+ "nov to feb inclusive (excluding 22nd dec to 4th jan inclusive)"
307
+ ): [
308
+ {
309
+ "weekend": False,
310
+ "start-month": 11,
311
+ "start-day": 1,
312
+ "finish-month": 12,
313
+ "finish-day": 21,
314
+ },
315
+ {
316
+ "weekend": False,
317
+ "start-month": 1,
318
+ "start-day": 4,
319
+ "finish-month": 2,
320
+ "finish-day": "last",
321
+ },
322
+ ],
323
+ "saturday and sunday all year": [
324
+ {
325
+ "weekend": True,
326
+ "start-month": 1,
327
+ "start-day": 1,
328
+ "finish-month": 12,
329
+ "finish-day": 31,
330
+ }
331
+ ],
332
+ (
333
+ "monday to friday (including bank holidays) november to february "
334
+ "monday to friday nov to feb"
335
+ ): [
336
+ {
337
+ "weekend": False,
338
+ "start-month": 11,
339
+ "start-day": 1,
340
+ "finish-month": 2,
341
+ "finish-day": "last",
342
+ }
343
+ ],
344
+ }
345
+
148
346
 
149
347
  def str_to_hr(hr_str):
150
348
  for sep in (":", "."):
@@ -209,6 +407,7 @@ def tab_lv_hv(sheet, gsp_rates):
209
407
  tariffs = gsp_rates["tariffs"] = {}
210
408
 
211
409
  bands = gsp_rates["bands"] = []
410
+ ums_bands = gsp_rates["ums_bands"] = []
212
411
 
213
412
  class State(Enum):
214
413
  OUTSIDE = auto()
@@ -236,15 +435,31 @@ def tab_lv_hv(sheet, gsp_rates):
236
435
 
237
436
  if is_weekend is None:
238
437
  state = State.OUTSIDE
239
- else:
240
- for i, band_name in enumerate(("red", "amber")):
241
- for slot in val_to_slots(get_value(row, i + 1)):
242
- bands.append(
438
+ continue
439
+
440
+ for i, band_name in enumerate(("red", "amber")):
441
+ for slot in val_to_slots(get_value(row, i + 1)):
442
+ bands.append(
443
+ {
444
+ "weekend": is_weekend,
445
+ "start": slot["start"],
446
+ "finish": slot["finish"],
447
+ "band": band_name,
448
+ }
449
+ )
450
+
451
+ val_6 = " ".join(get_value(row, 6).split()).lower()
452
+ periods = PERIODS[val_6]
453
+
454
+ for i, band_name in enumerate(("black", "yellow")):
455
+ for slot in val_to_slots(get_value(row, i + 8)):
456
+ for period in periods:
457
+ ums_bands.append(
243
458
  {
244
- "weekend": is_weekend,
245
- "start": slot["start"],
246
- "finish": slot["finish"],
247
459
  "band": band_name,
460
+ **period,
461
+ "start-decimal-hour": slot["start"],
462
+ "finish-decimal-hour": slot["finish"],
248
463
  }
249
464
  )
250
465
 
@@ -255,6 +470,9 @@ def tab_lv_hv(sheet, gsp_rates):
255
470
  llfcs_str = ",".join(
256
471
  chain(to_llfcs(get_value(row, 1)), to_llfcs(get_value(row, 10)))
257
472
  )
473
+ is_ums = "unmetered supplies" in val_0.lower()
474
+ high_band = "black" if is_ums else "red"
475
+ medium_band = "yellow" if is_ums else "amber"
258
476
  pcs_str = ",".join(to_pcs(row, 2))
259
477
  tariffs[llfcs_str + "_" + pcs_str] = {
260
478
  "description": val_0,
@@ -267,8 +485,10 @@ def tab_lv_hv(sheet, gsp_rates):
267
485
  "excess-gbp-per-kva-per-day": get_zero_rate(
268
486
  row, col_match(title_row, "exce")
269
487
  ),
270
- "red-gbp-per-kwh": get_rag_rate(row, col_match(title_row, "red")),
271
- "amber-gbp-per-kwh": get_rag_rate(
488
+ f"{high_band}-gbp-per-kwh": get_rag_rate(
489
+ row, col_match(title_row, "red")
490
+ ),
491
+ f"{medium_band}-gbp-per-kwh": get_rag_rate(
272
492
  row, col_match(title_row, "amber")
273
493
  ),
274
494
  "green-gbp-per-kwh": get_rag_rate(
@@ -344,54 +564,15 @@ def tab_ehv(sheet, gsp_rates):
344
564
  state = EHV_BLANK
345
565
  else:
346
566
  period_str = " ".join(get_value(row, 0).split()).lower()
347
- periods = []
348
-
349
- if period_str in (
350
- "monday to friday nov to feb (excluding "
351
- "22nd dec to 4th jan inclusive)",
352
- "monday to friday (including bank holidays) nov to feb inclusive "
353
- "(excluding 22nd dec to 4th jan inclusive)",
354
- ):
355
- periods.append(
356
- {
357
- "weekend": False,
358
- "start-month": 11,
359
- "start-day": 1,
360
- "finish-month": 12,
361
- "finish-day": 21,
362
- }
363
- )
364
- periods.append(
365
- {
366
- "weekend": False,
367
- "start-month": 1,
368
- "start-day": 5,
369
- "finish-month": 2,
370
- "finish-day": "last",
371
- }
372
- )
373
-
374
- elif period_str in (
375
- "monday to friday (including bank holidays) november to february",
376
- "monday to friday nov to feb",
377
- ):
378
- periods.append(
379
- {
380
- "weekend": False,
381
- "start-month": 11,
382
- "start-day": 1,
383
- "finish-month": 2,
384
- "finish-day": "last",
385
- }
386
- )
567
+ periods = PERIODS[period_str]
387
568
 
388
569
  for slot in val_to_slots(get_value(row, 3)):
389
570
  for period in periods:
390
571
  bands.append(
391
572
  {
392
573
  **period,
393
- "start-hour": slot["start"],
394
- "finish-hour": slot["finish"],
574
+ "start-decimal-hour": slot["start"],
575
+ "finish-decimal-hour": slot["finish"],
395
576
  }
396
577
  )
397
578
 
chellow/e/duos.py CHANGED
@@ -16,20 +16,17 @@ from chellow.utils import (
16
16
  )
17
17
 
18
18
 
19
- BANDS = ("super-red", "red", "amber", "green")
20
-
21
- KEYS = dict(
22
- (
23
- band,
24
- {
25
- "kwh": f"duos-{band}-kwh",
26
- "tariff-rate": f"{band}-gbp-per-kwh",
27
- "bill-rate": f"duos-{band}-rate",
28
- "gbp": f"duos-{band}-gbp",
29
- },
30
- )
19
+ BANDS = ("black", "super-red", "red", "amber", "yellow", "green")
20
+
21
+ KEYS = {
22
+ band: {
23
+ "kwh": f"duos-{band}-kwh",
24
+ "tariff-rate": f"{band}-gbp-per-kwh",
25
+ "bill-rate": f"duos-{band}-rate",
26
+ "gbp": f"duos-{band}-gbp",
27
+ }
31
28
  for band in BANDS
32
- )
29
+ }
33
30
 
34
31
  VL_LOOKUP = {
35
32
  "LV": {True: "lv-sub", False: "lv-net"},
@@ -706,6 +703,58 @@ def datum_2012_02_23(ds, hh):
706
703
  band = "super-red"
707
704
  break
708
705
 
706
+ bands_cache[start_date] = band
707
+ elif ds.dtc_meter_type_code is None: # unmetered
708
+ try:
709
+ band = gsp_group_cache["ums-bands"][start_date]
710
+ except KeyError:
711
+ try:
712
+ bands_cache = gsp_group_cache["ums-bands"]
713
+ except KeyError:
714
+ bands_cache = gsp_group_cache["ums-bands"] = {}
715
+
716
+ try:
717
+ band = bands_cache[start_date]
718
+ except KeyError:
719
+ band = "green"
720
+ ct_hr = hh["ct-decimal-hour"]
721
+ ct_day = hh["ct-day"]
722
+ ct_month = hh["ct-month"]
723
+ weekend = hh["ct-day-of-week"] > 4
724
+ try:
725
+ slots = ds.hh_rate(ds.dno_contract.id, start_date)[
726
+ ds.gsp_group_code
727
+ ]["ums_bands"]
728
+ except KeyError as e:
729
+ raise BadRequest(str(e))
730
+
731
+ for slot in slots:
732
+ if (
733
+ slot["weekend"] == weekend
734
+ and slot["start-decimal-hour"]
735
+ <= ct_hr
736
+ < slot["finish-decimal-hour"]
737
+ and (
738
+ ct_month > slot["start-month"]
739
+ or (
740
+ ct_month == slot["start-month"]
741
+ and ct_day >= slot["start-day"]
742
+ )
743
+ )
744
+ and (
745
+ ct_month < slot["finish-month"]
746
+ or (
747
+ ct_month == slot["finish-month"]
748
+ and (
749
+ slot["finish-day"] == "last"
750
+ or ct_day <= slot["finish-day"]
751
+ )
752
+ )
753
+ )
754
+ ):
755
+ band = slot["band"]
756
+ break
757
+
709
758
  bands_cache[start_date] = band
710
759
  else:
711
760
 
@@ -321,9 +321,9 @@ def _process_supply(
321
321
  while len(bill_ids) > 0:
322
322
  bill_id = list(sorted(bill_ids))[0]
323
323
  bill_ids.remove(bill_id)
324
- bill = (
325
- sess.query(Bill)
326
- .filter(Bill.id == bill_id)
324
+ bill = sess.scalar(
325
+ select(Bill)
326
+ .where(Bill.id == bill_id)
327
327
  .options(
328
328
  joinedload(Bill.batch),
329
329
  joinedload(Bill.bill_type),
@@ -332,7 +332,6 @@ def _process_supply(
332
332
  joinedload(Bill.reads).joinedload(RegisterRead.present_type),
333
333
  joinedload(Bill.reads).joinedload(RegisterRead.previous_type),
334
334
  )
335
- .one()
336
335
  )
337
336
  virtual_bill = {"problem": ""}
338
337
  supply = bill.supply
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chellow
3
- Version: 1754662596.0.0
3
+ Version: 1755011219.0.0
4
4
  Summary: Web Application for checking UK energy bills.
5
5
  Project-URL: Homepage, https://github.com/WessexWater/chellow
6
6
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
@@ -22,8 +22,8 @@ chellow/e/bsuos.py,sha256=2L7pgiGbV4k1Udfzjj4B2Qye02sV_FhNjwh7_sIxXFg,15525
22
22
  chellow/e/ccl.py,sha256=30dh_SvlgzsTQPPAJNZWILaMvbeDsv9-P-S1JxS5_SQ,3184
23
23
  chellow/e/cfd.py,sha256=CWLdYeNjgqT6Ro8YRf4vhwXIAJ2aV4Wi6HLNClVSeaQ,14260
24
24
  chellow/e/computer.py,sha256=lt4Zlr8EOClL1acuuvKA-tNPCI5RRHnAZbsaGQnB9j4,68835
25
- chellow/e/dno_rate_parser.py,sha256=EO3uIYD0uiT8uumI5wnODMsFwYGrdB5HexuOu-2aFkw,21875
26
- chellow/e/duos.py,sha256=RHrn93I1ASO2uYkuF18qlhG4p-jpuJhd_g3o69wtP4U,31004
25
+ chellow/e/dno_rate_parser.py,sha256=PRJnRHsoMdNQTzXfHet8PptXOcNUURKhVpwd9Dzt2Q4,26503
26
+ chellow/e/duos.py,sha256=3jOOnRP633xfzC7OhqWWW48H34T-NZosss9CNW6HQQs,33004
27
27
  chellow/e/elexon.py,sha256=eOmX_wpxj6Ty6eaEgGAgXX-MgyJkYQSAT6DtJeP1rUE,5544
28
28
  chellow/e/energy_management.py,sha256=tRQJ-7_caG91oKnh5qIuK9qE_Nr3BmZ3ddaj5GTHIKQ,10487
29
29
  chellow/e/hh_importer.py,sha256=JBVCNSpM-DMu9_io516KojvujwZEQq6upDSsMbtu_sI,21511
@@ -50,7 +50,7 @@ chellow/e/bill_parsers/activity_mop_stark_xlsx.py,sha256=opjXRrqrgBTbSKzL0JfTLP0
50
50
  chellow/e/bill_parsers/annual_mop_stark_xlsx.py,sha256=-HMoIfa_utXYKA44RuC0Xqv3vd2HLeQU_4P0iBUd3WA,4219
51
51
  chellow/e/bill_parsers/bgb_edi.py,sha256=GuwHeYbAGk7BVg5n19FcTANFDyKI-y0z3f9niQaPSSw,4828
52
52
  chellow/e/bill_parsers/csv.py,sha256=U5zcIaZ6B5QTTpFDAcBnk4G2r8B3j5kJhDPL4AJNkEk,5640
53
- chellow/e/bill_parsers/drax_edi.py,sha256=mzYaPYMVj2dFb1HIGV-HFtqYjhZ2g9V3xl_w8Z1ECfc,15400
53
+ chellow/e/bill_parsers/drax_edi.py,sha256=TPfFAM3z4CUsgIKT4B7Tc87urVzidklEFiZjQ3UgaVM,15371
54
54
  chellow/e/bill_parsers/drax_element_edi.py,sha256=kxjg1KA4UheMa8doGp9skXtQYrNK8Eisy9ksafR5TQo,13661
55
55
  chellow/e/bill_parsers/edf_export_xlsx.py,sha256=J4lY8epiSTIePZ6D1SGD76TXRoev35KrUC2sjHkNqlE,6632
56
56
  chellow/e/bill_parsers/engie_edi.py,sha256=yC5Tz5xFIcJmKZbvK_xcl0s-1fZsse1z4HEbwpC7fxU,15834
@@ -79,7 +79,7 @@ chellow/gas/transportation.py,sha256=Bkg8TWOs-v0ES-4qqwbleiOhqbE_t2KauUx9JYMZELM
79
79
  chellow/gas/views.py,sha256=GeCvi6BGTUN7bu7sVkypNckwG3Crl6AbUcRob9qMi0E,59733
80
80
  chellow/reports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
81
81
  chellow/reports/report_109.py,sha256=Exb-FQ5f70-ier_h15CgHGysQ7vJ7k3gFZ1001zM3iM,11171
82
- chellow/reports/report_111.py,sha256=_ipuMuvhjWLBVjK4wV08tbDG6s8cspQ_bzRZu1mPuXE,30224
82
+ chellow/reports/report_111.py,sha256=LAWmCLVE5yhPTVV_agZtlTyXHyNmJVes2zL7CS9eITo,30211
83
83
  chellow/reports/report_169.py,sha256=wortJyvgXTrnjjXhLzqwaksKKu63K5IgdzU5f4SkHMI,9246
84
84
  chellow/reports/report_181.py,sha256=ypfYWYVNC1X2fMlJyDzwNiNTTRrpPW49DirXE_xDKa0,4958
85
85
  chellow/reports/report_183.py,sha256=fGONpKEIXTqIT_3dE5jZKBIesWPgLq-chHO6X22dIv0,8768
@@ -386,6 +386,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
386
386
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
387
387
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
388
388
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
389
- chellow-1754662596.0.0.dist-info/METADATA,sha256=aX-vVmKqbNRf1rplpPv_hkiUpx6Bt0bFszWCFmaBh5k,12519
390
- chellow-1754662596.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
391
- chellow-1754662596.0.0.dist-info/RECORD,,
389
+ chellow-1755011219.0.0.dist-info/METADATA,sha256=LR04CnNjbSXoLGxeZWwX2C97Zj3DBdM8lNiUR4t21pg,12519
390
+ chellow-1755011219.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
391
+ chellow-1755011219.0.0.dist-info/RECORD,,