chellow 1759411815.0.0__py3-none-any.whl → 1760028799.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/lcc.py CHANGED
@@ -46,7 +46,7 @@ def run_import(sess, log, set_progress):
46
46
  s = requests.Session()
47
47
  s.verify = False
48
48
 
49
- for mod_name in ("chellow.e.cfd",):
49
+ for mod_name in ("chellow.e.cfd", "chellow.e.rab"):
50
50
  mod = import_module(mod_name)
51
51
  mod.lcc_import(sess, log, set_progress, s)
52
52
 
chellow/e/rab.py ADDED
@@ -0,0 +1,75 @@
1
+ from datetime import datetime as Datetime
2
+ from decimal import Decimal
3
+
4
+
5
+ from sqlalchemy import select
6
+
7
+ from chellow.e.lcc import api_records
8
+ from chellow.models import Contract, RateScript
9
+ from chellow.utils import ct_datetime, to_ct, to_utc
10
+
11
+
12
+ def hh(data_source):
13
+ try:
14
+ rab_cache = data_source.caches["rab"]
15
+ except KeyError:
16
+ rab_cache = data_source.caches["rab"] = {}
17
+
18
+ for h in data_source.hh_data:
19
+ try:
20
+ h["rab"] = rab_cache[h["start-date"]]
21
+ except KeyError:
22
+ h_start = h["start-date"]
23
+ rate_str = data_source.non_core_rate("rab_forecast_ilr_tra", h_start)[
24
+ "record"
25
+ ]["Interim_Levy_Rate_GBP_MWh"]
26
+ if rate_str == "":
27
+ base_rate_dec = Decimal("0")
28
+ else:
29
+ base_rate_dec = Decimal(rate_str) / Decimal(1000)
30
+
31
+ base_rate = float(base_rate_dec)
32
+
33
+ h["rab"] = rab_cache[h_start] = {
34
+ "interim": base_rate,
35
+ }
36
+
37
+
38
+ def lcc_import(sess, log, set_progress, s):
39
+ import_forecast_ilr_tra(sess, log, set_progress, s)
40
+
41
+
42
+ def _parse_date(date_str):
43
+ return to_utc(to_ct(Datetime.strptime(date_str[:10], "%Y-%m-%d")))
44
+
45
+
46
+ def import_forecast_ilr_tra(sess, log, set_progress, s):
47
+ log("Starting to check for new LCC RAB Forecast ILR TRA")
48
+
49
+ contract_name = "rab_forecast_ilr_tra"
50
+ contract = Contract.find_non_core_by_name(sess, contract_name)
51
+ if contract is None:
52
+ contract = Contract.insert_non_core(
53
+ sess, contract_name, "", {}, to_utc(ct_datetime(1996, 4, 1)), None, {}
54
+ )
55
+
56
+ for record in api_records(log, s, "1231fbb3-93ee-4a33-87a9-f15bb377346d"):
57
+ period_start_str = record["Month"]
58
+ if len(period_start_str) == 0:
59
+ continue
60
+ period_start = _parse_date(period_start_str)
61
+
62
+ rs = sess.execute(
63
+ select(RateScript).where(
64
+ RateScript.contract == contract,
65
+ RateScript.start_date == period_start,
66
+ )
67
+ ).scalar_one_or_none()
68
+ if rs is None:
69
+ rs = contract.insert_rate_script(sess, period_start, {})
70
+
71
+ rs_script = rs.make_script()
72
+ rs_script["record"] = record
73
+ rs.update(rs_script)
74
+ sess.commit()
75
+ log("Finished LCC RAB Forecast ILR TRA")
chellow/general_import.py CHANGED
@@ -942,47 +942,70 @@ def general_import_bill(sess, action, vals, args):
942
942
  supply,
943
943
  )
944
944
 
