chellow 1751980348.0.0__py3-none-any.whl → 1752483970.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/__init__.py +45 -18
- chellow/e/bill_parsers/drax_edi.py +6 -2
- chellow/e/bill_parsers/mm.py +17 -12
- chellow/views.py +5 -0
- {chellow-1751980348.0.0.dist-info → chellow-1752483970.0.0.dist-info}/METADATA +2 -2
- {chellow-1751980348.0.0.dist-info → chellow-1752483970.0.0.dist-info}/RECORD +7 -7
- {chellow-1751980348.0.0.dist-info → chellow-1752483970.0.0.dist-info}/WHEEL +0 -0
chellow/__init__.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import json
|
|
1
2
|
import os
|
|
3
|
+
from base64 import b64decode
|
|
2
4
|
from datetime import datetime as Datetime
|
|
3
5
|
from importlib.metadata import version
|
|
4
6
|
from pathlib import Path
|
|
@@ -127,17 +129,45 @@ def create_app(testing=False, instance_path=None):
|
|
|
127
129
|
g.config = {}
|
|
128
130
|
ad_props = g.config.get("ad_authentication", {})
|
|
129
131
|
ad_auth_on = ad_props.get("on", False)
|
|
132
|
+
easy_auth_props = g.config.get("easy_auth", {})
|
|
133
|
+
easy_auth_on = easy_auth_props.get("on", False)
|
|
134
|
+
path = request.path
|
|
135
|
+
if path in ("/health", "/robots933456.txt"):
|
|
136
|
+
return
|
|
130
137
|
if ad_auth_on:
|
|
131
138
|
username = request.headers["X-Isrw-Proxy-Logon-User"].upper()
|
|
132
|
-
user = g.sess.
|
|
139
|
+
user = g.sess.scalars(
|
|
140
|
+
select(User).where(User.email_address == username)
|
|
141
|
+
).first()
|
|
133
142
|
if user is None:
|
|
134
143
|
try:
|
|
135
144
|
username = ad_props["default_user"]
|
|
136
|
-
user = (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
user = g.sess.scalars(
|
|
146
|
+
select(User).where(User.email_address == username)
|
|
147
|
+
).first()
|
|
148
|
+
except KeyError:
|
|
149
|
+
user = None
|
|
150
|
+
if user is not None:
|
|
151
|
+
g.user = user
|
|
152
|
+
elif easy_auth_on:
|
|
153
|
+
jwt_enc = request.headers["X-MS-CLIENT-PRINCIPAL"]
|
|
154
|
+
jwt = json.loads(b64decode(jwt_enc))
|
|
155
|
+
for claim in jwt["claims"]:
|
|
156
|
+
if claim["typ"] == (
|
|
157
|
+
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/"
|
|
158
|
+
"emailaddress"
|
|
159
|
+
):
|
|
160
|
+
username = claim["val"]
|
|
161
|
+
user = g.sess.scalars(
|
|
162
|
+
select(User).where(User.email_address == username)
|
|
163
|
+
).first()
|
|
164
|
+
break
|
|
165
|
+
if user is None:
|
|
166
|
+
try:
|
|
167
|
+
username = easy_auth_props["default_user"]
|
|
168
|
+
user = g.sess.scalars(
|
|
169
|
+
select(User).where(User.email_address == username)
|
|
170
|
+
).first()
|
|
141
171
|
except KeyError:
|
|
142
172
|
user = None
|
|
143
173
|
if user is not None:
|
|
@@ -156,25 +186,20 @@ def create_app(testing=False, instance_path=None):
|
|
|
156
186
|
key = None
|
|
157
187
|
|
|
158
188
|
email = ips[key]
|
|
159
|
-
g.user = (
|
|
160
|
-
|
|
161
|
-
)
|
|
189
|
+
g.user = g.sess.scalars(
|
|
190
|
+
select(User).where(User.email_address == email)
|
|
191
|
+
).first()
|
|
162
192
|
except KeyError:
|
|
163
193
|
pass
|
|
164
194
|
else:
|
|
165
|
-
user = (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
.first()
|
|
169
|
-
)
|
|
195
|
+
user = g.sess.scalars(
|
|
196
|
+
select(User).where(User.email_address == auth.username)
|
|
197
|
+
).first()
|
|
170
198
|
if user is not None and user.password_matches(auth.password):
|
|
171
199
|
g.user = user
|
|
172
200
|
|
|
173
201
|
# Got our user
|
|
174
|
-
path = request.path
|
|
175
202
|
method = request.method
|
|
176
|
-
if path in ("/health",):
|
|
177
|
-
return
|
|
178
203
|
|
|
179
204
|
if g.user is not None:
|
|
180
205
|
if "X-Isrw-Proxy-Logon-User" in request.headers:
|
|
@@ -227,7 +252,9 @@ def create_app(testing=False, instance_path=None):
|
|
|
227
252
|
g.sess.commit()
|
|
228
253
|
return
|
|
229
254
|
|
|
230
|
-
if
|
|
255
|
+
if (not easy_auth_on) and (
|
|
256
|
+
(g.user is None) or (not ad_auth_on and auth is None)
|
|
257
|
+
):
|
|
231
258
|
return Response(
|
|
232
259
|
"Could not verify your access level for that URL.\n"
|
|
233
260
|
"You have to login with proper credentials",
|
|
@@ -51,7 +51,11 @@ ELEMENT_MAP = {
|
|
|
51
51
|
"cfd-operational-kwh",
|
|
52
52
|
),
|
|
53
53
|
"954379": ("cfd-interim-gbp", "cfd-interim-rate", "cfd-interim-kwh"),
|
|
54
|
-
"538249": (
|
|
54
|
+
"538249": (
|
|
55
|
+
"cm-settlement-levy-gbp",
|
|
56
|
+
"cm-settlement-levy-rate",
|
|
57
|
+
"cm-settlement-levy-kwh",
|
|
58
|
+
),
|
|
55
59
|
"568307": ("capacity-gbp", "capacity-rate", "capacity-kwh"),
|
|
56
60
|
},
|
|
57
61
|
},
|
|
@@ -104,6 +108,7 @@ ELEMENT_MAP = {
|
|
|
104
108
|
"duos-availability-kva",
|
|
105
109
|
),
|
|
106
110
|
"209269": ("tnuos-gbp", "tnuos-rate", "tnuos-days"),
|
|
111
|
+
"065950": ("eii-gbp", "eii-rate", "eii-kwh"),
|
|
107
112
|
},
|
|
108
113
|
"DUSDIS": {
|
|
109
114
|
"122568": ("nrg-gsp-losses-gbp", "nrg-rate", "nrg-gsp-losses-kwh"),
|
|
@@ -149,7 +154,6 @@ ELEMENT_MAP = {
|
|
|
149
154
|
"930504": ("eii-gbp", None, None),
|
|
150
155
|
"331201": ("eii-gbp", None, None),
|
|
151
156
|
"307253": ("eii-gbp", "eii-rate", "eii-kwh"),
|
|
152
|
-
"065950": ("eii-gbp", "eii-rate", "eii-kwh"),
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
TPR_LOOKUP = {
|
chellow/e/bill_parsers/mm.py
CHANGED
|
@@ -47,7 +47,9 @@ def _handle_0050(headers, pre_record, record):
|
|
|
47
47
|
unknown_4=12,
|
|
48
48
|
late_payment=12,
|
|
49
49
|
)
|
|
50
|
-
headers["late_payment"]
|
|
50
|
+
headers["breakdown"]["late_payment"] += Decimal(parts["late_payment"]) / Decimal(
|
|
51
|
+
100
|
|
52
|
+
)
|
|
51
53
|
"""
|
|
52
54
|
|
|
53
55
|
|
|
@@ -57,13 +59,10 @@ def _handle_0051(headers, pre_record, record):
|
|
|
57
59
|
|
|
58
60
|
def _handle_0100(headers, pre_record, record):
|
|
59
61
|
issue_date = headers["issue_date"]
|
|
60
|
-
late_payment = headers.get("late_payment")
|
|
61
62
|
headers.clear()
|
|
62
63
|
headers["issue_date"] = issue_date
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
headers["account"] = pre_record[43:52]
|
|
66
|
-
headers["reference"] = pre_record[41:46]
|
|
64
|
+
headers["account"] = pre_record[42:52]
|
|
65
|
+
headers["reference"] = pre_record[52:64]
|
|
67
66
|
headers["kwh"] = Decimal("0")
|
|
68
67
|
headers["breakdown"] = defaultdict(int, {"vat": {}})
|
|
69
68
|
headers["reads"] = []
|
|
@@ -245,6 +244,17 @@ def _handle_0860(headers, pre_record, record):
|
|
|
245
244
|
bd["metering-gbp"] += Decimal(parts["metering_gbp"]) / Decimal("100")
|
|
246
245
|
|
|
247
246
|
|
|
247
|
+
def _handle_0960(headers, pre_record, record):
|
|
248
|
+
parts = _chop_record(
|
|
249
|
+
record,
|
|
250
|
+
days=3,
|
|
251
|
+
payment=12,
|
|
252
|
+
rate=6,
|
|
253
|
+
)
|
|
254
|
+
bd = headers["breakdown"]
|
|
255
|
+
bd["late_payment_gbp"] += Decimal(parts["payment"]) / Decimal(100)
|
|
256
|
+
|
|
257
|
+
|
|
248
258
|
def _handle_1455(headers, pre_record, record):
|
|
249
259
|
parts = _chop_record(
|
|
250
260
|
record, ccl_kwh=13, unknown_1=10, ccl_rate=13, ccl_gbp=12, unkown_2=8
|
|
@@ -294,12 +304,6 @@ def _handle_1500(headers, pre_record, record):
|
|
|
294
304
|
breakdown = headers["breakdown"]
|
|
295
305
|
net = Decimal("0.00") + Decimal(parts["net"]) / Decimal("100")
|
|
296
306
|
gross = Decimal("0.00") + Decimal(parts["gross"]) / Decimal("100")
|
|
297
|
-
if "late_payment" in headers:
|
|
298
|
-
late_payment_gbp = headers["late_payment"]
|
|
299
|
-
net += late_payment_gbp
|
|
300
|
-
gross += late_payment_gbp
|
|
301
|
-
breakdown["late-payment-gbp"] += late_payment_gbp
|
|
302
|
-
del headers["late_payment"]
|
|
303
307
|
|
|
304
308
|
return {
|
|
305
309
|
"bill_type_code": "W" if net < 0 else "N",
|
|
@@ -354,6 +358,7 @@ LINE_HANDLERS = {
|
|
|
354
358
|
"0461": _handle_0461,
|
|
355
359
|
"0470": _handle_0470,
|
|
356
360
|
"0860": _handle_0860,
|
|
361
|
+
"0960": _handle_0960,
|
|
357
362
|
"1455": _handle_1455,
|
|
358
363
|
"1460": _handle_1460,
|
|
359
364
|
"1500": _handle_1500,
|
chellow/views.py
CHANGED
|
@@ -198,6 +198,11 @@ def health():
|
|
|
198
198
|
return Response("healthy\n", mimetype="text/plain")
|
|
199
199
|
|
|
200
200
|
|
|
201
|
+
@home.route("/robots933456.txt")
|
|
202
|
+
def robots():
|
|
203
|
+
return Response("healthy\n", mimetype="text/plain")
|
|
204
|
+
|
|
205
|
+
|
|
201
206
|
@home.route("/local_reports/<int:report_id>/output")
|
|
202
207
|
def local_report_output_get(report_id):
|
|
203
208
|
report = g.sess.execute(select(Report).where(Report.id == report_id)).scalar_one()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chellow
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1752483970.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,7 +22,7 @@ Requires-Dist: pypdf==4.3.1
|
|
|
22
22
|
Requires-Dist: python-dateutil==2.8.2
|
|
23
23
|
Requires-Dist: pytz==2022.6
|
|
24
24
|
Requires-Dist: requests==2.32.4
|
|
25
|
-
Requires-Dist: sqlalchemy==2.0.
|
|
25
|
+
Requires-Dist: sqlalchemy==2.0.41
|
|
26
26
|
Requires-Dist: waitress==3.0.1
|
|
27
27
|
Requires-Dist: xlrd==2.0.1
|
|
28
28
|
Requires-Dist: zish==0.1.12
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
chellow/__init__.py,sha256=
|
|
1
|
+
chellow/__init__.py,sha256=9aoSbGmHCIHwzI_c_TLSg5CeKwqAq0I6kKaMvTrTMqg,10936
|
|
2
2
|
chellow/api.py,sha256=mk17TfweR76DPFC8lX2SArTjai6y6YshASxqO1w-_-s,11036
|
|
3
3
|
chellow/bank_holidays.py,sha256=T_utYMwe_g1dz5X-aOTdIPryg49SvB7QsWM1yphlqG8,4423
|
|
4
4
|
chellow/commands.py,sha256=ESBe9ZWj1c3vdZgqMZ9gFvYAB3hRag2R1PzOwuw9yFo,1302
|
|
@@ -13,7 +13,7 @@ chellow/rate_server.py,sha256=fg-Pf_9Hk3bXmC9riPQNGQxBvLvBa_WtNYdwDCjnCSg,5678
|
|
|
13
13
|
chellow/rrun.py,sha256=1Kt2q_K9UoDG_nsZz-Q6XJiMNKroWqlqFdxn2M6Q8CA,2088
|
|
14
14
|
chellow/testing.py,sha256=Dj2c1NX8lVlygueOrh2eyYawLW6qKEHxNhXVVUaNRO0,3637
|
|
15
15
|
chellow/utils.py,sha256=i3GQK9MIcweosZk2gi-nX_IFq2DxURAJDyNoLBg6YwM,19421
|
|
16
|
-
chellow/views.py,sha256=
|
|
16
|
+
chellow/views.py,sha256=fPCuYTWXAAWnu1Cwt4Dk3k7PHNj9gw9HeQRiXgRIn60,85459
|
|
17
17
|
chellow/e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
chellow/e/aahedc.py,sha256=d2usudp7KYWpU6Pk3fal5EQ47EbvkvKeaFGylnb3NWw,606
|
|
19
19
|
chellow/e/bill_importer.py,sha256=7UcnqNlKbJc2GhW9gy8sDp9GuqambJVpZLvbafOZztA,7411
|
|
@@ -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=
|
|
53
|
+
chellow/e/bill_parsers/drax_edi.py,sha256=vAVH8nnHqkwacmHiP88vFGHBKlH9k59YIf1G-7P05Yg,15184
|
|
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=PDMDI0aqUM1lalgzxih1YmMho11n1rMqE0vyL-aEIs8,15840
|
|
@@ -61,7 +61,7 @@ chellow/e/bill_parsers/gdf_csv.py,sha256=ZfK3Oc6oP28p_P9DIevLNB_zW2WLcEJ3Lvb1gL3
|
|
|
61
61
|
chellow/e/bill_parsers/haven_csv.py,sha256=0uENq8IgVNqdxfBQMBxLTSZWCOuDHXZC0xzk52SbfyE,13652
|
|
62
62
|
chellow/e/bill_parsers/haven_edi.py,sha256=YGPHRxPOhje9s32jqPHHELni2tooOYj3cMC_qaZVPq4,16107
|
|
63
63
|
chellow/e/bill_parsers/haven_edi_tprs.py,sha256=ZVX9CCqUybsot_Z0BEOJPvl9x5kSr7fEWyuJXvZDcz4,11841
|
|
64
|
-
chellow/e/bill_parsers/mm.py,sha256=
|
|
64
|
+
chellow/e/bill_parsers/mm.py,sha256=1myKrms3yVAhKFCzk3swWJjCwepZYk8GkD0wK0bpsj4,11184
|
|
65
65
|
chellow/e/bill_parsers/nonsettlement_dc_stark_xlsx.py,sha256=YvQ0Q6HlZ4XSk6Phx1UWaTSj8FREVjwQe8nrpiLVzbU,5458
|
|
66
66
|
chellow/e/bill_parsers/settlement_dc_stark_xlsx.py,sha256=osCpUYUdLcPtlo7ngXWGw0ImnxssLa1fOSejMwe51-k,6381
|
|
67
67
|
chellow/e/bill_parsers/sse_edi.py,sha256=L85DOfNkqexeEIEr8pCBn_2sHJI-zEaw6cogpE3YyYM,15204
|
|
@@ -385,6 +385,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
|
|
|
385
385
|
chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
|
|
386
386
|
chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
|
|
387
387
|
chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
|
|
388
|
-
chellow-
|
|
389
|
-
chellow-
|
|
390
|
-
chellow-
|
|
388
|
+
chellow-1752483970.0.0.dist-info/METADATA,sha256=2YZ1h5mTfgfRUr2ArLYeDbtIli2e5Mbvn5TaFKA1PY8,12585
|
|
389
|
+
chellow-1752483970.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
390
|
+
chellow-1752483970.0.0.dist-info/RECORD,,
|
|
File without changes
|