chellow 1721045482.0.0__py3-none-any.whl → 1721742190.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.

@@ -3,9 +3,11 @@ from collections import defaultdict
3
3
  from decimal import Decimal
4
4
  from io import StringIO
5
5
 
6
+ from dateutil.relativedelta import relativedelta
7
+
6
8
  from werkzeug.exceptions import BadRequest
7
9
 
8
- from chellow.utils import HH, parse_mpan_core, to_ct, to_utc
10
+ from chellow.utils import parse_mpan_core, to_ct, to_utc
9
11
 
10
12
 
11
13
  def parse_date(date_str):
@@ -55,7 +57,11 @@ def _handle_0100(headers, pre_record, record):
55
57
  def _handle_0101(headers, pre_record, record):
56
58
  parts = _chop_record(record, start_date=DATE_LENGTH, finish_date=DATE_LENGTH)
57
59
  headers["start_date"] = parse_date(parts["start_date"])
58
- headers["finish_date"] = to_utc(to_ct(parse_date_naive(parts["finish_date"]) - HH))
60
+ headers["finish_date"] = to_utc(
61
+ to_ct(
62
+ parse_date_naive(parts["finish_date"]) + relativedelta(hours=23, minutes=30)
63
+ )
64
+ )
59
65
 
60
66
 