945
- for i in range(15, len(vals), 11):
946
- msn = add_arg(args, "Meter Serial Number", vals, i)
947
- mpan_str = add_arg(args, "MPAN", vals, i + 1)
948
- coefficient_str = add_arg(args, "Coefficient", vals, i + 2)
949
- coefficient = Decimal(coefficient_str)
950
- units = add_arg(args, "Units", vals, i + 3)
951
- tpr_code = add_arg(args, "TPR", vals, i + 4)
952
- if len(tpr_code) > 0:
953
- tpr = Tpr.get_by_code(sess, tpr_code)
954
- else:
955
- tpr = None
956
-
957
- prev_date_str = add_arg(args, "Previous Date", vals, i + 5)
958
- prev_date = parse_hh_start(prev_date_str)
959
- prev_value_str = add_arg(args, "Previous Value", vals, i + 6)
960
- prev_value = Decimal(prev_value_str)
961
-
962
- prev_type_str = add_arg(args, "Previous Type", vals, i + 7)
963
- prev_type = ReadType.get_by_code(sess, prev_type_str)
964
-
965
- pres_date_str = add_arg(args, "Present Date", vals, i + 8)
966
- pres_date = parse_hh_start(pres_date_str)
967
- pres_value_str = add_arg(args, "Present Value", vals, i + 9)
968
- pres_value = Decimal(pres_value_str)
969
-
970
- pres_type_str = add_arg(args, "Present Type", vals, i + 10)
971
- pres_type = ReadType.get_by_code(sess, pres_type_str)
972
- bill.insert_read(
973
- sess,
974
- tpr,
975
- coefficient,
976
- units,
977
- msn,
978
- mpan_str,
979
- prev_date,
980
- prev_value,
981
- prev_type,
982
- pres_date,
983
- pres_value,
984
- pres_type,
985
- )
945
+ i = 15
946
+ while i < len(vals):
947
+ typ = add_arg(args, "read or element", vals, i)
948
+ if typ == "read":
949
+ msn = add_arg(args, "Meter Serial Number", vals, i + 1)
950
+ mpan_str = add_arg(args, "MPAN", vals, i + 2)
951
+ coefficient_str = add_arg(args, "Coefficient", vals, i + 3)
952
+ coefficient = Decimal(coefficient_str)
953
+ units = add_arg(args, "Units", vals, i + 4)
954
+ tpr_code = add_arg(args, "TPR", vals, i + 5)
955
+ if len(tpr_code) > 0:
956
+ tpr = Tpr.get_by_code(sess, tpr_code)
957
+ else:
958
+ tpr = None
959
+
960
+ prev_date_str = add_arg(args, "Previous Date", vals, i + 6)
961
+ prev_date = parse_hh_start(prev_date_str)
962
+ prev_value_str = add_arg(args, "Previous Value", vals, i + 7)
963
+ prev_value = Decimal(prev_value_str)
964
+
965
+ prev_type_str = add_arg(args, "Previous Type", vals, i + 8)
966
+ prev_type = ReadType.get_by_code(sess, prev_type_str)
967
+
968
+ pres_date_str = add_arg(args, "Present Date", vals, i + 9)
969
+ pres_date = parse_hh_start(pres_date_str)
970
+ pres_value_str = add_arg(args, "Present Value", vals, i + 10)
971
+ pres_value = Decimal(pres_value_str)
972
+
973
+ pres_type_str = add_arg(args, "Present Type", vals, i + 11)
974
+ pres_type = ReadType.get_by_code(sess, pres_type_str)
975
+ bill.insert_read(
976
+ sess,
977
+ tpr,
978
+ coefficient,
979
+ units,
980
+ msn,
981
+ mpan_str,
982
+ prev_date,
983
+ prev_value,
984
+ prev_type,
985
+ pres_date,
986
+ pres_value,
987
+ pres_type,
988
+ )
989
+ i += 12
990
+ elif typ == "element":
991
+ name = add_arg(args, "Name", vals, i + 1)
992
+ start_date_str = add_arg(args, "Start Date", vals, i + 2)
993
+ start_date = parse_hh_start(start_date_str)
994
+ finish_date_str = add_arg(args, "Finish Date", vals, i + 3)
995
+ finish_date = parse_hh_start(finish_date_str)
996
+ net_str = add_arg(args, "Net", vals, i + 4)
997
+ net = Decimal(net_str)
998
+ breakdown_str = add_arg(args, "Breakdown", vals, i + 5)
999
+ breakdown = _parse_breakdown(breakdown_str)
1000
+ bill.insert_element(
1001
+ sess,
1002
+ name,
1003
+ start_date,
1004
+ finish_date,
1005
+ net,
1006
+ breakdown,
1007
+ )
1008
+ i += 6
986
1009
 
