chellow 1719570651.0.0__py3-none-any.whl → 1720526317.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.

@@ -36,6 +36,9 @@ def content(user_id, start_date, finish_date, contract_id):
36
36
  "energisation_status",
37
37
  "gsp_group",
38
38
  "dno",
39
+ "era_start",
40
+ "pc",
41
+ "meter_type",
39
42
  "site_code",
40
43
  "imp_is_substation",
41
44
  "imp_llfc_code",
@@ -46,7 +49,8 @@ def content(user_id, start_date, finish_date, contract_id):
46
49
  ]
47
50
 
48
51
  bill_titles = contract_func(caches, contract, "virtual_bill_titles")()
49
- writer.writerow(header_titles + bill_titles)
52
+ titles = header_titles + bill_titles
53
+ writer.writerow(titles)
50
54
  vb_func = contract_func(caches, contract, "virtual_bill")
51
55
 
52
56
  for era in (
@@ -77,34 +81,31 @@ def content(user_id, start_date, finish_date, contract_id):
77
81
  exp_llfc_description = supply_source.llfc.description
78
82
  imp_is_substation = imp_llfc_code = imp_llfc_description = None
79
83
 
80
- out = [
81
- era.imp_mpan_core,
82
- era.exp_mpan_core,
83
- chunk_start,
84
- chunk_finish,
85
- supply_source.energisation_status_code,
86
- supply_source.gsp_group_code,
87
- supply_source.dno_code,
88
- era.get_physical_site(sess).code,
89
- imp_is_substation,
90
- imp_llfc_code,
91
- imp_llfc_description,
92
- exp_is_substation,
93
- exp_llfc_code,
94
- exp_llfc_description,
95
- ]
84
+ out = {
85
+ "imp_mpan_core": era.imp_mpan_core,
86
+ "exp_mpan_core": era.exp_mpan_core,
87
+ "start_date": chunk_start,
88
+ "finish_date": chunk_finish,
89
+ "energisation_status": supply_source.energisation_status_code,
90
+ "gsp_group": supply_source.gsp_group_code,
91
+ "dno": supply_source.dno_code,
92
+ "era_start": era.start_date,
93
+ "pc": supply_source.pc_code,
94
+ "meter_type": supply_source.meter_type_code,
95
+ "site_code": era.get_physical_site(sess).code,
96
+ "imp_is_substation": imp_is_substation,
97
+ "imp_llfc_code": imp_llfc_code,
98
+ "imp_llfc_description": imp_llfc_description,
99
+ "exp_is_substation": exp_is_substation,
100
+ "exp_llfc_code": exp_llfc_code,
101
+ "exp_llfc_description": exp_llfc_description,
102
+ }
96
103
  vb_func(supply_source)
97
104
  bill = supply_source.mop_bill
98
105
  for title in bill_titles:
99
106
  if title in bill:
100
- out.append(bill[title])
101
- del bill[title]
102
- else:
103
- out.append("")
104
- for k in sorted(bill.keys()):
105
- out.append(k)
106
- out.append(bill[k])
107
- writer.writerow(csv_make_val(v) for v in out)
107
+ out[title] = bill[title]
108
+ writer.writerow(csv_make_val(out.get(t)) for t in titles)
108
109
 
109
110
  sess.rollback() # Avoid long-running transactions
110
111
  except BadRequest as e:
@@ -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):
@@ -37,13 +37,16 @@ def content(user_id, contract_id, end_year, end_month, months):
37
37
 
38
38
  bill_titles = contract_func(caches, contract, "virtual_bill_titles")()
