chellow 1729012049.0.0__py3-none-any.whl → 1729081025.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.

@@ -4,9 +4,12 @@ from decimal import Decimal
4
4
 
5
5
  from dateutil.relativedelta import relativedelta
6
6
 
7
+ from sqlalchemy import select
8
+
7
9
  from werkzeug.exceptions import BadRequest
8
10
 
9
11
  from chellow.edi_lib import parse_edi, to_date, to_decimal
12
+ from chellow.models import GEra, Session
10
13
  from chellow.utils import HH, to_ct, to_utc
11
14
 
12
15
  # From Total 2024-05-29
@@ -28,6 +31,7 @@ SUPPLIER_CODE_MAP = {
28
31
  "STD": ("standing", Decimal("1000"), Decimal("1")),
29
32
  "MET": ("commodity", Decimal("100000"), Decimal("1000")),
30
33
  "CCL": ("ccl", Decimal("100000"), Decimal("1000")),
34
+ "SUN": ("sundry", Decimal("1000"), Decimal("100")),
31
35
  }
32
36
 
33
37
  UNIT_MAP = {"M3": "M3", "HH": "HCUF", "HCUF": "HCUF"}
@@ -110,14 +114,19 @@ def _process_CCD2(elements, headers):
110
114
  units_billed = to_decimal(nuct) / units_divisor
111
115
  breakdown[key] += units_billed
112
116
 
113
- if tpref == "standing" or "start_date" not in headers:
114
- headers["start_date"] = to_date(csdt[0])
117
+ start_date = to_date(csdt[0])
118
+ if start_date is not None and (tpref == "standing" or "start_date" not in headers):
119
+ headers["start_date"] = start_date
115
120
 
116
- if tpref == "standing" or "finish_date" not in headers:
117
- headers["finish_date"] = _to_finish_date(cedt[0])
121
+ finish_date = _to_finish_date(cedt[0])
122
+ if finish_date is not None and (
123
+ tpref == "standing" or "finish_date" not in headers
124
+ ):
125
+ headers["finish_date"] = finish_date
118
126
 
119
- if "mprn" not in headers:
120
- headers["mprn"] = mloc[0]
127
+ mprn = mloc[0]
128
+ if "mprn" not in headers and len(mprn) > 0:
129
+ headers["mprn"] = mprn
121
130
 
122
131
  if len(conb) > 0 and len(conb[0]) > 0:
123
132
  headers["breakdown"]["units_consumed"] += to_decimal(conb) / Decimal("1000")
@@ -152,6 +161,93 @@ def _process_CCD2(elements, headers):
152
161
  )
153
162
 
154
163
 