987
1010
  elif action == "update":
988
1011
  bill_id_str = add_arg(args, "Bill Id", vals, 0)
@@ -306,6 +306,7 @@
306
306
  <td>Type</td>
307
307
  <td>Breakdown</td>
308
308
  <td>Kwh</td>
309
+ <td>'read' or 'element'</td>
309
310
  <td>(Meter Serial Number</td>
310
311
  <td>Mpan</td>
311
312
  <td>Coefficient</td>
@@ -317,6 +318,12 @@
317
318
  <td>Present Date</td>
318
319
  <td>Present Value</td>
319
320
  <td>Present Type)*</td>
321
+ <td>'read' or 'element'</td>
322
+ <td>(Name</td>
323
+ <td>Start Date</td>
324
+ <td>Finish Date</td>
325
+ <td>Net</td>
326
+ <td>Breakdown)*</td>
320
327
  </tr>
321
328
  <tr>
322
329
  <td><em>update</em></td>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chellow
3
- Version: 1759411815.0.0
3
+ Version: 1760028799.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)
@@ -14,7 +14,7 @@ Requires-Dist: odio==0.0.23
14
14
  Requires-Dist: openpyxl==3.1.5
15
15
  Requires-Dist: paramiko==3.4.1
16
16
  Requires-Dist: pep3143daemon==0.1.0
17
- Requires-Dist: pg8000==1.31.1
17
+ Requires-Dist: pg8000==1.31.5
18
18
  Requires-Dist: pip>=9.0.1
19
19
  Requires-Dist: psutil==5.9.5
20
20
  Requires-Dist: pympler==1.0.1
@@ -47,7 +47,7 @@ Chellow is a web application for checking UK electricity and gas bills. It's des
47
47
  for organizations with high electricity consumption. The software is hosted at
48
48
  https://github.com/WessexWater/chellow.
49
49
 