39
39
  header_titles = [
40
- "Import MPAN Core",
41
- "Export MPAN Core",
42
- "Start Date",
43
- "Finish Date",
40
+ "imp_mpan_core",
41
+ "exp_mpan_core",
42
+ "start_date",
43
+ "finish_date",
44
44
  "energisation_status",
45
45
  "gsp_group",
46
46
  "dno",
47
+ "era_start",
48
+ "pc",
49
+ "meter_type",
47
50
  "site_code",
48
51
  "imp_is_substation",
49
52
  "imp_llfc_code",
@@ -55,7 +58,8 @@ def content(user_id, contract_id, end_year, end_month, months):
55
58
 
56
59
  vb_func = contract_func(caches, contract, "virtual_bill")
57
60
 
58
- writer.writerow(header_titles + bill_titles)
61
+ titles = header_titles + bill_titles
62
+ writer.writerow(titles)
59
63
 
60
64
  for era in (
61
65
  sess.query(Era)
@@ -86,36 +90,33 @@ def content(user_id, contract_id, end_year, end_month, months):
86
90
  exp_llfc_description = supply_source.llfc.description
87
91
  imp_is_substation = imp_llfc_code = imp_llfc_description = None
88
92
 
89
- vals = [
90
- era.imp_mpan_core,
91
- era.exp_mpan_core,
92
- chunk_start,
93
- chunk_finish,
94
- supply_source.energisation_status_code,
95
- supply_source.gsp_group_code,
96
- supply_source.dno_code,
97
- era.get_physical_site(sess).code,
98
- imp_is_substation,
99
- imp_llfc_code,
100
- imp_llfc_description,
101
- exp_is_substation,
102
- exp_llfc_code,
103
- exp_llfc_description,
104
- ]
93
+ vals = {
94
+ "imp_mpan_core": era.imp_mpan_core,
95
+ "exp_mpan_core": era.exp_mpan_core,
96
+ "start_date": chunk_start,
97
+ "finish_date": chunk_finish,
98
+ "energisation_status": supply_source.energisation_status_code,
99
+ "gsp_group": supply_source.gsp_group_code,
100
+ "dno": supply_source.dno_code,
101
+ "era_start": era.start_date,
102
+ "pc": supply_source.pc_code,
103
+ "meter_type": supply_source.meter_type_code,
104
+ "site_code": era.get_physical_site(sess).code,
105
+ "imp_is_substation": imp_is_substation,
106
+ "imp_llfc_code": imp_llfc_code,
107
+ "imp_llfc_description": imp_llfc_description,
108
+ "exp_is_substation": exp_is_substation,
109
+ "exp_llfc_code": exp_llfc_code,
110
+ "exp_llfc_description": exp_llfc_description,
111
+ }
105
112
 
106
113
  vb_func(supply_source)
107
114
  bill = supply_source.dc_bill
108
115
 
109
116
  for title in bill_titles:
110
- vals.append(bill.get(title))
111
- if title in bill:
112
- del bill[title]
117
+ vals[title] = bill.get(title)
113
118
 
114
- for k in sorted(bill.keys()):
115
- vals.append(k)
116
- vals.append(bill[k])
117
-
118
- writer.writerow(csv_make_val(v) for v in vals)
119
+ writer.writerow(csv_make_val(vals.get(t)) for t in titles)
119
120
 
120
121
  # Avoid long-running transactions
121
122
  sess.rollback()
@@ -83,37 +83,32 @@ def _process_era(
83
83
  exp_llfc_description = data_source.llfc.description
84
84
  imp_is_substation = imp_llfc_code = imp_llfc_description = None
85
85
 
86
- vals = [
87
- data_source.mpan_core,
88
- site.code,
89
- site.name,
90
- data_source.supplier_account,
91
- data_source.start_date,
92
- data_source.finish_date,
93
- data_source.energisation_status_code,
94
- data_source.gsp_group_code,
95
- data_source.dno_code,
96
- imp_is_substation,
97
- imp_llfc_code,
98
- imp_llfc_description,
99
- exp_is_substation,
100
- exp_llfc_code,
101
- exp_llfc_description,
102
- ]
86
+ vals = {
87
+ "mpan_core": data_source.mpan_core,
88
+ "site_code": site.code,
89
+ "site_name": site.name,
90
+ "account": data_source.supplier_account,
91
+ "from": data_source.start_date,
92
+ "to": data_source.finish_date,
93
+ "energisation_status": data_source.energisation_status_code,
94
+ "gsp_group": data_source.gsp_group_code,
95
+ "dno": data_source.dno_code,
96
+ "era_start": era.start_date,
97
+ "pc": data_source.pc_code,
98
+ "meter_type": data_source.meter_type_code,
99
+ "imp_is_substation": imp_is_substation,
100
+ "imp_llfc_code": imp_llfc_code,
101
+ "imp_llfc_description": imp_llfc_description,
102
+ "exp_is_substation": exp_is_substation,
103
+ "exp_llfc_code": exp_llfc_code,
104
+ "exp_llfc_description": exp_llfc_description,
105
+ }
103
106
 
104
107
  vb_func(data_source)
105
108
  bill = data_source.supplier_bill
106
109
  for title in bill_titles:
107
110
  if title in bill:
108
- val = bill[title]
109
- del bill[title]
110
- else:
111
- val = ""
112
- vals.append(val)
113
-
114
- for k in sorted(bill.keys()):
115
- vals.append(k)
116
- vals.append(str(bill[k]))
111
+ vals[title] = bill[title]
117
112
 
118
113
  return vals
119
114
 
@@ -163,6 +158,9 @@ def create_csv(f, sess, start_date, finish_date, contract_id):
163
158
  "energisation_status",
164
159
  "gsp_group",
165
160
  "dno",
161
+ "era_start",
162
+ "pc",
163
+ "meter_type",
166
164
  "imp_is_substation",
167
165
  "imp_llfc_code",
168
166
  "imp_llfc_description",
@@ -170,7 +168,8 @@ def create_csv(f, sess, start_date, finish_date, contract_id):
170
168
  "exp_llfc_code",
171
169
  "exp_llfc_description",
172
170
  ]
173
- writer.writerow(header_titles + bill_titles)
171
+ titles = header_titles + bill_titles
172
+ writer.writerow(titles)
174
173
  vb_func = contract_func(caches, contract, "virtual_bill")
175
174
 
176
175
  for month_start, month_finish in month_pairs:
@@ -201,7 +200,7 @@ def create_csv(f, sess, start_date, finish_date, contract_id):
201
200
  period_finish,
202
201
  era,
203
202
  )
204
- writer.writerow(csv_make_val(v) for v in vals)
203
+ writer.writerow(csv_make_val(vals.get(t)) for t in titles)
205
204
  except BadRequest as e:
206
205
  raise BadRequest(
207
206
  f"Problem with {chellow.utils.url_root}eras/{era.id}/edit "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1719570651.0.0
3
+ Version: 1720526317.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)
@@ -74,7 +74,7 @@ chellow/reports/report_181.py,sha256=mCL6vXfrj8r0kL-LilDS0SnSu5tJOzCq7eMJVx9zpEw
74
74
  chellow/reports/report_183.py,sha256=DZX-hHJPl_Tbgkt31C_cuLZg_5L2b6iCPQ5foOZizR0,8817
75
75
  chellow/reports/report_187.py,sha256=UvpaYHjyJFNV5puYq8_KxfzoBtVrwFgIGUOmC5oGA9A,9956
76
76
  chellow/reports/report_219.py,sha256=cA0lfJKnJg41Zc4_gZB1KUXZ9JeJo0TiTlu5jm1bdDM,7158
77
- chellow/reports/report_231.py,sha256=gOb1AkXZQvwVpRg5cIenO7iR7Se1_zsWnJp9l2BlgpA,5008
77
+ chellow/reports/report_231.py,sha256=uhO1algP7sibpZVaniqGs56HOCPCQeDO-Y-UfvFQwnI,5311
78
78
  chellow/reports/report_233.py,sha256=cIatj-HHYW_GNIRsji-DlsmYjt8rUdm_5xujPLOYL8U,4537
79
79
  chellow/reports/report_241.py,sha256=AlFmSHnfG2HWv_ICmWX7fNpPwLHjq7mo1QtOTjSKO3k,5384
80
80
  chellow/reports/report_247.py,sha256=ozgCcee8XeqYbOpZCyU2STJKaz6h2x7TYQogagTaYLw,46626
@@ -83,10 +83,10 @@ 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
- chellow/reports/report_81.py,sha256=UYr0Dm4TmCCYUbIWw3hWNI0GdQRhH27vwVk3Ytdsrcg,5288
89
- chellow/reports/report_87.py,sha256=ZadBo40rUORN0Fi926-dDHeTFn6L-fBzp3b4k7v5MdY,6802
88
+ chellow/reports/report_81.py,sha256=f7sKPZUbl2VDbDHIg7B5rMDxcx_xnV1Y6PbjJyiTPLA,5609
89
+ chellow/reports/report_87.py,sha256=j2gdBOapaVY1ZnlNlw14RPx58_k8eUkc3oRSnKuCsNA,7057
90
90
  chellow/reports/report_asset_comparison.py,sha256=UN298MHuzyUDUiiZr7F_Ua6SrdVOlFLjgKjnIbrA-14,6118
91
91
  chellow/reports/report_batches.py,sha256=7O5TcB9W1sPKS0LQMsC6sUDzx73X5iyoZE0O3zK91zs,4798
92
92
  chellow/reports/report_bills.py,sha256=AHW6tiZAOE0gXDfencPvemE4zqK6eTqfN8_bWQ4RT5o,3323
@@ -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-1719570651.0.0.dist-info/METADATA,sha256=yaaDeEPCR9gyn7FAzr9s9ysogjV22XbTtqdeLVAJWHI,12205
368
- chellow-1719570651.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
369
- chellow-1719570651.0.0.dist-info/RECORD,,
367
+ chellow-1720526317.0.0.dist-info/METADATA,sha256=iyZrZ95p6OGYA8F9VMGixtiqBwF6NGri0JHZNnUJL_Y,12205
368
+ chellow-1720526317.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
369
+ chellow-1720526317.0.0.dist-info/RECORD,,