chellow 1705585731.0.0__py3-none-any.whl → 1706020835.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/e/cfd.py +81 -24
- chellow/e/triad.py +17 -2
- {chellow-1705585731.0.0.dist-info → chellow-1706020835.0.0.dist-info}/METADATA +1 -1
- {chellow-1705585731.0.0.dist-info → chellow-1706020835.0.0.dist-info}/RECORD +5 -5
- {chellow-1705585731.0.0.dist-info → chellow-1706020835.0.0.dist-info}/WHEEL +0 -0
chellow/e/cfd.py
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
from datetime import datetime as Datetime
|
|
2
2
|
|
|
3
3
|
from dateutil.relativedelta import relativedelta
|
|
4
|
+
|
|
4
5
|
from sqlalchemy import null, or_, select
|
|
5
6
|
|
|
7
|
+
from werkzeug.exceptions import BadRequest
|
|
8
|
+
|
|
6
9
|
from chellow.e.lcc import api_search, api_sql
|
|
7
10
|
from chellow.models import Contract, RateScript
|
|
8
11
|
from chellow.utils import ct_datetime, hh_format, to_ct, to_utc
|
|
9
12
|
|
|
10
13
|
|
|
11
|
-
def hh(data_source):
|
|
14
|
+
def hh(data_source, use_bill_check=False):
|
|
12
15
|
try:
|
|
13
16
|
cfd_cache = data_source.caches["cfd"]
|
|
14
17
|
except KeyError:
|
|
@@ -19,47 +22,60 @@ def hh(data_source):
|
|
|
19
22
|
h["cfd-rate"] = cfd_cache[h["start-date"]]
|
|
20
23
|
except KeyError:
|
|
21
24
|
h_start = h["start-date"]
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
RateScript.finish_date == null(),
|
|
31
|
-
RateScript.finish_date >= h_start,
|
|
32
|
-
),
|
|
25
|
+
if use_bill_check:
|
|
26
|
+
base_rate = (
|
|
27
|
+
float(
|
|
28
|
+
data_source.non_core_rate("cfd_forecast_ilr_tra", h_start)[
|
|
29
|
+
"record"
|
|
30
|
+
]["Interim_Levy_Rate_GBP_Per_MWh"]
|
|
31
|
+
)
|
|
32
|
+
/ 1000
|
|
33
33
|
)
|
|
34
|
-
).one_or_none()
|
|
35
|
-
if daily_rs.finish_date is None and h_start >= to_utc(
|
|
36
|
-
to_ct(daily_rs.start_date) + relativedelta(months=3)
|
|
37
|
-
):
|
|
38
|
-
base_rate = data_source.non_core_rate(
|
|
39
|
-
"cfd_in_period_tracking", h_start
|
|
40
|
-
)["rate_gbp_per_kwh"]
|
|
41
34
|
else:
|
|
42
|
-
|
|
43
|
-
"cfd_reconciled_daily_levy_rates"
|
|
44
|
-
)
|
|
35
|
+
daily_contract = Contract.get_non_core_by_name(
|
|
36
|
+
data_source.sess, "cfd_reconciled_daily_levy_rates"
|
|
37
|
+
)
|
|
38
|
+
daily_rs = data_source.sess.scalars(
|
|
39
|
+
select(RateScript).where(
|
|
40
|
+
RateScript.contract == daily_contract,
|
|
41
|
+
RateScript.start_date <= h_start,
|
|
42
|
+
or_(
|
|
43
|
+
RateScript.finish_date == null(),
|
|
44
|
+
RateScript.finish_date >= h_start,
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
).one_or_none()
|
|
48
|
+
if daily_rs.finish_date is None and h_start >= to_utc(
|
|
49
|
+
to_ct(daily_rs.start_date) + relativedelta(months=3)
|
|
50
|
+
):
|
|
51
|
+
base_rate_dec = data_source.non_core_rate(
|
|
52
|
+
"cfd_in_period_tracking", h_start
|
|
53
|
+
)["rate_gbp_per_kwh"]
|
|
54
|
+
else:
|
|
55
|
+
base_rate_dec = data_source.non_core_rate(
|
|
56
|
+
"cfd_reconciled_daily_levy_rates", h_start
|
|
57
|
+
)["rate_gbp_per_kwh"]
|
|
58
|
+
base_rate = float(base_rate_dec)
|
|
45
59
|
|
|
46
60
|
effective_ocl_rate = data_source.non_core_rate(
|
|
47
61
|
"cfd_operational_costs_levy", h["start-date"]
|
|
48
62
|
)["record"]["Effective_OCL_Rate_GBP_Per_MWh"]
|
|
49
63
|
if effective_ocl_rate == "":
|
|
50
64
|
levy_rate_str = data_source.non_core_rate(
|
|
51
|
-
"cfd_operational_costs_levy",
|
|
65
|
+
"cfd_operational_costs_levy", h_start
|
|
52
66
|
)["record"]["OCL_Rate_GBP_Per_MWh"]
|
|
53
67
|
else:
|
|
54
68
|
levy_rate_str = effective_ocl_rate
|
|
55
69
|
levy_rate = float(levy_rate_str) / 1000
|
|
56
|
-
|
|
70
|
+
|
|
71
|
+
h["cfd-rate"] = cfd_cache[h_start] = base_rate + levy_rate
|
|
57
72
|
|
|
58
73
|
|
|
59
74
|
def lcc_import(sess, log, set_progress, s):
|
|
60
75
|
import_in_period_tracking(sess, log, set_progress, s)
|
|
61
76
|
import_operational_costs_levy(sess, log, set_progress, s)
|
|
62
77
|
import_reconciled_daily_levy_rates(sess, log, set_progress, s)
|
|
78
|
+
import_forecast_ilr_tra(sess, log, set_progress, s)
|
|
63
79
|
|
|
64
80
|
|
|
65
81
|
def _quarters(s):
|
|
@@ -93,6 +109,16 @@ def _parse_date(date_str):
|
|
|
93
109
|
return to_utc(to_ct(Datetime.strptime(date_str[:10], "%Y-%m-%d")))
|
|
94
110
|
|
|
95
111
|
|
|
112
|
+
def _parse_varying_date(date_str):
|
|
113
|
+
if "-" in date_str:
|
|
114
|
+
pattern = "%Y-%m-%d"
|
|
115
|
+
elif "/" in date_str:
|
|
116
|
+
pattern = "%d/%m/%Y"
|
|
117
|
+
else:
|
|
118
|
+
raise BadRequest(f"The date {date_str} is not recognized.")
|
|
119
|
+
return Datetime.strptime(date_str, pattern)
|
|
120
|
+
|
|
121
|
+
|
|
96
122
|
def import_in_period_tracking(sess, log, set_progress, s):
|
|
97
123
|
log("Starting to check for new LCC CfD In-Period Tracking")
|
|
98
124
|
|
|
@@ -303,3 +329,34 @@ def import_reconciled_daily_levy_rates(sess, log, set_progress, s):
|
|
|
303
329
|
|
|
304
330
|
log("Finished LCC CfD Reconciled Daily Levy Rates")
|
|
305
331
|
sess.commit()
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def import_forecast_ilr_tra(sess, log, set_progress, s):
|
|
335
|
+
log("Starting to check for new LCC CfD Forecast ILR TRA")
|
|
336
|
+
|
|
337
|
+
contract_name = "cfd_forecast_ilr_tra"
|
|
338
|
+
contract = Contract.find_non_core_by_name(sess, contract_name)
|
|
339
|
+
if contract is None:
|
|
340
|
+
contract = Contract.insert_non_core(
|
|
341
|
+
sess, contract_name, "", {}, to_utc(ct_datetime(1996, 4, 1)), None, {}
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
res_j = api_search(s, "fbece4ce-7cfc-42b7-8fb2-387cf59a3c32", sort="Period_Start")
|
|
345
|
+
for record in res_j["result"]["records"]:
|
|
346
|
+
period_start_str = record["Period_Start"]
|
|
347
|
+
period_start = to_utc(to_ct(_parse_varying_date(period_start_str)))
|
|
348
|
+
|
|
349
|
+
rs = sess.execute(
|
|
350
|
+
select(RateScript).where(
|
|
351
|
+
RateScript.contract == contract,
|
|
352
|
+
RateScript.start_date == period_start,
|
|
353
|
+
)
|
|
354
|
+
).scalar_one_or_none()
|
|
355
|
+
if rs is None:
|
|
356
|
+
rs = contract.insert_rate_script(sess, period_start, {})
|
|
357
|
+
|
|
358
|
+
rs_script = rs.make_script()
|
|
359
|
+
rs_script["record"] = record
|
|
360
|
+
rs.update(rs_script)
|
|
361
|
+
sess.commit()
|
|
362
|
+
log("Finished LCC CfD Forecast ILR TRA")
|
chellow/e/triad.py
CHANGED
|
@@ -8,6 +8,8 @@ from pypdf import PdfReader
|
|
|
8
8
|
|
|
9
9
|
from sqlalchemy import null, or_, select
|
|
10
10
|
|
|
11
|
+
from werkzeug.exceptions import BadRequest
|
|
12
|
+
|
|
11
13
|
import chellow.e.duos
|
|
12
14
|
from chellow.models import Contract, RateScript
|
|
13
15
|
from chellow.national_grid import api_get
|
|
@@ -276,6 +278,16 @@ GSP_LOOKUP = {
|
|
|
276
278
|
}
|
|
277
279
|
|
|
278
280
|
|
|
281
|
+
def _parse_varying_date(date_str):
|
|
282
|
+
if "-" in date_str:
|
|
283
|
+
pattern = "%Y-%m-%d"
|
|
284
|
+
elif "/" in date_str:
|
|
285
|
+
pattern = "%d/%m/%Y"
|
|
286
|
+
else:
|
|
287
|
+
raise BadRequest(f"The date {date_str} is not recognized.")
|
|
288
|
+
return Datetime.strptime(date_str, pattern)
|
|
289
|
+
|
|
290
|
+
|
|
279
291
|
def national_grid_import(sess, log, set_progress, s):
|
|
280
292
|
log("Starting to check for new TNUoS TRIAD Tariffs")
|
|
281
293
|
|
|
@@ -317,10 +329,13 @@ def national_grid_import(sess, log, set_progress, s):
|
|
|
317
329
|
rates = tr[polarity] = {}
|
|
318
330
|
|
|
319
331
|
record_key = GSP_LOOKUP[record["Zone_No"]]
|
|
320
|
-
record_published_date = record["Published_Date"]
|
|
332
|
+
record_published_date = _parse_varying_date(record["Published_Date"])
|
|
321
333
|
|
|
322
334
|
rate = rates.get(record_key)
|
|
323
|
-
if
|
|
335
|
+
if (
|
|
336
|
+
rate is None
|
|
337
|
+
or _parse_varying_date(rate["Published_Date"]) < record_published_date
|
|
338
|
+
):
|
|
324
339
|
rates[record_key] = record
|
|
325
340
|
rs.update(rs_script)
|
|
326
341
|
sess.commit()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: chellow
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1706020835.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)
|
|
@@ -18,7 +18,7 @@ chellow/e/bill_importer.py,sha256=y1bpn49xDwltj0PRFowWsjAVamcD8eyxUbCTdGxEZiE,73
|
|
|
18
18
|
chellow/e/bmarketidx.py,sha256=0JCBBnP3xfLq2eFjXO_u-gzHyTizab4Pp6PRK6OZLcw,7134
|
|
19
19
|
chellow/e/bsuos.py,sha256=YtEhce5589kJWNp0HlA7N9L1hHl2KjYkUm54cUCOB8w,15080
|
|
20
20
|
chellow/e/ccl.py,sha256=CYeFrg0TNF7Av49nqxa0guA8CMcJhdMpBRmOq8PH6G0,564
|
|
21
|
-
chellow/e/cfd.py,sha256=
|
|
21
|
+
chellow/e/cfd.py,sha256=eWN1U6_q4OqlLuXOo131jC5536Q3KU2S6Bl6uUv379E,12420
|
|
22
22
|
chellow/e/computer.py,sha256=J8VvYjcSeJNrG2Ak8Zi2t2bb_8tMrkHWny4JQlgIyy8,67032
|
|
23
23
|
chellow/e/dno_rate_parser.py,sha256=3IqGM2v6Str7S3Rc9FZ7lRWBKthfb3zSjpJLSETPcEE,20631
|
|
24
24
|
chellow/e/duos.py,sha256=ISTcNqe9KNjVNM2Qs8IBoQxnmSXOt5W_G7tZxp4T78M,28870
|
|
@@ -36,7 +36,7 @@ chellow/e/scenario.py,sha256=1tUxnvwTzr6cKqiw2wphdv5XDzV6JO6UVYkyQa67vHs,23263
|
|
|
36
36
|
chellow/e/system_price.py,sha256=F2GF_TNapfpbhoYjuGYAUCtD4JnccOUfd3w2ClG55qc,8032
|
|
37
37
|
chellow/e/tlms.py,sha256=m6bUY1LNRlPoZ8va7Y3TlXAIktlTz36UVygFoDqwXIc,9586
|
|
38
38
|
chellow/e/tnuos.py,sha256=qybrPCVukQ2l0RIdqn8XtHEbAU0izGoqUrFLoLVUoVI,4126
|
|
39
|
-
chellow/e/triad.py,sha256=
|
|
39
|
+
chellow/e/triad.py,sha256=S6LEMHvUKhAZe0-yfLIRciYDZ8IKMn1jh1TmmsbQD3s,13588
|
|
40
40
|
chellow/e/views.py,sha256=HIoyHeKR-j8wvxoyk3ZytTsCjU7g3ejFYVh56e6MxKE,212153
|
|
41
41
|
chellow/e/bill_parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
42
|
chellow/e/bill_parsers/activity_mop_stark_xlsx.py,sha256=UgWXDPzQkQghyj_lfgBqoSJpHB-t-qOdSaB8qY6GLog,4071
|
|
@@ -361,6 +361,6 @@ chellow/templates/g/supply_note_edit.html,sha256=6UQf_qbhFDys3cVsTp-c7ABWZpggW9R
|
|
|
361
361
|
chellow/templates/g/supply_notes.html,sha256=WR3YwGh_qqTklSJ7JqWX6BKBc9rk_jMff4RiWZiF2CM,936
|
|
362
362
|
chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
|
|
363
363
|
chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
|
|
364
|
-
chellow-
|
|
365
|
-
chellow-
|
|
366
|
-
chellow-
|
|
364
|
+
chellow-1706020835.0.0.dist-info/METADATA,sha256=ArRKTKkqPCuPDcnv7ta2OVMFShUtAaPkT1XJm_iwFm4,12160
|
|
365
|
+
chellow-1706020835.0.0.dist-info/WHEEL,sha256=mRYSEL3Ih6g5a_CVMIcwiF__0Ae4_gLYh01YFNwiq1k,87
|
|
366
|
+
chellow-1706020835.0.0.dist-info/RECORD,,
|
|
File without changes
|