chellow 1720006293.0.0__py3-none-any.whl → 1720600044.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/views.py CHANGED
@@ -79,7 +79,6 @@ from chellow.models import (
79
79
  )
80
80
  from chellow.utils import (
81
81
  HH,
82
- PropDict,
83
82
  c_months_u,
84
83
  csv_make_val,
85
84
  ct_datetime,
@@ -3732,24 +3731,15 @@ def pc_get(pc_id):
3732
3731
 
3733
3732
  @e.route("/supplier_bills/<int:bill_id>/add_read")
3734
3733
  def read_add_get(bill_id):
3735
- read_types = g.sess.query(ReadType).order_by(ReadType.code)
3736
- estimated_read_type_id = (
3737
- g.sess.query(ReadType.id).filter(ReadType.code == "E").scalar()
3738
- )
3739
- tprs = g.sess.query(Tpr).order_by(Tpr.code)
3734
+ read_types = g.sess.scalars(select(ReadType).order_by(ReadType.code))
3735
+ estimated_read_type = ReadType.get_by_code(g.sess, "E")
3736
+ tprs = g.sess.scalars(select(Tpr).order_by(Tpr.code))
3740
3737
  bill = Bill.get_by_id(g.sess, bill_id)
3741
3738
  coefficient = 1
3742
3739
  mpan_str = msn = previous_date = previous_value = previous_type_id = None
3743
3740
 
3744
3741
  era = bill.supply.find_era_at(g.sess, bill.start_date)
3745
3742
  if era is not None:
3746
- era_properties = PropDict(
3747
- f"{chellow.utils.url_root}eras/{era.id}", loads(era.properties)
3748
- )
3749
- try:
3750
- coefficient = float(era_properties["coefficient"])
3751
- except KeyError:
3752
- pass
3753
3743
  mpan_str = era.imp_mpan_core
3754
3744
  msn = era.msn
3755
3745
 
@@ -3778,7 +3768,7 @@ def read_add_get(bill_id):
3778
3768
  previous_date=previous_date,
3779
3769
  previous_value=previous_value,
3780
3770
  previous_type_id=previous_type_id,
3781
- estimated_read_type_id=estimated_read_type_id,
3771
+ estimated_read_type_id=estimated_read_type.id,
3782
3772
  )
3783
3773
 
3784
3774
 
chellow/models.py CHANGED
@@ -6687,28 +6687,7 @@ def insert_dtc_meter_types(sess):
6687
6687
  DtcMeterType.insert(sess, code, desc)
6688
6688
 
6689
6689
 
6690
- def db_init(sess, root_path):
6691
- db_name = config["PGDATABASE"]
6692
- log_message("Initializing database.")
6693
-
6694
- ct_now = ct_datetime_now()
6695
- last_month_start, _ = list(
6696
- c_months_u(finish_year=ct_now.year, finish_month=ct_now.month, months=2)
6697
- )[0]
6698
-
6699
- insert_voltage_levels(sess)
6700
- sess.commit()
6701
-
6702
- for code in ("editor", "viewer", "party-viewer"):
6703
- UserRole.insert(sess, code)
6704
- sess.commit()
6705
-
6706
- insert_sources(sess)
6707
- sess.commit()
6708
-
6709
- insert_generator_types(sess)
6710
- sess.commit()
6711
-
6690
+ def insert_read_types(sess):
6712
6691
  for code, desc in (
6713
6692
  ("A", "Actual Change of Supplier Read"),
6714
6693
  ("D", "Deemed (Settlement Registers) or Estimated (Non-Settlement Registers)"),
@@ -6731,6 +6710,31 @@ def db_init(sess, root_path):
6731
6710
  ("Z", "Actual Change of Tenancy Read"),
6732
6711
  ):
6733
6712
  sess.add(ReadType(code, desc))
