chellow 1717422005.0.0__py3-none-any.whl → 1717768383.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.

@@ -8,7 +8,7 @@ from openpyxl import load_workbook
8
8
  from werkzeug.exceptions import BadRequest
9
9
 
10
10
  from chellow.models import Session
11
- from chellow.utils import hh_format, parse_mpan_core, to_utc
11
+ from chellow.utils import parse_mpan_core, to_utc
12
12
 
13
13
 
14
14
  class Parser:
@@ -99,10 +99,18 @@ class Parser:
99
99
  ad_hoc_visits = self.get_dec("P", row)
100
100
  ad_hoc_rate = self.get_dec("Q", row)
101
101
  ad_hoc_gbp = self.get_dec("R", row)
102
+ activity_names = set()
103
+ activity_gbp = Decimal("0")
104
+ if ad_hoc_gbp != 0:
105
+ activity_names.add("ad_hoc_visit")
106
+ activity_gbp += ad_hoc_gbp
102
107
 
103
108
  annual_visits = self.get_int("S", row)
104
109
  annual_rate = self.get_dec("T", row)
105
110
  annual_gbp = self.get_dec("U", row)
111
+ if annual_gbp != 0:
112
+ activity_names.add("annual_visit")
113
+ activity_gbp += annual_gbp
106
114
 
107
115
  if cop_3_meters > 0:
108
116
  cop = "3"
@@ -121,19 +129,16 @@ class Parser:
121
129
  "mpan-gbp": mpan_gbp,
122
130
  "ad-hoc-visits": ad_hoc_visits,
123
131
  "ad-hoc-rate": [ad_hoc_rate],
124
- "ad-hoc-gbp": ad_hoc_gbp,
132
+ "ad-hoc-gbp-info": ad_hoc_gbp,
125
133
  "annual-visits-count": annual_visits,
126
134
  "annual-visits-rate": [annual_rate],
127
- "annual-visits-gbp": annual_gbp,
135
+ "annual-visits-gbp-info": annual_gbp,
128
136
  }
129
- annual_date_cell = self.get_cell("V", row)
130
- annual_date_value = annual_date_cell.value
131
- if annual_date_value is not None:
132
- if isinstance(annual_date_value, Datetime):
133
- annual_date = hh_format(annual_date_value)
134
- else:
135
- annual_date = annual_date_value
136
- breakdown["annual-visits-date"] = [annual_date]
137
+ if len(activity_names) > 0:
138
+ breakdown["activity-name"] = sorted(activity_names)
139
+
140
+ if activity_gbp != 0:
141
+ breakdown["activity-gbp"] = activity_gbp
137
142
 