61
67
  CHARGE_UNITS_LOOKUP = {
@@ -132,6 +138,12 @@ CONSUMPTION_UNITS_LOOKUP = {"KWH": "kWh", "KVA": "kVA", "KVARH": "kVArh", "KW":
132
138
 
133
139
  REGISTER_CODE_LOOKUP = {"DAY": "00040", "NIGHT": "00206", "SINGLE": "00001"}
134
140
 
141
+ READ_TYPE_LOOKUP = {
142
+ " ": "E",
143
+ "E": "E",
144
+ "N": "N",
145
+ }
146
+
135
147
 
136
148
  def _handle_0461(headers, pre_record, record):
137
149
  parts = _chop_record(
@@ -161,6 +173,8 @@ def _handle_0461(headers, pre_record, record):
161
173
  prev_read_date_str = parts["prev_read_date"].strip()
162
174
  if len(prev_read_date_str) > 0:
163
175
  tpr_code = REGISTER_CODE_LOOKUP[parts["register_code"].strip()]
176
+ prev_type_code = READ_TYPE_LOOKUP[parts["prev_read_type"]]
177
+ pres_type_code = READ_TYPE_LOOKUP[parts["pres_read_type"]]
164
178
 
165
179
  headers["reads"].append(
166
180
  {
@@ -171,10 +185,10 @@ def _handle_0461(headers, pre_record, record):
171
185
  "tpr_code": tpr_code,
172
186
  "prev_date": parse_date(parts["prev_read_date"]),
173
187
  "prev_value": Decimal(parts["prev_read_value"]),
174
- "prev_type_code": parts["prev_read_type"],
188
+ "prev_type_code": prev_type_code,
175
189
  "pres_date": parse_date(parts["pres_read_date"]),
176
190
  "pres_value": Decimal(parts["pres_read_value"]),
177
- "pres_type_code": parts["pres_read_type"],
191
+ "pres_type_code": pres_type_code,
178
192
  }
179
193
  )
180
194
 
@@ -183,8 +197,23 @@ def _handle_0470(headers, pre_record, record):
183
197
  pass
184
198
 
185
199
 
200
+ def _handle_0860(headers, pre_record, record):
201
+ parts = _chop_record(
202
+ record,
203
+ metering_gbp=12,
204
+ unknown_1=12,
205
+ unknown_2=12,
206
+ metering_date=DATE_LENGTH,
207
+ description=80,
208
+ )
209
+ bd = headers["breakdown"]
210
+ bd["metering-gbp"] += Decimal(parts["metering_gbp"]) / Decimal("100")
211
+
212
+
186
213
  def _handle_1455(headers, pre_record, record):
187
- parts = _chop_record(record, ccl_kwh=13, unknown_1=8, ccl_rate=15, ccl_gbp=13)
214
+ parts = _chop_record(
215
+ record, ccl_kwh=13, unknown_1=8, ccl_rate=15, ccl_gbp=12, unkown_2=8
216
+ )
188
217
  bd = headers["breakdown"]
189
218
  bd["ccl-kwh"] += Decimal(parts["ccl_kwh"])
190
219
  if "ccl-rate" in bd:
@@ -261,6 +290,7 @@ LINE_HANDLERS = {
261
290
  "0460": _handle_0460,
262
291
  "0461": _handle_0461,
263
292
  "0470": _handle_0470,
293
+ "0860": _handle_0860,
264
294
  "1455": _handle_1455,
265
295
  "1460": _handle_1460,
266
296
  "1500": _handle_1500,
@@ -110,7 +110,7 @@ def _process_era(
110
110
  f"contain the 'kwh' key."
111
111
  )
112
112
 
113
- billed_kwh = billed_gbp = 0
113
+ billed_kwh = billed_net_gbp = billed_vat_gbp = billed_gross_gbp = 0
114
114
 
115
115
  g_era_associates = {s.site.code for s in g_era.site_g_eras if not s.is_physical}
116
116
 
@@ -127,7 +127,9 @@ def _process_era(
127
127
  ).total_seconds() + (30 * 60)
128
128
  overlap_proportion = overlap_duration / bill_duration
129
129
  billed_kwh += overlap_proportion * float(g_bill.kwh)
130
- billed_gbp += overlap_proportion * float(g_bill.net)
130
+ billed_net_gbp += overlap_proportion * float(g_bill.net)
131
+ billed_vat_gbp += overlap_proportion * float(g_bill.vat)
132
+ billed_gross_gbp += overlap_proportion * float(g_bill.gross)
131
133
 
132
134
  associated_site_ids = ",".join(sorted(g_era_associates))
133
135
  g_era_rows.append(
@@ -149,12 +151,14 @@ def _process_era(
149
151
  kwh,
150
152
  gbp,
151
153
  billed_kwh,
152
- billed_gbp,
154
+ billed_net_gbp,
155
+ billed_vat_gbp,
156
+ billed_gross_gbp,
153
157
  ]
154
158
  ]
155
159
  + [make_val(bill.get(t)) for t in vb_titles]
156
160
  )
157
- return kwh, gbp, billed_kwh, billed_gbp
161
+ return kwh, gbp, billed_kwh, billed_net_gbp, billed_vat_gbp, billed_gross_gbp
158
162
 
159
163
 
160
164
  def content(
@@ -227,7 +231,14 @@ def content(
227
231
  "associated_site_ids",
228
232
  "month",
229
233
  ]
230
- summary_titles = ["kwh", "gbp", "billed_kwh", "billed_gbp"]
234
+ summary_titles = [
235
+ "kwh",
236
+ "gbp",
237
+ "billed_kwh",
238
+ "billed_net_gbp",
239
+ "billed_vat_gbp",
240
+ "billed_gross_gbp",
241
+ ]
231
242
 
232
243
  vb_titles = []
233
244
  conts = (
@@ -264,7 +275,8 @@ def content(
264
275
  GEra.start_date <= month_finish,
265
276
  or_(GEra.finish_date == null(), GEra.finish_date >= month_start),
266
277
  ):
267
- site_kwh = site_gbp = site_billed_kwh = site_billed_gbp = 0
278
+ site_kwh = site_gbp = site_billed_kwh = site_billed_net_gbp = 0
279
+ site_billed_vat_gbp = site_billed_gross_gbp = 0
268
280
 
269
281
  g_eras_q = (
270
282
  select(GEra)
@@ -290,7 +302,14 @@ def content(
290
302
 
291
303
  for g_era in sess.scalars(g_eras_q):
292
304
  try:
293
- kwh, gbp, billed_kwh, billed_gbp = _process_era(
305
+ (
306
+ kwh,
307
+ gbp,
308
+ billed_kwh,
309
+ billed_net_gbp,
310
+ billed_vat_gbp,
311
+ billed_gross_gbp,
312
+ ) = _process_era(
294
313
  report_context,
295
314
  sess,
296
315
  site,
@@ -305,7 +324,9 @@ def content(
305
324
  site_kwh += kwh
306
325
  site_gbp += gbp
307
326
  site_billed_kwh += billed_kwh
308
- site_billed_gbp += billed_gbp
327
+ site_billed_net_gbp += billed_net_gbp
328
+ site_billed_vat_gbp += billed_vat_gbp
329
+ site_billed_gross_gbp += billed_gross_gbp
309
330
  except BadRequest as e:
310
331
  raise BadRequest(
311
332
  f"Problem with g_era {g_era.id}: {e.description}"
@@ -328,7 +349,9 @@ def content(
328
349
  site_kwh,
329
350
  site_gbp,
330
351
  site_billed_kwh,
331
- site_billed_gbp,
352
+ site_billed_net_gbp,
353
+ site_billed_vat_gbp,
354
+ site_billed_gross_gbp,
332
355
  ]
333
356
  ]
334
357
  )
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1721045482.0.0
3
+ Version: 1721742190.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)
7
7
  Classifier: Operating System :: OS Independent
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Requires-Python: >=3.9
10
+ Requires-Dist: cryptography==42.0.8
10
11
  Requires-Dist: flask-restx==1.2.0
11
12
  Requires-Dist: flask==2.3.3
12
13
  Requires-Dist: odio==0.0.23
@@ -51,7 +51,7 @@ chellow/e/bill_parsers/gdf_csv.py,sha256=ZfK3Oc6oP28p_P9DIevLNB_zW2WLcEJ3Lvb1gL3
51
51
  chellow/e/bill_parsers/haven_csv.py,sha256=0uENq8IgVNqdxfBQMBxLTSZWCOuDHXZC0xzk52SbfyE,13652
52
52
  chellow/e/bill_parsers/haven_edi.py,sha256=YGPHRxPOhje9s32jqPHHELni2tooOYj3cMC_qaZVPq4,16107
53
53
  chellow/e/bill_parsers/haven_edi_tprs.py,sha256=ZVX9CCqUybsot_Z0BEOJPvl9x5kSr7fEWyuJXvZDcz4,11841
54
- chellow/e/bill_parsers/mm.py,sha256=WpjKJZ0HW6Yko3aZiq43HQU-i_rrBWgQTqggJB3FIEU,8627
54
+ chellow/e/bill_parsers/mm.py,sha256=0Ch-ngypH2X7eeEq5tDkaGQreCZUbjeDCmhbyGo2_vQ,9305
55
55
  chellow/e/bill_parsers/nonsettlement_dc_stark_xlsx.py,sha256=yogXTuQHGRL7IiqvRWr2C9V24ez1j9Yx0128UygPE_k,4723
56
56
  chellow/e/bill_parsers/settlement_dc_stark_xlsx.py,sha256=PlEqCZuJ9DfQXeeYQ64jtf3ML7sUt_tt61QOOTnkE5c,6380
57
57
  chellow/e/bill_parsers/sse_edi.py,sha256=L85DOfNkqexeEIEr8pCBn_2sHJI-zEaw6cogpE3YyYM,15204
@@ -94,7 +94,7 @@ chellow/reports/report_csv_llfcs.py,sha256=OHSbP64lQ6dlAMcQYgvdANlA4lQyF0iBlwk7V
94
94
  chellow/reports/report_csv_site_hh_data.py,sha256=T-clGDmYdn0ej7zZfL3kDp4Vyd82WzptxEzxx9KqAZg,4270
95
95
  chellow/reports/report_csv_site_snags.py,sha256=gG2sYQrLoIBwCoMUC8rhmAL7Kffh_rvNb9UOX7cYDko,2668
96
96
  chellow/reports/report_ecoes_comparison.py,sha256=PGDJKI2f6DCVCH0xcp--BzXWAWFfTDGgcKVQnfqxBKg,21653
97
- chellow/reports/report_g_monthly_duration.py,sha256=vI5FKAU8_oThjR5oflPZont7Z7sVAunr0qlMfJsaPJI,12004
97
+ chellow/reports/report_g_monthly_duration.py,sha256=FMMFIWFfGW2Bd9Excpf4LLXXqQ-fbnZZ_KfNa1VaPqA,13034
98
98
  chellow/reports/report_g_supplies_snapshot.py,sha256=0M0x_0o0985Hu45gUJJJwzfx0DDOAuXBJ1UVUDbQ36g,4718
99
99
  chellow/reports/report_g_supply_virtual_bill.py,sha256=x_KtQ02dwgmXvAEUXJ1poK0BRwqxa-GcbJ5pddEina0,3694
100
100
  chellow/reports/report_g_virtual_bills.py,sha256=t3hmTiURk1E_mPucIboCdPBlSLapDIUdHYRpVTFtJgw,4569
@@ -364,6 +364,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
364
364
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
365
365
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
366
366
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
367
- chellow-1721045482.0.0.dist-info/METADATA,sha256=MCDoXQp2ZxQmbo2xUOsJglW0_jrPAGJv4L4XYVDVdjY,12205
368
- chellow-1721045482.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
369
- chellow-1721045482.0.0.dist-info/RECORD,,
367
+ chellow-1721742190.0.0.dist-info/METADATA,sha256=pO8MYNQFGnV170Ar3U4yBTCtGFuUpG6NRlK1Qb6xHEk,12241
368
+ chellow-1721742190.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
369
+ chellow-1721742190.0.0.dist-info/RECORD,,