164
+ def _process_CCD3(elements, headers):
165
+ breakdown = headers["breakdown"]
166
+ ccde = elements["CCDE"]
167
+ nuct = elements["NUCT"]
168
+ mtnr = elements["MTNR"]
169
+ conb = elements["CONB"]
170
+ adjf = elements["ADJF"]
171
+ prdt = elements["PRDT"]
172
+ pvdt = elements["PVDT"]
173
+ prrd = elements["PRRD"]
174
+ cppu = elements["CPPU"]
175
+ ctot = elements["CTOT"]
176
+ csdt = elements["CSDT"]
177
+ cedt = elements["CEDT"]
178
+ mloc = elements["MLOC"]
179
+
180
+ ccde_supplier_code = ccde[2]
181
+ tpref, rate_divisor, units_divisor = SUPPLIER_CODE_MAP[ccde_supplier_code]
182
+
183
+ rate_str = cppu[0]
184
+ if len(rate_str.strip()) > 0:
185
+ rate_key = f"{tpref}_rate"
186
+ if rate_key not in breakdown:
187
+ breakdown[rate_key] = set()
188
+ rate = Decimal(rate_str) / rate_divisor
189
+ breakdown[rate_key].add(rate)
190
+
191
+ breakdown[f"{tpref}_gbp"] += to_decimal(ctot) / Decimal("100")
192
+
193
+ if len(nuct) > 1:
194
+ suff = NUCT_LOOKUP[nuct[1].strip()]
195
+ key = f"{tpref}_{suff}"
196
+ units_billed = to_decimal(nuct) / units_divisor
197
+ breakdown[key] += units_billed
198
+
199
+ start_date = to_date(csdt[0])
200
+ if start_date is not None and (tpref == "standing" or "start_date" not in headers):
201
+ headers["start_date"] = start_date
202
+
203
+ finish_date = _to_finish_date(cedt[0])
204
+ if finish_date is not None and (
205
+ tpref == "standing" or "finish_date" not in headers
206
+ ):
207
+ headers["finish_date"] = finish_date
208
+
209
+ mprn = mloc[0]
210
+ if "mprn" not in headers and len(mprn) > 0:
211
+ headers["mprn"] = mprn
212
+
213
+ if len(conb) > 0 and len(conb[0]) > 0:
214
+ headers["breakdown"]["units_consumed"] += to_decimal(conb) / Decimal("1000")
215
+
216
+ if tpref == "commodity":
217
+ headers["kwh"] += units_billed
218
+
219
+ if len(prrd) > 0 and len(prrd[0]) > 0:
220
+ pres_read_date = to_date(prdt[0])
221
+ prev_read_date = to_date(pvdt[0])
222
+
223
+ pres_read_value = Decimal(prrd[0])
224
+ pres_read_type = READ_TYPE_MAP[prrd[1]]
225
+ prev_read_value = Decimal(prrd[2])
226
+ prev_read_type = READ_TYPE_MAP[prrd[3]]
227
+ msn = mtnr[0]
228
+ unit = UNIT_MAP[conb[1]]
229
+ correction_factor = Decimal(adjf[1]) / Decimal(100000)
230
+
231
+ headers["reads"].append(
232
+ {
233
+ "msn": msn,
234
+ "unit": unit,
235
+ "correction_factor": correction_factor,
236
+ "prev_date": prev_read_date,
237
+ "prev_value": prev_read_value,
238
+ "prev_type_code": prev_read_type,
239
+ "pres_date": pres_read_date,
240
+ "pres_value": pres_read_value,
241
+ "pres_type_code": pres_read_type,
242
+ }
243
+ )
244
+
245
+
246
+ def _process_CLO(elements, headers):
247
+ cloc = elements["CLOC"]
248
+ headers["account"] = cloc[2]
249
+
250
+
155
251
  def _process_MTR(elements, headers):
156
252
  if headers["message_type"] == "UTLBIL":
157
253
  breakdown = headers["breakdown"]
@@ -159,11 +255,35 @@ def _process_MTR(elements, headers):
159
255
  if isinstance(v, set):
160
256
  breakdown[k] = sorted(v)
161
257
 
258
+ account = headers["account"]
259
+ try:
260
+ mprn = headers["mprn"]
261
+ except KeyError:
262
+ with Session() as sess:
263
+ g_era = sess.scalars(
264
+ select(GEra)
265
+ .where(GEra.account == account)
266
+ .order_by(GEra.start_date)
267
+ ).first()
268
+ if g_era is None:
269
+ raise BadRequest(
270
+ f"Couldn't find an MPRN, and then couldn't fine a supply "
271
+ f"with account {account}."
272
+ )
273
+ else:
274
+ mprn = g_era.g_supply.mprn
275
+
276
+ start_date = headers["start_date"]
277
+ if "finish_date" in headers:
278
+ finish_date = headers["finish_date"]
279
+ else:
280
+ finish_date = start_date
281
+
162
282
  return {
163
283
  "raw_lines": "\n".join(headers["raw_lines"]),
164
- "mprn": headers["mprn"],
284
+ "mprn": mprn,
165
285
  "reference": headers["reference"],
166
- "account": headers["mprn"],
286
+ "account": account,
167
287
  "reads": headers["reads"],
168
288
  "kwh": headers["kwh"],
169
289
  "breakdown": headers["breakdown"],
@@ -171,8 +291,8 @@ def _process_MTR(elements, headers):
171
291
  "vat_gbp": headers["vat"],
172
292
  "gross_gbp": headers["gross"],
173
293
  "bill_type_code": headers["bill_type_code"],
174
- "start_date": headers["start_date"],
175
- "finish_date": headers["finish_date"],
294
+ "start_date": start_date,
295
+ "finish_date": finish_date,
176
296
  "issue_date": headers["issue_date"],
177
297
  }