138
143
  bills.append(
139
144
  {
chellow/e/bmarketidx.py CHANGED
@@ -1,9 +1,12 @@
1
1
  import atexit
2
- import collections
3
2
  import threading
4
3
  import traceback
4
+ from collections import deque
5
+ from datetime import datetime as Datetime
5
6
  from decimal import Decimal
6
7
 
8
+ from dateutil.relativedelta import relativedelta
9
+
7
10
  import requests
8
11
 
9
12
  from werkzeug.exceptions import BadRequest
@@ -73,7 +76,7 @@ class BmarketidxImporter(threading.Thread):
73
76
  def __init__(self):
74
77
  super().__init__(name="Bmarketidx Importer")
75
78
  self.lock = threading.RLock()
76
- self.messages = collections.deque(maxlen=100)
79
+ self.messages = deque(maxlen=1000)
77
80
  self.stopped = threading.Event()
78
81
  self.going = threading.Event()
79
82
 
@@ -145,7 +148,7 @@ class BmarketidxImporter(threading.Thread):
145
148
  self.global_alert = (
146
149
  f"There's a problem with the <a "
147
150
  f"href='/non_core_contracts/{contract.id}/"
148
- f"automatic_importer'>bmarketidx automatic "
151
+ f"auto_importer'>bmarketidx automatic "
149
152
  f"importer</a>."
150
153
  )
151
154
  finally:
@@ -164,24 +167,38 @@ def _process_month(log_f, sess, contract, latest_rs, month_start, month_finish):
164
167
  )
165
168
  rates = {}
166
169
  month_finish_ct = to_ct(month_finish)
170
+ base_url = "https://data.elexon.co.uk/bmrs/api/v1/balancing/pricing/market-index"
167
171
  for d in range(month_finish_ct.day):
168
- day_ct = ct_datetime(month_finish_ct.year, month_finish_ct.month, d + 1)
172
+ day_from_ct = ct_datetime(month_finish_ct.year, month_finish_ct.month, d + 1)
173
+ day_to_ct = day_from_ct + relativedelta(days=1)
169
174
  params = {
170
- "q": f"ajax/alldata/MID/Date,SP,Provider,Price,Volume/NULL/"
171
- f'{day_ct.strftime("%Y-%m-%d")}/ALL'
175
+ "from": f'{day_from_ct.strftime("%Y-%m-%d")}T00:00Z',
176
+ "to": f'{day_to_ct.strftime("%Y-%m-%d")}T00:00Z',
177
+ "settlementPeriodFrom": "1",
178
+ "settlementPeriodTo": "1",
172
179
  }
173
180
  sess.rollback()
174
- r = requests.get(
175
- "https://www.bmreports.com/bmrs/", params=params, timeout=60, verify=False
176
- )
181
+ q_str = "&".join(f"{k}={v}" for k, v in params.items())
182
+ log_f(f"Attempting to download {base_url}?{q_str}")
183
+ r = requests.get(base_url, params=params, timeout=60, verify=False)
177
184
  res = r.json()
178
- for h in res["arr"]:
179
- dt = to_utc(day_ct + (int(h["settlementPeriod"]) - 1) * HH)
180
- try:
181
- rate = rates[dt]
182
- except KeyError:
183
- rate = rates[dt] = {}
184
- rate[h["DataProviderId"]] = Decimal(h["MarketIndexPrice"]) / Decimal(1000)
185
+ for h in res["data"]:
186
+ # {
187
+ # "startTime":"2022-06-01T23:00:00Z",
188
+ # "dataProvider":"N2EXMIDP",
189
+ # "settlementDate":"2022-06-02",
190
+ # "settlementPeriod":1,
191
+ # "price":0.00,
192
+ # "volume":0.000
193
+ # },
194
+ settlement_date = Datetime.strptime(h["settlementDate"], "%Y-%m-%d")
195
+ if settlement_date.month == month_finish_ct.month:
196
+ dt = to_utc(settlement_date + (int(h["settlementPeriod"]) - 1) * HH)
197
+ try:
198
+ rate = rates[dt]
199
+ except KeyError:
200
+ rate = rates[dt] = {}
201
+ rate[h["dataProvider"]] = Decimal(h["price"]) / Decimal(1000)
185
202
 
186
203
  if month_finish in rates:
187
204
  log_f("The whole month's data is there.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1717422005.0.0
3
+ Version: 1717768383.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)
@@ -15,7 +15,7 @@ chellow/views.py,sha256=eDvTQM_PUqRvrCQvBdlF5q7MEs7w2yJmRjcC8WDbHtE,79584
15
15
  chellow/e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  chellow/e/aahedc.py,sha256=d2usudp7KYWpU6Pk3fal5EQ47EbvkvKeaFGylnb3NWw,606
17
17
  chellow/e/bill_importer.py,sha256=7UcnqNlKbJc2GhW9gy8sDp9GuqambJVpZLvbafOZztA,7411
18
- chellow/e/bmarketidx.py,sha256=lao_Azld-aaimEQLsTCpGTaZKI8iFpg2K6CDFOG0seM,7132
18
+ chellow/e/bmarketidx.py,sha256=C0BaHn2RxIuWH2QzA-OmSP0fbUGvW9tqEUhLnzOEdmA,7968
19
19
  chellow/e/bsuos.py,sha256=hdP9vnOJSuZl46OAkJeUg1XJYvYIBj4J6Sqce1Hy9Vs,15542
20
20
  chellow/e/ccl.py,sha256=30dh_SvlgzsTQPPAJNZWILaMvbeDsv9-P-S1JxS5_SQ,3184
21
21
  chellow/e/cfd.py,sha256=V1DTT5XBQbt8hO1gae1u3315fZ4iuYk3XC7J2sUbhKQ,14352
@@ -53,7 +53,7 @@ chellow/e/bill_parsers/haven_edi.py,sha256=YGPHRxPOhje9s32jqPHHELni2tooOYj3cMC_q
53
53
  chellow/e/bill_parsers/haven_edi_tprs.py,sha256=ZVX9CCqUybsot_Z0BEOJPvl9x5kSr7fEWyuJXvZDcz4,11841
54
54
  chellow/e/bill_parsers/mm.py,sha256=ShhaVc0IpShpy4Q2pfj3EfjhpjbffQutKsAq6ivNiys,8522
55
55
  chellow/e/bill_parsers/nonsettlement_dc_stark_xlsx.py,sha256=yogXTuQHGRL7IiqvRWr2C9V24ez1j9Yx0128UygPE_k,4723
56
- chellow/e/bill_parsers/settlement_dc_stark_xlsx.py,sha256=gKeYMdUO4bVycV8n1lWs5AIfF3bHZLkM6tkasD4rhHs,6239
56
+ chellow/e/bill_parsers/settlement_dc_stark_xlsx.py,sha256=PlEqCZuJ9DfQXeeYQ64jtf3ML7sUt_tt61QOOTnkE5c,6380
57
57
  chellow/e/bill_parsers/sse_edi.py,sha256=L85DOfNkqexeEIEr8pCBn_2sHJI-zEaw6cogpE3YyYM,15204
58
58
  chellow/e/bill_parsers/sww_xls.py,sha256=QEjiuvwvr5FuWCfqqVw8LaA_vZyAKsvRAS5fw3xtFhM,7533
59
59
  chellow/gas/bill_import.py,sha256=w0lPgK_Drzh8rtnEBQe3qFuxrgzZ6qQSgpaGrrGznMU,6549
@@ -364,6 +364,6 @@ chellow/templates/g/supply_note_edit.html,sha256=6UQf_qbhFDys3cVsTp-c7ABWZpggW9R
364
364
  chellow/templates/g/supply_notes.html,sha256=WR3YwGh_qqTklSJ7JqWX6BKBc9rk_jMff4RiWZiF2CM,936
365
365
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
366
366
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
367
- chellow-1717422005.0.0.dist-info/METADATA,sha256=Htpjp-p18RGbhe8l7jpmEErcTO1aCFxezxhbSBeCG1c,12205
368
- chellow-1717422005.0.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
369
- chellow-1717422005.0.0.dist-info/RECORD,,
367
+ chellow-1717768383.0.0.dist-info/METADATA,sha256=FSbmmHYytVZN9CdVIekLk3eUbkbT4a-3mLVR3ow7PFM,12205
368
+ chellow-1717768383.0.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
369
+ chellow-1717768383.0.0.dist-info/RECORD,,