50
- [![Build Status](https://github.com/WessexWater/chellow/workflows/chellow/badge.svg)](https://github.com/WessexWater/chellow/workflows/chellow)
50
+ [![Build Status](https://github.com/WessexWater/chellow/actions/workflows/chellow.yml/badge.svg)](https://github.com/WessexWater/chellow/actions/workflows/chellow.yml)
51
51
 
52
52
 
53
53
  ## Installation
@@ -55,8 +55,7 @@ https://github.com/WessexWater/chellow.
55
55
  Chellow is a Python web application that uses the PostgreSQL database. To install
56
56
  Chellow, follow these steps:
57
57
 
58
- * Install [PostgreSQL](http://www.postgresql.org/) 12
59
- * Set the PostgreSQL time zone to 'UTC'.
58
+ * Install [PostgreSQL](http://www.postgresql.org/) 15
60
59
  * Create a PostgreSQL database: `createdb --encoding=UTF8 chellow`
61
60
  * Set up the following environment variables to configure Chellow:
62
61
 
@@ -5,7 +5,7 @@ chellow/commands.py,sha256=ESBe9ZWj1c3vdZgqMZ9gFvYAB3hRag2R1PzOwuw9yFo,1302
5
5
  chellow/dloads.py,sha256=dixp-O0MF2_mlwrnKx3D9DH09Qu05BjTo0rZfigTjR4,5534
6
6
  chellow/edi_lib.py,sha256=Lq70TUJuogoP5KGrphzUEUfyfgftEclg_iA3mpNAaDI,51324
7
7
  chellow/fake_batch_updater.py,sha256=khAmvSUn9qN04w8C92kRg1UeyQvfLztE7QXv9tUz6nE,11611
8
- chellow/general_import.py,sha256=bm8FoaC9xUajGvJYShuS5GEwPwcL5eCF9D9g6o_AkB0,68089
8
+ chellow/general_import.py,sha256=ghybbden66VT4q5J0vYwiNg-6G2vg71EgCN_x3fvhW0,69200
9
9
  chellow/models.py,sha256=Ws3-jP6x3bSrCmv1umbviaQ3SijpP4R_a6i2Go26gRM,247072
10
10
  chellow/national_grid.py,sha256=-c_vqNRtpNIQOcm0F1NDhS3_QUiOaLgEJYWzysSNc5Y,4369
11
11
  chellow/proxy.py,sha256=cVXIktPlX3tQ1BYcwxq0nJXKE6r3DtFTtfFHPq55HaM,1351
@@ -35,8 +35,9 @@ chellow/e/hh_parser_schneider_xlsx.py,sha256=Vtq0TNz-oojoKJm4PeH4ZwBp2I-mjArB9-F
35
35
  chellow/e/hh_parser_simple_csv.py,sha256=lJx9tw9BWFSoBmns1Cws_vY-OIn90LPt2yvIN_CFcTE,2177
36
36
  chellow/e/hh_parser_vital_xlsx.py,sha256=g9-CElfH1PPfwpuUcVvD6WQpBlNxCo8j9pq_0Yza0ZM,4125
37
37
  chellow/e/lafs.py,sha256=SUUFtvn_IQQTrZue1zefCYgzuscA0FVX2ySZ9u8BDPw,7776
38
- chellow/e/lcc.py,sha256=OkpynN8_iAdHRlu-yyU6BhRUqYYOZsUnl0HbHULYo_4,4670
38
+ chellow/e/lcc.py,sha256=VqwKBE6N6wXv_xu0o-1CRtJripoFGCZ8Q8e1hvce_34,4686
39
39
  chellow/e/mdd_importer.py,sha256=NugJr2JhuzkPTsEMl_5UdQuw5K2p8lVJ-hyz4MK6Hfg,35762
40
+ chellow/e/rab.py,sha256=8buWWqo7CPzAqenI8zEnKDMVxzXZzQZUFAWY9sdGH3s,2320
40
41
  chellow/e/rcrc.py,sha256=92CA1uIotIHd1epQ_jEPdJKzXqDFV-AoJOJeRO6MEyA,4274
41
42
  chellow/e/ro.py,sha256=cpeJQMY_6SpVxL1nySSj9we58A6E2KwJEAb6fK7cZKY,626
42
43
  chellow/e/scenario.py,sha256=FLgh03r_SgXx0hMWFbAvwsz2ScDL8LUwYWSWVv2rQlg,24973
@@ -128,7 +129,7 @@ chellow/templates/downloads.html,sha256=R9QPcFz-PLJOX7rDlmquIk-Hp9Iq-thzWCTfOexS
128
129
  chellow/templates/edi_viewer.html,sha256=szUthgHOdph6Of-7f_1LeC_zYlNJaMeS5ctn6xTAeiM,1437
129
130
  chellow/templates/fake_batch_updater.html,sha256=aRQbxtNUlIzxwgSUy2pr-Km5NbhZkse4WSBtlqFIJMg,1885
130
131
  chellow/templates/general_import.html,sha256=9ezzieDjaPBZ0nUJkMkzoDxWVzYtr4D-Dr2UCA5xV8U,1370
131
- chellow/templates/general_imports.html,sha256=-uQRJBtpwZHODcWM1JuECJ_H_AHsu8frtwEFQ6s_7Sk,13690
132
+ chellow/templates/general_imports.html,sha256=h7UC7AWJ3Qw9PH8UPq24PqZ5xQF5b3Ct7LfC_PK78BE,13866
132
133
  chellow/templates/home.html,sha256=7xiD6QLju3ugALzMlzTJosRyMUmQGWPK6jDF7oZbnAQ,5781
133
134
  chellow/templates/input_date.html,sha256=rpgB5n0LfN8Y5djN_ZiuSxqdskxzCoKrEqI7hyJkVQo,1248
134
135
  chellow/templates/local_report.html,sha256=pV7_0QwyQ-D3OS9LXrly5pq3qprZnwTCoq6vCnMTkS4,1332
@@ -399,6 +400,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
399
400
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
400
401
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
401
402
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
402
- chellow-1759411815.0.0.dist-info/METADATA,sha256=BDsyDyi0K8znwxoja9PvDrJJCVAIOiddSch-eAR_AU4,12519
403
- chellow-1759411815.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
404
- chellow-1759411815.0.0.dist-info/RECORD,,
403
+ chellow-1760028799.0.0.dist-info/METADATA,sha256=zm1x1B_QH5ZI_HiJ4vFBX0RbyndLd_v2iw77jNS4QqU,12500
404
+ chellow-1760028799.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
405
+ chellow-1760028799.0.0.dist-info/RECORD,,