6713
+
6714
+
6715
+ def db_init(sess, root_path):
6716
+ db_name = config["PGDATABASE"]
6717
+ log_message("Initializing database.")
6718
+
6719
+ ct_now = ct_datetime_now()
6720
+ last_month_start, _ = list(
6721
+ c_months_u(finish_year=ct_now.year, finish_month=ct_now.month, months=2)
6722
+ )[0]
6723
+
6724
+ insert_voltage_levels(sess)
6725
+ sess.commit()
6726
+
6727
+ for code in ("editor", "viewer", "party-viewer"):
6728
+ UserRole.insert(sess, code)
6729
+ sess.commit()
6730
+
6731
+ insert_sources(sess)
6732
+ sess.commit()
6733
+
6734
+ insert_generator_types(sess)
6735
+ sess.commit()
6736
+
6737
+ insert_read_types(sess)
6734
6738
  sess.commit()
6735
6739
 
6736
6740
  insert_cops(sess)
@@ -102,6 +102,7 @@ def content(g_batch_id, g_bill_id, g_contract_id, start_date, finish_date, user_
102
102
  _process_g_bill_ids(
103
103
  sess,
104
104
  report_context,
105
+ g_contract,
105
106
  g_bill_ids,
106
107
  forecast_date,
107
108
  bill_titles,
@@ -122,6 +123,7 @@ def content(g_batch_id, g_bill_id, g_contract_id, start_date, finish_date, user_
122
123
  def _process_g_bill_ids(
123
124
  sess,
124
125
  report_context,
126
+ g_contract,
125
127
  g_bill_ids,
126
128
  forecast_date,
127
129
  bill_titles,
@@ -132,15 +134,24 @@ def _process_g_bill_ids(
132
134
  g_bill_id = list(sorted(g_bill_ids))[0]
133
135
  g_bill_ids.remove(g_bill_id)
134
136
  g_bill = sess.query(GBill).filter(GBill.id == g_bill_id).one()
135
- problem = ""
136
137
  g_supply = g_bill.g_supply
138
+ vals = {
139
+ "covered_vat_gbp": Decimal("0.00"),
140
+ "covered_net_gbp": Decimal("0.00"),
141
+ "covered_gross_gbp": Decimal("0.00"),
142
+ "covered_kwh": Decimal(0),
143
+ "covered_start": g_bill.start_date,
144
+ "covered_finish": g_bill.finish_date,
145
+ "covered_bill_ids": [],
146
+ "virtual_problem": "",
147
+ }
137
148
  read_dict = defaultdict(set)
138
149
  for g_read in g_bill.g_reads:
139
150
  if not all(
140
151
  g_read.msn == era.msn
141
152
  for era in g_supply.find_g_eras(sess, g_read.prev_date, g_read.pres_date)
142
153
  ):
143
- problem += (
154
+ vals["virtual_problem"] += (
144
155
  f"The MSN {g_read.msn} of the register read {g_read.id} doesn't match "
145
156
  f"the MSN of all the relevant eras."
146
157
  )
@@ -152,17 +163,9 @@ def _process_g_bill_ids(
152
163
  typ_set = read_dict[str(dt) + "-" + g_read.msn]
153
164
  typ_set.add(typ)
154
165
  if len(typ_set) > 1:
155
- problem += f" Reads taken on {dt} have differing read types."
156
-
157
- vals = {
158
- "covered_vat_gbp": Decimal("0.00"),
159
- "covered_net_gbp": Decimal("0.00"),
160
- "covered_gross_gbp": Decimal("0.00"),
161
- "covered_kwh": Decimal(0),
162
- "covered_start": g_bill.start_date,
163
- "covered_finish": g_bill.finish_date,
164
- "covered_bill_ids": [],
165
- }
166
+ vals[
167
+ "virtual_problem"
168
+ ] += f" Reads taken on {dt} have differing read types."
166
169
 
167
170
  covered_primary_bill = None
168
171
  enlarged = True
@@ -270,12 +273,19 @@ def _process_g_bill_ids(
270
273
  or_(GEra.finish_date == null(), GEra.finish_date >= vals["covered_start"]),
271
274
  )
272
275
  ).scalars():
276
+ if g_era.g_contract != g_contract:
277
+ vals[
278
+ "virtual_problem"
279
+ ] += "The contract of the bill is different from the contract of the era."
280
+ continue
273
281
  site = (
274
282
  sess.query(Site)
275
283
  .join(SiteGEra)
276
284
  .filter(SiteGEra.is_physical == true(), SiteGEra.g_era == g_era)
277
285
  .one()
278
286
  )
287
+ vals["site_code"] = site.code
288
+ vals["site_name"] = site.name
279
289
 
280
290
  chunk_start = hh_max(vals["covered_start"], g_era.start_date)
281
291
  chunk_finish = hh_min(vals["covered_finish"], g_era.finish_date)
@@ -314,8 +324,6 @@ def _process_g_bill_ids(
314
324
  vals["bill_finish_date"] = g_bill.finish_date
315
325
  vals["mprn"] = g_supply.mprn
316
326
  vals["supply_name"] = g_supply.name
317
- vals["site_code"] = site.code
318
- vals["site_name"] = site.name
319
327
 
320
328
  for k, v in vals.items():
321
329
  if k == "covered_bill_ids":
@@ -332,9 +340,7 @@ def _process_g_bill_ids(
332
340
  except KeyError:
333
341
  vals[title] = None
334
342
 
335
- csv_writer.writerow(
336
- [(vals.get(k) if vals.get(k) is not None else "") for k in titles]
337
- )
343
+ csv_writer.writerow([csv_make_val(vals.get(k)) for k in titles])
338
344
 
339
345
 
340
346
  def do_get(sess):
@@ -445,6 +445,7 @@
445
445
  <td><em>update</em></td>
446
446
  <td><em>g_era</em></td>
447
447
  <td>MPRN</td>
448
+ <td>Date</td>
448
449
  <td>Start date</td>
449
450
  <td>Finish date</td>
450
451
  <td>Meter Serial Number</td>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1720006293.0.0
3
+ Version: 1720600044.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)
@@ -5,7 +5,7 @@ chellow/commands.py,sha256=ESBe9ZWj1c3vdZgqMZ9gFvYAB3hRag2R1PzOwuw9yFo,1302
5
5
  chellow/dloads.py,sha256=5SmP-0QPK6xCkd_wjIWh_8FAzN5OxNHCzyEQ1Xb-Y-M,5256
6
6
  chellow/edi_lib.py,sha256=alu20x9ZX06iPfnNI9dEJzuP6RIf4We3Y_M_bl7RrcY,51789
7
7
  chellow/general_import.py,sha256=l3EHq9zG9Vfl5Ee6XTVrC1nusXo4YGGB4VBmZ_JaJR8,65798
8
- chellow/models.py,sha256=SYLBU6olcoYlrqSGeF6YYDHP_1pf4xT_M1QpHDOYCIs,243088
8
+ chellow/models.py,sha256=7fCVyf9aCDb9natETLHzC2XIQkYxJhyLQhOQsTMWjFI,243147
9
9
  chellow/national_grid.py,sha256=uxcv0qisHPyzw9AVIYPzsRqwt2XPAcZL-SBR12qcrS0,4364
10
10
  chellow/proxy.py,sha256=cVXIktPlX3tQ1BYcwxq0nJXKE6r3DtFTtfFHPq55HaM,1351
11
11
  chellow/rate_server.py,sha256=fg-Pf_9Hk3bXmC9riPQNGQxBvLvBa_WtNYdwDCjnCSg,5678
@@ -38,7 +38,7 @@ chellow/e/system_price.py,sha256=6w5J7bzwFAZubE2zdOFRiS8IIrVP8hkoIOaG2yCt-Ic,623
38
38
  chellow/e/tlms.py,sha256=M33D6YpMixu2KkwSCzDRM3kThLgShg8exp63Obo75l8,8905
39
39
  chellow/e/tnuos.py,sha256=XseYztPUsQXNKuBmystO2kzzwAG9ehCZgpGBTdgSk-A,4313
40
40
  chellow/e/triad.py,sha256=lIQj7EdUrcFwEqleuHZXYU_bfzIwNOqUVVxB3NPQt4A,13710
41
- chellow/e/views.py,sha256=AiafJQsK5pY7_bTiPq3zfJT1wEmcx5hhqkhIdX7fl8U,215342
41
+ chellow/e/views.py,sha256=l2G7IZiCi3krcTokE18DAJGQvAXiZQHKwAdpdCiNxso,215060
42
42
  chellow/e/bill_parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  chellow/e/bill_parsers/activity_mop_stark_xlsx.py,sha256=UgWXDPzQkQghyj_lfgBqoSJpHB-t-qOdSaB8qY6GLog,4071
44
44
  chellow/e/bill_parsers/annual_mop_stark_xlsx.py,sha256=-HMoIfa_utXYKA44RuC0Xqv3vd2HLeQU_4P0iBUd3WA,4219
@@ -83,7 +83,7 @@ chellow/reports/report_291.py,sha256=rqBXy6s7hMeYWw-yNX6w_L5t2yz6rNEeos_4xO7wf90
83
83
  chellow/reports/report_33.py,sha256=laVz-itDbJTdvC6LxLEeuY0eKpYx43Un4adiExPTEEE,16730
84
84
  chellow/reports/report_387.py,sha256=kmBZopb0AOivcowO2nPjRj6LnV0_QjCDXLwqPL7IGVE,5672
85
85
  chellow/reports/report_41.py,sha256=QQeTshA1Og7N3wPaoZ8ynJzwsvZ1mgSFc7DDkVqIZoM,7447
86
- chellow/reports/report_429.py,sha256=0GCc0rQnOSG0fusw69yMMOCxnWApBd3P2sGWIg1py9M,12359
86
+ chellow/reports/report_429.py,sha256=8WlLqyfMyvIF5Kc6CE0MKwcT5xwmR_Ao99Ef72yAOVc,12668
87
87
  chellow/reports/report_59.py,sha256=CCFPUspUFgoMt6sMFsdtLYW-inA9rN6D-6Kted6vskA,45458
88
88
  chellow/reports/report_81.py,sha256=f7sKPZUbl2VDbDHIg7B5rMDxcx_xnV1Y6PbjJyiTPLA,5609
89
89
  chellow/reports/report_87.py,sha256=j2gdBOapaVY1ZnlNlw14RPx58_k8eUkc3oRSnKuCsNA,7057
@@ -115,7 +115,7 @@ chellow/templates/csv_sites_monthly_duration.html,sha256=59gErG6KwA57z-qh2EJsVGv
115
115
  chellow/templates/downloads.html,sha256=R9QPcFz-PLJOX7rDlmquIk-Hp9Iq-thzWCTfOexSpXg,937
116
116
  chellow/templates/edi_viewer.html,sha256=szUthgHOdph6Of-7f_1LeC_zYlNJaMeS5ctn6xTAeiM,1437
117
117
  chellow/templates/general_import.html,sha256=SMemHGu466Be3_cAWSS6Hn-Kv-1psbEMDD6NQG6bfbI,1013
118
- chellow/templates/general_imports.html,sha256=aPCS_oxOYOCU25koK9lgF3HSiT8GkLeLYpm6NBjT-mo,13051
118
+ chellow/templates/general_imports.html,sha256=VRmBqYsXsirm880WiFrJ3CknAXAoLR9Mnpz9cKjIeM8,13069
119
119
  chellow/templates/home.html,sha256=_ANKmcnlk_PDyZl6SCmejU8d90f3t8EH_rDDPDyYUwE,5657
120
120
  chellow/templates/input_date.html,sha256=rpgB5n0LfN8Y5djN_ZiuSxqdskxzCoKrEqI7hyJkVQo,1248
121
121
  chellow/templates/local_report.html,sha256=pV7_0QwyQ-D3OS9LXrly5pq3qprZnwTCoq6vCnMTkS4,1332
@@ -364,6 +364,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
364
364
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
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-1720006293.0.0.dist-info/METADATA,sha256=4Fg3yXTfYZ7JKwEwREZI72dTqsSTGAwudXblzYPbCUY,12205
368
- chellow-1720006293.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
369
- chellow-1720006293.0.0.dist-info/RECORD,,
367
+ chellow-1720600044.0.0.dist-info/METADATA,sha256=a62z_0cUvruY5SbuPBQeyCb1_GLDsaUZNCewzbwjAYo,12205
368
+ chellow-1720600044.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
369
+ chellow-1720600044.0.0.dist-info/RECORD,,