178
298
 
@@ -215,10 +335,10 @@ CODE_FUNCS = {
215
335
  "BTL": _process_NOOP,
216
336
  "CCD1": _process_NOOP,
217
337
  "CCD2": _process_CCD2,
218
- "CCD3": _process_NOOP,
338
+ "CCD3": _process_CCD3,
219
339
  "CCD4": _process_NOOP,
220
340
  "CDT": _process_NOOP,
221
- "CLO": _process_NOOP,
341
+ "CLO": _process_CLO,
222
342
  "END": _process_NOOP,
223
343
  "FIL": _process_NOOP,
224
344
  "MHD": _process_MHD,
@@ -23,7 +23,7 @@
23
23
  <form method="post">
24
24
  <fieldset>
25
25
  <legend>Update details</legend>
26
- <label>Username</label>
26
+ <label>Username (case sensitive)</label>
27
27
  <input name="email_address" size="100" value="
28
28
  {%- if request.values.email_address -%}
29
29
  {{ request.values.email_address }}
@@ -67,11 +67,11 @@
67
67
  <fieldset>
68
68
  <legend>Change password</legend>
69
69
  <input type="hidden" name="change_password">
70
- <label>Current password</label>
70
+ <label>Current password (case sensitive)</label>
71
71
  <input type="password" name="current_password">
72
- <label>New password</label>
72
+ <label>New password (case sensitive)</label>
73
73
  <input type="password" name="new_password">
74
- <label>Confirm new Password</label>
74
+ <label>Confirm new Password (case sensitive)</label>
75
75
  <input type="password" name="confirm_new_password">
76
76
  <input type="submit" value="Change">
77
77
  </fieldset>
@@ -50,10 +50,10 @@
50
50
  <fieldset>
51
51
  <legend>Add new user</legend>
52
52
 
53
- <label>Username</label>
53
+ <label>Username (case sensitive)</label>
54
54
  {{input_text('email_address')}}
55
55
  {% if not ad_auth_on %}
56
- <label>Password</label>
56
+ <label>Password (case sensitive)</label>
57
57
  <input type="password" name="password">
58
58
  {% endif %}
59
59
  <fieldset>
@@ -74,24 +74,6 @@
74
74
  checked
75
75
  {% endif %}
76
76
  >
77
- <label>Party Viewer</label>
78
- <input type="radio" name="user_role_code" value="party-viewer"
79
- {% if request.values.user_role_code == 'party-viewer' %}
80
- checked
81
- {% endif %}
82
- >
83
- <label>Party Viewer Party</label>
84
- <select name="party_id">
85
- {% for party in parties %}
86
- <option value="{{ party.id }}"
87
- {%- if request.values.user_role_id == party.id -%}
88
- selected
89
- {% endif %}
90
- >{{ party.name }} {{ party.participant.code }}
91
- {{ party.market_role.description }}
92
- </option>
93
- {% endfor %}
94
- </select>
95
77
  </fieldset>
96
78
  <input type="submit" value="Add">
97
79
  </fieldset>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1729012049.0.0
3
+ Version: 1729081025.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)
@@ -63,7 +63,7 @@ chellow/e/bill_parsers/sww_xls.py,sha256=QEjiuvwvr5FuWCfqqVw8LaA_vZyAKsvRAS5fw3x
63
63
  chellow/gas/bill_import.py,sha256=w0lPgK_Drzh8rtnEBQe3qFuxrgzZ6qQSgpaGrrGznMU,6549
