chellow 1728986476.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.

@@ -172,7 +172,8 @@ def _handle_0461(headers, pre_record, record):
172
172
  mpan_core = parse_mpan_core(parts["mpan_core"])
173
173
  headers["mpan_core"] = mpan_core
174
174
  units = CONSUMPTION_UNITS_LOOKUP[parts["units"].strip()]
175
- if units == "kWh":
175
+ register_code = parts["register_code"].strip()
176
+ if units == "kWh" and not register_code.startswith("NOCHARGE"):
176
177
  headers["kwh"] += Decimal(parts["quantity"])
177
178
 
178
179
  prev_read_date_str = parts["prev_read_date"].strip()
chellow/e/computer.py CHANGED
@@ -993,7 +993,10 @@ class SupplySource(DataSource):
993
993
  else:
994
994
  self.llfc = era.imp_llfc
995
995
 
996
- self.sc = era.imp_sc
996
+ if "imp_sc" in self.era_map:
997
+ self.sc = self.era_map["imp_sc"]
998
+ else:
999
+ self.sc = era.imp_sc
997
1000
  self.supplier_account = era.imp_supplier_account
998
1001
 
999
1002
  if era.imp_supplier_contract.id in self.era_map_supplier_contracts:
@@ -1020,7 +1023,10 @@ class SupplySource(DataSource):
1020
1023
  else:
1021
1024
  self.llfc = era.exp_llfc
1022
1025
 
1023
- self.sc = 0 if era.exp_sc is None else era.exp_sc
1026
+ if "exp_sc" in self.era_map:
1027
+ self.sc = self.era_map["exp_sc"]
1028
+ else:
1029
+ self.sc = era.exp_sc
1024
1030
  self.supplier_account = era.exp_supplier_account
1025
1031
 
1026
1032
  if era.exp_supplier_contract is None:
@@ -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,
@@ -83,7 +83,8 @@
83
83
  "new_export": 3,
84
84
  9: 51
85
85
  },
86
- "sc": 400,
86
+ "imp_sc": 400,
87
+ "exp_sc": 400,
87
88
  "mpan_cores": {
88
89
  "22 8679 7237 782": "20 7568 7217 378"
89
90
  }
@@ -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: 1728986476.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)
@@ -20,7 +20,7 @@ chellow/e/bmarketidx.py,sha256=C0BaHn2RxIuWH2QzA-OmSP0fbUGvW9tqEUhLnzOEdmA,7968
20
20
  chellow/e/bsuos.py,sha256=hdP9vnOJSuZl46OAkJeUg1XJYvYIBj4J6Sqce1Hy9Vs,15542
21
21
  chellow/e/ccl.py,sha256=30dh_SvlgzsTQPPAJNZWILaMvbeDsv9-P-S1JxS5_SQ,3184
22
22
  chellow/e/cfd.py,sha256=Gm435c42LFwZx1n-1UY1Tdx6mL1is7E0vRLWQe8RPOo,14184
23
- chellow/e/computer.py,sha256=CoYf9SA8zrh1NP_S1jKsfXsaBm5kFcjBbtPUJnx8M9A,67274
23
+ chellow/e/computer.py,sha256=24aBfC-aYoTseRwQSNRAb1PwTKp0zL9aispceL8drcU,67469
24
24
  chellow/e/dno_rate_parser.py,sha256=A5TP6KjyfT5lVWh7dX4SiXRi6wnf2lGv-H_T4Sod8CI,21731
25
25
  chellow/e/duos.py,sha256=nwviRjz-qIt3GxIMHk0hItIT4dtKsxOWq9TUC1z-hO8,30864
26
26
  chellow/e/elexon.py,sha256=ALhXS9Es7PV0z9ukPbIramn3cf3iLyFi-PMWPSm5iOs,5487
@@ -55,7 +55,7 @@ chellow/e/bill_parsers/gdf_csv.py,sha256=ZfK3Oc6oP28p_P9DIevLNB_zW2WLcEJ3Lvb1gL3
55
55
  chellow/e/bill_parsers/haven_csv.py,sha256=0uENq8IgVNqdxfBQMBxLTSZWCOuDHXZC0xzk52SbfyE,13652
56
56
  chellow/e/bill_parsers/haven_edi.py,sha256=YGPHRxPOhje9s32jqPHHELni2tooOYj3cMC_qaZVPq4,16107
57
57
  chellow/e/bill_parsers/haven_edi_tprs.py,sha256=ZVX9CCqUybsot_Z0BEOJPvl9x5kSr7fEWyuJXvZDcz4,11841
58
- chellow/e/bill_parsers/mm.py,sha256=hlMglK7UvVJs0AgHe3uWxcOSPuVVjt-29Xhlj3CvN4E,9942
58
+ chellow/e/bill_parsers/mm.py,sha256=56_nfXNrt_ZZRwoHnj5xTi6Emh9I2wY4JJSaNxmwcCc,10038
59
59
  chellow/e/bill_parsers/nonsettlement_dc_stark_xlsx.py,sha256=yogXTuQHGRL7IiqvRWr2C9V24ez1j9Yx0128UygPE_k,4723
60
60
  chellow/e/bill_parsers/settlement_dc_stark_xlsx.py,sha256=PlEqCZuJ9DfQXeeYQ64jtf3ML7sUt_tt61QOOTnkE5c,6380
61
61
  chellow/e/bill_parsers/sse_edi.py,sha256=L85DOfNkqexeEIEr8pCBn_2sHJI-zEaw6cogpE3YyYM,15204
@@ -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
@@ -278,7 +278,7 @@ chellow/templates/e/read_type.html,sha256=volKteZB79famXrzN_Bgqy9JT9C4a50vXLkuZ0
278
278
  chellow/templates/e/read_types.html,sha256=CknHXNEkBnsAprqI66ftvnnMFBdR_kqI7o26rxjlrJA,473
279
279
  chellow/templates/e/scenario.html,sha256=E8o3WQwAEejzaMPzeuUqyt9fWWNSDtN96qkJz0slDEo,1522
280
280
  chellow/templates/e/scenario_add.html,sha256=qQpxvhlrQqrNYiIQTHu_NvSoeSKuRNEJQYwLqRlQ8_U,516
281
- chellow/templates/e/scenario_docs.html,sha256=-aFljSJhiOEKaAb0omOo9kDjnwMarEaFNo-dSYoiwLc,4946
281
+ chellow/templates/e/scenario_docs.html,sha256=QxcX30Y0EJ0KDH0OBZs91a48FSehUEpT8qT1QhuXnRk,4971
282
282
  chellow/templates/e/scenario_edit.html,sha256=Uf64v_qsBP0BxaFEIz214CC_dZXlvro4zvQXH_towhA,1070
283
283
  chellow/templates/e/scenarios.html,sha256=zlNhZvQEcuwLgHObVHS-4THur5Lz9Jf1G6xD98-jamI,847
284
284
  chellow/templates/e/site_add_e_supply.html,sha256=_gi1ejI4TMTMX9vCW7z2kToR2XKR6qoVh67qp_VrDsM,2731
@@ -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-1728986476.0.0.dist-info/METADATA,sha256=Ok78n_Nora0YJLcFiP8BesoLcDRKSM8OKZWHFjMZ-Tk,12204
373
- chellow-1728986476.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
374
- chellow-1728986476.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,,