64
64
  chellow/gas/bill_parser_csv.py,sha256=Ecdy-apFT-mWAxddAsM4k1s-9-FpIaOfjP0oFc0rdQg,5557
65
65
  chellow/gas/bill_parser_engie_edi.py,sha256=Ko0vZP-QdVQ1uuhS_5cdrii60_cM4b_LFJMoY0pZqnk,8950
66
- chellow/gas/bill_parser_total_edi.py,sha256=HdX2ctKvqIA5saf8VkpWmYWfqaZsdB-sAEcMSZjTgE4,7425
66
+ chellow/gas/bill_parser_total_edi.py,sha256=bMAeIkzHwNhv0qdKYXtRl-tzUUYtjNkbM3PMl3NurFc,11225
67
67
  chellow/gas/ccl.py,sha256=DMlcPUELZi00CaDekVJINYk3GgH5apFrImVdmkbyba0,2913
68
68
  chellow/gas/cv.py,sha256=4cdYYQ8Qak6NeYdBCB4YaQ0jX8-UkaydIIdibCQuXxM,7344
69
69
  chellow/gas/dn_rate_parser.py,sha256=Mq8rAcUEUxIQOks59bsCKl8GrefvoHbrTCHqon9N0z0,11340
@@ -155,9 +155,9 @@ chellow/templates/sites.html,sha256=4ouJ5xYqYHjXCv3cDucTjgbOd_whReFPPHopLBdW6Go,
155
155
  chellow/templates/supplies.html,sha256=Ie_4K4-KwXqrCBwaUcjWxmV27rYjeESI_DCS9gLUipk,3488
156
156
  chellow/templates/system.html,sha256=PP8MN8mieil3AwLS1WlQBcgbl0J61bksN-Cy4toYNqo,1871
157
157
  chellow/templates/tester.html,sha256=4DYrtcnFY0y6o3K6_tSmFpPlCRngZj1zo8nJ1NI4pk8,623
158
- chellow/templates/user.html,sha256=tUeE5v-MOayJD_vP1P4g1ruoVMCTcbk-u28fOVTPj84,2412
158
+ chellow/templates/user.html,sha256=bv1AuqnU_GFELaIbDaXSZ3FK6XJaM8so5fOkE8pVpPY,2480
159
159
  chellow/templates/user_roles.html,sha256=Pfjr4uApEmJl8t9s0qJTxigQcAVYw7gpV_ECE8c0Cto,399
160
- chellow/templates/users.html,sha256=dBB0yOvsoYbY_I9le1XGqZ0SlesUbWMqfRGlZOtOgNs,2244
160
+ chellow/templates/users.html,sha256=F2eS3ow3VrxA-FnSbWK2Z-9mtPhZeC-VNPVWDXDWZHM,1706
161
161
  chellow/templates/e/asset_comparison.html,sha256=QyN3WMw8YoFaSWUvD2NOnRLdLdB3Kv6m3t8Id8Mb6_A,678
162
162
  chellow/templates/e/channel.html,sha256=R5fhdsHvhB7k57Rw_gviUQ7_EXBGwP05E691V1BUNSQ,2056
163
163
  chellow/templates/e/channel_add.html,sha256=szwQJBHx2kAoSFomXDHD0N_7PSd4drqOoAWhM-jvSqM,1676
@@ -369,6 +369,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
369
369
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
370
370
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
371
371
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
372
- chellow-1729012049.0.0.dist-info/METADATA,sha256=KGncQBfTFXII_d4142UqVWnPjzQDIkmVbxHvd9Bj9-Y,12204
373
- chellow-1729012049.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
374
- chellow-1729012049.0.0.dist-info/RECORD,,
372
+ chellow-1729081025.0.0.dist-info/METADATA,sha256=Ygi8fee2scaBMTgIk5iIgnwRKmnpuhknbCNGFdn-VHU,12204
373
+ chellow-1729081025.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
374
+ chellow-1729081025.0.0.dist-info/RECORD,,