chellow 1733501869.0.0__py3-none-any.whl → 1736431515.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/bill_parsers/edf_export_xlsx.py +59 -50
- chellow/e/views.py +122 -0
- chellow/templates/e/site_hh_data.html +73 -49
- chellow/templates/e/supply.html +0 -2
- chellow/templates/g/supply.html +2 -4
- chellow/templates/site.html +1 -1
- chellow/views.py +0 -119
- {chellow-1733501869.0.0.dist-info → chellow-1736431515.0.0.dist-info}/METADATA +2 -2
- {chellow-1733501869.0.0.dist-info → chellow-1736431515.0.0.dist-info}/RECORD +10 -11
- {chellow-1733501869.0.0.dist-info → chellow-1736431515.0.0.dist-info}/WHEEL +1 -1
- chellow/templates/site_hh_data.html +0 -75
|
@@ -7,7 +7,7 @@ from openpyxl import load_workbook
|
|
|
7
7
|
|
|
8
8
|
from werkzeug.exceptions import BadRequest
|
|
9
9
|
|
|
10
|
-
from chellow.utils import
|
|
10
|
+
from chellow.utils import c_months_u, ct_datetime, parse_mpan_core, to_ct, to_utc
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def get_cell(sheet, col, row):
|
|
@@ -86,6 +86,63 @@ ELEM_LOOKUP = {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
|
|
89
|
+
def _parse_gduos_sheet(sheet, mpan_core, issue_date):
|
|
90
|
+
bills = []
|
|
91
|
+
for row in range(2, len(sheet["A"]) + 1):
|
|
92
|
+
val = get_cell(sheet, "A", row).value
|
|
93
|
+
if val is None or val == "":
|
|
94
|
+
break
|
|
95
|
+
|
|
96
|
+
start_date_str = get_str(sheet, "B", row)
|
|
97
|
+
start_date_ct = to_ct(Datetime.strptime(start_date_str, "%Y-%m"))
|
|
98
|
+
start_date, finish_date = next(
|
|
99
|
+
c_months_u(
|
|
100
|
+
start_year=start_date_ct.year, start_month=start_date_ct.month, months=1
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
element_desc = get_str(sheet, "D", row).strip()
|
|
105
|
+
units = get_dec(sheet, "E", row)
|
|
106
|
+
rate = get_dec(sheet, "F", row)
|
|
107
|
+
net = round(get_dec(sheet, "G", row), 2)
|
|
108
|
+
|
|
109
|
+
titles = ELEM_LOOKUP[element_desc]
|
|
110
|
+
if titles is None:
|
|
111
|
+
continue
|
|
112
|
+
|
|
113
|
+
breakdown = {
|
|
114
|
+
titles["gbp"]: net,
|
|
115
|
+
titles["units"]: units,
|
|
116
|
+
titles["rate"]: [rate],
|
|
117
|
+
}
|
|
118
|
+
bill = {
|
|
119
|
+
"bill_type_code": "N",
|
|
120
|
+
"kwh": Decimal(0),
|
|
121
|
+
"vat": Decimal("0.00"),
|
|
122
|
+
"net": net,
|
|
123
|
+
"gross": net,
|
|
124
|
+
"reads": [],
|
|
125
|
+
"breakdown": breakdown,
|
|
126
|
+
"account": mpan_core,
|
|
127
|
+
"issue_date": issue_date,
|
|
128
|
+
"start_date": start_date,
|
|
129
|
+
"finish_date": finish_date,
|
|
130
|
+
"mpan_core": mpan_core,
|
|
131
|
+
"reference": "_".join(
|
|
132
|
+
(
|
|
133
|
+
to_ct(start_date).strftime("%Y%m%d"),
|
|
134
|
+
to_ct(finish_date).strftime("%Y%m%d"),
|
|
135
|
+
to_ct(issue_date).strftime("%Y%m%d"),
|
|
136
|
+
mpan_core,
|
|
137
|
+
titles["name"],
|
|
138
|
+
)
|
|
139
|
+
),
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
bills.append(bill)
|
|
143
|
+
return bills
|
|
144
|
+
|
|
145
|
+
|
|
89
146
|
def _make_raw_bills(book):
|
|
90
147
|
bills = []
|
|
91
148
|
sheet = book.worksheets[0]
|
|
@@ -135,56 +192,8 @@ def _make_raw_bills(book):
|
|
|
135
192
|
}
|
|
136
193
|
)
|
|
137
194
|
sheet = book.worksheets[3]
|
|
138
|
-
|
|
139
|
-
val = get_cell(sheet, "A", row).value
|
|
140
|
-
if val is None or val == "":
|
|
141
|
-
break
|
|
195
|
+
bills.extend(_parse_gduos_sheet(sheet, mpan_core, issue_date))
|
|
142
196
|
|
|
143
|
-
start_date_str = get_str(sheet, "B", row)
|
|
144
|
-
start_date_ct = to_ct(Datetime.strptime(start_date_str, "%Y-%m"))
|
|
145
|
-
start_date = to_utc(start_date_ct)
|
|
146
|
-
finish_date = to_utc(start_date_ct + relativedelta(months=1) - HH)
|
|
147
|
-
|
|
148
|
-
element_desc = get_str(sheet, "D", row).strip()
|
|
149
|
-
units = get_dec(sheet, "E", row)
|
|
150
|
-
rate = get_dec(sheet, "F", row)
|
|
151
|
-
net = round(get_dec(sheet, "G", row), 2)
|
|
152
|
-
|
|
153
|
-
titles = ELEM_LOOKUP[element_desc]
|
|
154
|
-
if titles is None:
|
|
155
|
-
continue
|
|
156
|
-
|
|
157
|
-
breakdown = {
|
|
158
|
-
titles["gbp"]: net,
|
|
159
|
-
titles["units"]: units,
|
|
160
|
-
titles["rate"]: [rate],
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
bills.append(
|
|
164
|
-
{
|
|
165
|
-
"bill_type_code": "N",
|
|
166
|
-
"kwh": Decimal(0),
|
|
167
|
-
"vat": Decimal("0.00"),
|
|
168
|
-
"net": net,
|
|
169
|
-
"gross": net,
|
|
170
|
-
"reads": [],
|
|
171
|
-
"breakdown": breakdown,
|
|
172
|
-
"account": mpan_core,
|
|
173
|
-
"issue_date": issue_date,
|
|
174
|
-
"start_date": start_date,
|
|
175
|
-
"finish_date": finish_date,
|
|
176
|
-
"mpan_core": mpan_core,
|
|
177
|
-
"reference": "_".join(
|
|
178
|
-
(
|
|
179
|
-
to_ct(start_date).strftime("%Y%m%d"),
|
|
180
|
-
to_ct(finish_date).strftime("%Y%m%d"),
|
|
181
|
-
to_ct(issue_date).strftime("%Y%m%d"),
|
|
182
|
-
mpan_core,
|
|
183
|
-
titles["name"],
|
|
184
|
-
)
|
|
185
|
-
),
|
|
186
|
-
}
|
|
187
|
-
)
|
|
188
197
|
return bills
|
|
189
198
|
|
|
190
199
|
|
chellow/e/views.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
|
3
3
|
import threading
|
|
4
4
|
from collections import defaultdict
|
|
5
5
|
from datetime import datetime as Datetime
|
|
6
|
+
from decimal import Decimal
|
|
6
7
|
from io import BytesIO, StringIO
|
|
7
8
|
from itertools import chain, islice
|
|
8
9
|
from random import random
|
|
@@ -4729,6 +4730,127 @@ def site_add_e_supply_post(site_id):
|
|
|
4729
4730
|
)
|
|
4730
4731
|
|
|
4731
4732
|
|
|
4733
|
+
@e.route("/sites/<int:site_id>/hh_data")
|
|
4734
|
+
def site_hh_data_get(site_id):
|
|
4735
|
+
caches = {}
|
|
4736
|
+
site = Site.get_by_id(g.sess, site_id)
|
|
4737
|
+
|
|
4738
|
+
start_year = req_int("start_year")
|
|
4739
|
+
start_month = req_int("start_month")
|
|
4740
|
+
start_date, finish_date = next(
|
|
4741
|
+
c_months_u(start_year=start_year, start_month=start_month, months=1)
|
|
4742
|
+
)
|
|
4743
|
+
|
|
4744
|
+
supplies = (
|
|
4745
|
+
g.sess.query(Supply)
|
|
4746
|
+
.join(Era)
|
|
4747
|
+
.join(SiteEra)
|
|
4748
|
+
.join(Source)
|
|
4749
|
+
.filter(
|
|
4750
|
+
SiteEra.site == site,
|
|
4751
|
+
SiteEra.is_physical == true(),
|
|
4752
|
+
Era.start_date <= finish_date,
|
|
4753
|
+
or_(Era.finish_date == null(), Era.finish_date >= start_date),
|
|
4754
|
+
Source.code != "sub",
|
|
4755
|
+
)
|
|
4756
|
+
.order_by(Supply.id)
|
|
4757
|
+
.distinct()
|
|
4758
|
+
.options(joinedload(Supply.source), joinedload(Supply.generator_type))
|
|
4759
|
+
.all()
|
|
4760
|
+
)
|
|
4761
|
+
|
|
4762
|
+
data = iter(
|
|
4763
|
+
g.sess.query(HhDatum)
|
|
4764
|
+
.join(Channel)
|
|
4765
|
+
.join(Era)
|
|
4766
|
+
.filter(
|
|
4767
|
+
Channel.channel_type == "ACTIVE",
|
|
4768
|
+
Era.supply_id.in_([s.id for s in supplies]),
|
|
4769
|
+
HhDatum.start_date >= start_date,
|
|
4770
|
+
HhDatum.start_date <= finish_date,
|
|
4771
|
+
)
|
|
4772
|
+
.order_by(HhDatum.start_date, Era.supply_id)
|
|
4773
|
+
.options(
|
|
4774
|
+
joinedload(HhDatum.channel)
|
|
4775
|
+
.joinedload(Channel.era)
|
|
4776
|
+
.joinedload(Era.supply)
|
|
4777
|
+
.joinedload(Supply.source)
|
|
4778
|
+
)
|
|
4779
|
+
)
|
|
4780
|
+
datum = next(data, None)
|
|
4781
|
+
|
|
4782
|
+
hh_data = []
|
|
4783
|
+
for hh_date in hh_range(caches, start_date, finish_date):
|
|
4784
|
+
sups = []
|
|
4785
|
+
hh_dict = {
|
|
4786
|
+
"start_date": hh_date,
|
|
4787
|
+
"supplies": sups,
|
|
4788
|
+
"export_kwh": Decimal(0),
|
|
4789
|
+
"import_kwh": Decimal(0),
|
|
4790
|
+
"parasitic_kwh": Decimal(0),
|
|
4791
|
+
"generated_kwh": Decimal(0),
|
|
4792
|
+
"third_party_import_kwh": Decimal(0),
|
|
4793
|
+
"third_party_export_kwh": Decimal(0),
|
|
4794
|
+
}
|
|
4795
|
+
hh_data.append(hh_dict)
|
|
4796
|
+
for supply in supplies:
|
|
4797
|
+
sup_hh = {}
|
|
4798
|
+
sups.append(sup_hh)
|
|
4799
|
+
while (
|
|
4800
|
+
datum is not None
|
|
4801
|
+
and datum.start_date == hh_date
|
|
4802
|
+
and datum.channel.era.supply_id == supply.id
|
|
4803
|
+
):
|
|
4804
|
+
channel = datum.channel
|
|
4805
|
+
imp_related = channel.imp_related
|
|
4806
|
+
source_code = channel.era.supply.source.code
|
|
4807
|
+
|
|
4808
|
+
prefix = "import_" if imp_related else "export_"
|
|
4809
|
+
sup_hh[f"{prefix}kwh"] = datum.value
|
|
4810
|
+
sup_hh[f"{prefix}status"] = datum.status
|
|
4811
|
+
|
|
4812
|
+
if not imp_related and source_code in ("grid", "gen-grid"):
|
|
4813
|
+
hh_dict["export_kwh"] += datum.value
|
|
4814
|
+
if imp_related and source_code in ("grid", "gen-grid"):
|
|
4815
|
+
hh_dict["import_kwh"] += datum.value
|
|
4816
|
+
if (imp_related and source_code == "gen") or (
|
|
4817
|
+
not imp_related and source_code == "gen-grid"
|
|
4818
|
+
):
|
|
4819
|
+
hh_dict["generated_kwh"] += datum.value
|
|
4820
|
+
if (not imp_related and source_code == "gen") or (
|
|
4821
|
+
imp_related and source_code == "gen-grid"
|
|
4822
|
+
):
|
|
4823
|
+
hh_dict["parasitic_kwh"] += datum.value
|
|
4824
|
+
if (imp_related and source_code == "3rd-party") or (
|
|
4825
|
+
not imp_related and source_code == "3rd-party-reverse"
|
|
4826
|
+
):
|
|
4827
|
+
hh_dict["third_party_import_kwh"] += datum.value
|
|
4828
|
+
if (not imp_related and source_code == "3rd-party") or (
|
|
4829
|
+
imp_related and source_code == "3rd-party-reverse"
|
|
4830
|
+
):
|
|
4831
|
+
hh_dict["third_party_export_kwh"] += datum.value
|
|
4832
|
+
datum = next(data, None)
|
|
4833
|
+
|
|
4834
|
+
hh_dict["displaced_kwh"] = (
|
|
4835
|
+
hh_dict["generated_kwh"] - hh_dict["export_kwh"] - hh_dict["parasitic_kwh"]
|
|
4836
|
+
)
|
|
4837
|
+
hh_dict["used_kwh"] = sum(
|
|
4838
|
+
(
|
|
4839
|
+
hh_dict["import_kwh"],
|
|
4840
|
+
hh_dict["displaced_kwh"],
|
|
4841
|
+
hh_dict["third_party_import_kwh"] - hh_dict["third_party_export_kwh"],
|
|
4842
|
+
)
|
|
4843
|
+
)
|
|
4844
|
+
|
|
4845
|
+
return render_template(
|
|
4846
|
+
"site_hh_data.html",
|
|
4847
|
+
site=site,
|
|
4848
|
+
supplies=supplies,
|
|
4849
|
+
hh_data=hh_data,
|
|
4850
|
+
start_date=start_date,
|
|
4851
|
+
)
|
|
4852
|
+
|
|
4853
|
+
|
|
4732
4854
|
@e.route("/sources")
|
|
4733
4855
|
def sources_get():
|
|
4734
4856
|
sources = g.sess.query(Source).order_by(Source.code)
|
|
@@ -1,52 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
1
|
+
{% extends "base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block title %}
|
|
4
|
+
Sites » {{site.code}} {{site.name}} » HH data
|
|
5
|
+
{% endblock %}
|
|
6
|
+
|
|
7
|
+
{% block inside_head %}
|
|
8
|
+
<style>
|
|
9
|
+
tbody > tr {
|
|
10
|
+
scroll-margin-top: 8em;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
tbody > tr:target {
|
|
14
|
+
background-color: yellow;
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
{% endblock %}
|
|
18
|
+
|
|
19
|
+
{% block nav %}
|
|
20
|
+
<a href="/sites">Sites</a> »
|
|
21
|
+
<a href="/sites/{{site.id}}">{{site.code}} {{site.name}}</a> » HH data
|
|
22
|
+
{% endblock %}
|
|
23
|
+
|
|
24
|
+
{% block content %}
|
|
25
|
+
<form action="/e/sites/{{site.id}}/hh_data">
|
|
26
|
+
<fieldset>
|
|
27
|
+
<label>Month</label> {{input_date(prefix='start', initial=start_date, resolution='month')}}
|
|
28
|
+
<input type="submit" value="Show">
|
|
29
|
+
</fieldset>
|
|
30
|
+
</form>
|
|
31
|
+
|
|
32
|
+
<table class="sticky">
|
|
33
|
+
<caption>HH Data</caption>
|
|
34
|
+
<thead>
|
|
34
35
|
<tr>
|
|
35
|
-
<
|
|
36
|
-
<
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
<
|
|
40
|
-
<
|
|
41
|
-
<
|
|
42
|
-
{% for
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
<
|
|
36
|
+
<th>HH Starting</th>
|
|
37
|
+
<th>Imported kWh</th>
|
|
38
|
+
<th>Used kWh</th>
|
|
39
|
+
<th>Displaced kWh</th>
|
|
40
|
+
<th>Generated kWh</th>
|
|
41
|
+
<th>Exported kWh</th>
|
|
42
|
+
<th>Parasitic kWh</th>
|
|
43
|
+
{% for supply in supplies %}
|
|
44
|
+
{% set pref = supply.name + ' '+ supply.source.code +
|
|
45
|
+
(' ' + supply.generator_type.code if
|
|
46
|
+
supply.generator_type != None else '') %}
|
|
47
|
+
<th style="border-left-width: medium;">{{pref}} Imp kWh</th>
|
|
48
|
+
<th>{{pref}} Imp Status</th>
|
|
49
|
+
<th>{{pref}} Exp kWh</th>
|
|
50
|
+
<th>{{pref}} Exp Status</th>
|
|
48
51
|
{% endfor %}
|
|
49
52
|
</tr>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
</thead>
|
|
54
|
+
<tbody>
|
|
55
|
+
{% for hh in hh_data %}
|
|
56
|
+
{% set start_str = hh.start_date|hh_format %}
|
|
57
|
+
<tr id="{{start_str}}">
|
|
58
|
+
<td style="white-space: nowrap">{{start_str}}</td>
|
|
59
|
+
<td>{{hh.import_kwh}}</td>
|
|
60
|
+
<td>{{hh.used_kwh}}</td>
|
|
61
|
+
<td>{{hh.displaced_kwh}}</td>
|
|
62
|
+
<td>{{hh.generated_kwh}}</td>
|
|
63
|
+
<td>{{hh.export_kwh}}</td>
|
|
64
|
+
<td>{{hh.parasitic_kwh}}</td>
|
|
65
|
+
{% for datum in hh.supplies %}
|
|
66
|
+
<td style="border-left-width: medium;"
|
|
67
|
+
>{{datum.import_kwh}}</td>
|
|
68
|
+
<td>{{datum.import_status}}</td>
|
|
69
|
+
<td>{{datum.export_kwh}}</td>
|
|
70
|
+
<td>{{datum.export_status}}</td>
|
|
71
|
+
{% endfor %}
|
|
72
|
+
</tr>
|
|
73
|
+
{% endfor %}
|
|
74
|
+
</tbody>
|
|
75
|
+
</table>
|
|
76
|
+
{% endblock %}
|
chellow/templates/e/supply.html
CHANGED
|
@@ -218,8 +218,6 @@
|
|
|
218
218
|
{{ input_number('months', initial='1', size='2', maxlength='2', required=True) }}
|
|
219
219
|
<label>Final Month</label>
|
|
220
220
|
{{ input_date('finish', last_month_finish, 'month') }}
|
|
221
|
-
<label>Include bill check tabs?</label>
|
|
222
|
-
{{input_checkbox('is_bill_check')}}
|
|
223
221
|
<input type="submit" value="Download">
|
|
224
222
|
</fieldset>
|
|
225
223
|
</form>
|
chellow/templates/g/supply.html
CHANGED
|
@@ -366,10 +366,8 @@
|
|
|
366
366
|
<fieldset>
|
|
367
367
|
<input type="hidden" name="g_supply_id" value="{{g_supply.id}}">
|
|
368
368
|
<legend>Monthly Duration</legend>
|
|
369
|
-
<
|
|
370
|
-
|
|
371
|
-
month(s) finishing at the end of
|
|
372
|
-
{{ input_date('finish', last_month_finish, 'month') }}
|
|
369
|
+
<label>Months Long</label> <input name="months" maxlength="2" size="2" value="1">
|
|
370
|
+
<label>Last Month</label> {{ input_date('finish', last_month_finish, 'month') }}
|
|
373
371
|
<input type="submit" value="Download">
|
|
374
372
|
</fieldset>
|
|
375
373
|
</form>
|
chellow/templates/site.html
CHANGED
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
Table of site level monthly kWh, MD kWh etc.</a>
|
|
162
162
|
</li>
|
|
163
163
|
<li>
|
|
164
|
-
<a href="/sites/{{site.id}}/hh_data?
|
|
164
|
+
<a href="/e/sites/{{site.id}}/hh_data?start_year={{month_finish.year}}&start_month={{month_finish.month}}">Table of hh data</a>
|
|
165
165
|
</li>
|
|
166
166
|
<li>
|
|
167
167
|
<a href="/e/sites/{{site.id}}/site_snags">Site Snags</a>
|
chellow/views.py
CHANGED
|
@@ -10,7 +10,6 @@ import traceback
|
|
|
10
10
|
import types
|
|
11
11
|
from collections import OrderedDict
|
|
12
12
|
from datetime import datetime as Datetime
|
|
13
|
-
from decimal import Decimal
|
|
14
13
|
from functools import wraps
|
|
15
14
|
from importlib import import_module
|
|
16
15
|
from io import DEFAULT_BUFFER_SIZE, StringIO
|
|
@@ -50,7 +49,6 @@ from sqlalchemy import (
|
|
|
50
49
|
true,
|
|
51
50
|
)
|
|
52
51
|
from sqlalchemy.exc import IntegrityError
|
|
53
|
-
from sqlalchemy.orm import joinedload
|
|
54
52
|
from sqlalchemy.orm.attributes import flag_modified
|
|
55
53
|
|
|
56
54
|
from werkzeug.exceptions import BadRequest, Forbidden
|
|
@@ -1155,123 +1153,6 @@ def report_post(report_id):
|
|
|
1155
1153
|
return report_module.do_post(g.sess)
|
|
1156
1154
|
|
|
1157
1155
|
|
|
1158
|
-
@home.route("/sites/<int:site_id>/hh_data")
|
|
1159
|
-
def site_hh_data_get(site_id):
|
|
1160
|
-
caches = {}
|
|
1161
|
-
site = Site.get_by_id(g.sess, site_id)
|
|
1162
|
-
|
|
1163
|
-
year = req_int("year")
|
|
1164
|
-
month = req_int("month")
|
|
1165
|
-
start_date, finish_date = next(
|
|
1166
|
-
c_months_u(start_year=year, start_month=month, months=1)
|
|
1167
|
-
)
|
|
1168
|
-
|
|
1169
|
-
supplies = (
|
|
1170
|
-
g.sess.query(Supply)
|
|
1171
|
-
.join(Era)
|
|
1172
|
-
.join(SiteEra)
|
|
1173
|
-
.join(Source)
|
|
1174
|
-
.filter(
|
|
1175
|
-
SiteEra.site == site,
|
|
1176
|
-
SiteEra.is_physical == true(),
|
|
1177
|
-
Era.start_date <= finish_date,
|
|
1178
|
-
or_(Era.finish_date == null(), Era.finish_date >= start_date),
|
|
1179
|
-
Source.code != "sub",
|
|
1180
|
-
)
|
|
1181
|
-
.order_by(Supply.id)
|
|
1182
|
-
.distinct()
|
|
1183
|
-
.options(joinedload(Supply.source), joinedload(Supply.generator_type))
|
|
1184
|
-
.all()
|
|
1185
|
-
)
|
|
1186
|
-
|
|
1187
|
-
data = iter(
|
|
1188
|
-
g.sess.query(HhDatum)
|
|
1189
|
-
.join(Channel)
|
|
1190
|
-
.join(Era)
|
|
1191
|
-
.filter(
|
|
1192
|
-
Channel.channel_type == "ACTIVE",
|
|
1193
|
-
Era.supply_id.in_([s.id for s in supplies]),
|
|
1194
|
-
HhDatum.start_date >= start_date,
|
|
1195
|
-
HhDatum.start_date <= finish_date,
|
|
1196
|
-
)
|
|
1197
|
-
.order_by(HhDatum.start_date, Era.supply_id)
|
|
1198
|
-
.options(
|
|
1199
|
-
joinedload(HhDatum.channel)
|
|
1200
|
-
.joinedload(Channel.era)
|
|
1201
|
-
.joinedload(Era.supply)
|
|
1202
|
-
.joinedload(Supply.source)
|
|
1203
|
-
)
|
|
1204
|
-
)
|
|
1205
|
-
datum = next(data, None)
|
|
1206
|
-
|
|
1207
|
-
hh_data = []
|
|
1208
|
-
for hh_date in hh_range(caches, start_date, finish_date):
|
|
1209
|
-
sups = []
|
|
1210
|
-
hh_dict = {
|
|
1211
|
-
"start_date": hh_date,
|
|
1212
|
-
"supplies": sups,
|
|
1213
|
-
"export_kwh": Decimal(0),
|
|
1214
|
-
"import_kwh": Decimal(0),
|
|
1215
|
-
"parasitic_kwh": Decimal(0),
|
|
1216
|
-
"generated_kwh": Decimal(0),
|
|
1217
|
-
"third_party_import_kwh": Decimal(0),
|
|
1218
|
-
"third_party_export_kwh": Decimal(0),
|
|
1219
|
-
}
|
|
1220
|
-
hh_data.append(hh_dict)
|
|
1221
|
-
for supply in supplies:
|
|
1222
|
-
sup_hh = {}
|
|
1223
|
-
sups.append(sup_hh)
|
|
1224
|
-
while (
|
|
1225
|
-
datum is not None
|
|
1226
|
-
and datum.start_date == hh_date
|
|
1227
|
-
and datum.channel.era.supply_id == supply.id
|
|
1228
|
-
):
|
|
1229
|
-
channel = datum.channel
|
|
1230
|
-
imp_related = channel.imp_related
|
|
1231
|
-
source_code = channel.era.supply.source.code
|
|
1232
|
-
|
|
1233
|
-
prefix = "import_" if imp_related else "export_"
|
|
1234
|
-
sup_hh[f"{prefix}kwh"] = datum.value
|
|
1235
|
-
sup_hh[f"{prefix}status"] = datum.status
|
|
1236
|
-
|
|
1237
|
-
if not imp_related and source_code in ("grid", "gen-grid"):
|
|
1238
|
-
hh_dict["export_kwh"] += datum.value
|
|
1239
|
-
if imp_related and source_code in ("grid", "gen-grid"):
|
|
1240
|
-
hh_dict["import_kwh"] += datum.value
|
|
1241
|
-
if (imp_related and source_code == "gen") or (
|
|
1242
|
-
not imp_related and source_code == "gen-grid"
|
|
1243
|
-
):
|
|
1244
|
-
hh_dict["generated_kwh"] += datum.value
|
|
1245
|
-
if (not imp_related and source_code == "gen") or (
|
|
1246
|
-
imp_related and source_code == "gen-grid"
|
|
1247
|
-
):
|
|
1248
|
-
hh_dict["parasitic_kwh"] += datum.value
|
|
1249
|
-
if (imp_related and source_code == "3rd-party") or (
|
|
1250
|
-
not imp_related and source_code == "3rd-party-reverse"
|
|
1251
|
-
):
|
|
1252
|
-
hh_dict["third_party_import_kwh"] += datum.value
|
|
1253
|
-
if (not imp_related and source_code == "3rd-party") or (
|
|
1254
|
-
imp_related and source_code == "3rd-party-reverse"
|
|
1255
|
-
):
|
|
1256
|
-
hh_dict["third_party_export_kwh"] += datum.value
|
|
1257
|
-
datum = next(data, None)
|
|
1258
|
-
|
|
1259
|
-
hh_dict["displaced_kwh"] = (
|
|
1260
|
-
hh_dict["generated_kwh"] - hh_dict["export_kwh"] - hh_dict["parasitic_kwh"]
|
|
1261
|
-
)
|
|
1262
|
-
hh_dict["used_kwh"] = sum(
|
|
1263
|
-
(
|
|
1264
|
-
hh_dict["import_kwh"],
|
|
1265
|
-
hh_dict["displaced_kwh"],
|
|
1266
|
-
hh_dict["third_party_import_kwh"] - hh_dict["third_party_export_kwh"],
|
|
1267
|
-
)
|
|
1268
|
-
)
|
|
1269
|
-
|
|
1270
|
-
return render_template(
|
|
1271
|
-
"site_hh_data.html", site=site, supplies=supplies, hh_data=hh_data
|
|
1272
|
-
)
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
1156
|
@home.route("/sites/<int:site_id>")
|
|
1276
1157
|
def site_get(site_id):
|
|
1277
1158
|
configuration_contract = Contract.get_non_core_by_name(g.sess, "configuration")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: chellow
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1736431515.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)
|
|
@@ -12,7 +12,7 @@ chellow/rate_server.py,sha256=fg-Pf_9Hk3bXmC9riPQNGQxBvLvBa_WtNYdwDCjnCSg,5678
|
|
|
12
12
|
chellow/rrun.py,sha256=1Kt2q_K9UoDG_nsZz-Q6XJiMNKroWqlqFdxn2M6Q8CA,2088
|
|
13
13
|
chellow/testing.py,sha256=Od4HHH6pZrhJ_De118_F55RJEKmAvhUH2S24QE9qFQk,3635
|
|
14
14
|
chellow/utils.py,sha256=Ej7dsbQ6Ee8X2aZ7B2Vs-hUFCsMABioAdOV1DJjwY-0,19293
|
|
15
|
-
chellow/views.py,sha256=
|
|
15
|
+
chellow/views.py,sha256=OlNGtFB9OatQPMzHiXTjBoGOSnFT7cC38GA2x7rtcFg,79490
|
|
16
16
|
chellow/e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
chellow/e/aahedc.py,sha256=d2usudp7KYWpU6Pk3fal5EQ47EbvkvKeaFGylnb3NWw,606
|
|
18
18
|
chellow/e/bill_importer.py,sha256=7UcnqNlKbJc2GhW9gy8sDp9GuqambJVpZLvbafOZztA,7411
|
|
@@ -43,13 +43,13 @@ chellow/e/system_price.py,sha256=6w5J7bzwFAZubE2zdOFRiS8IIrVP8hkoIOaG2yCt-Ic,623
|
|
|
43
43
|
chellow/e/tlms.py,sha256=M33D6YpMixu2KkwSCzDRM3kThLgShg8exp63Obo75l8,8905
|
|
44
44
|
chellow/e/tnuos.py,sha256=NBmc-f3oezrl4gviAKobljHfICTpBKxxxEGBGJi_lRk,4927
|
|
45
45
|
chellow/e/triad.py,sha256=lIQj7EdUrcFwEqleuHZXYU_bfzIwNOqUVVxB3NPQt4A,13710
|
|
46
|
-
chellow/e/views.py,sha256=
|
|
46
|
+
chellow/e/views.py,sha256=VkoB3-jgydp-2RMdlYVvSL4UVUmt7wMnCJpHSBdf1jM,220753
|
|
47
47
|
chellow/e/bill_parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
48
48
|
chellow/e/bill_parsers/activity_mop_stark_xlsx.py,sha256=UgWXDPzQkQghyj_lfgBqoSJpHB-t-qOdSaB8qY6GLog,4071
|
|
49
49
|
chellow/e/bill_parsers/annual_mop_stark_xlsx.py,sha256=-HMoIfa_utXYKA44RuC0Xqv3vd2HLeQU_4P0iBUd3WA,4219
|
|
50
50
|
chellow/e/bill_parsers/bgb_edi.py,sha256=GuwHeYbAGk7BVg5n19FcTANFDyKI-y0z3f9niQaPSSw,4828
|
|
51
51
|
chellow/e/bill_parsers/csv.py,sha256=U5zcIaZ6B5QTTpFDAcBnk4G2r8B3j5kJhDPL4AJNkEk,5640
|
|
52
|
-
chellow/e/bill_parsers/edf_export_xlsx.py,sha256=
|
|
52
|
+
chellow/e/bill_parsers/edf_export_xlsx.py,sha256=weVvtnXVBSNtz-CMiUHCTI2W8kV19lX7UDMZilxybKk,6440
|
|
53
53
|
chellow/e/bill_parsers/engie_edi.py,sha256=CTobTskDjzdcqqf_qk2ukDSaTLrVpGZMM0sYlwehog4,14985
|
|
54
54
|
chellow/e/bill_parsers/engie_export_xlsx.py,sha256=oZO0qHdDlOxjJ6J5Ate82CkAoX4bxed1EJyUKHxBcpk,4690
|
|
55
55
|
chellow/e/bill_parsers/engie_xls.py,sha256=jrut2heH_ZWmSjcn7celOydZS9Y49GfpYjDk_EKwamI,14453
|
|
@@ -152,11 +152,10 @@ chellow/templates/scenario_add.html,sha256=xFTb9CaA-qV2iwnVqcS44vD8JlYatBQet8Rat
|
|
|
152
152
|
chellow/templates/scenario_docs.html,sha256=0YP_h8GYkqCFLBoCj2w4PE4Js15DT_WoxYlK9nRSMlA,6949
|
|
153
153
|
chellow/templates/scenario_edit.html,sha256=x2Eicq_eFs7ax2EtL4GrD73qKF-LhN41OQdPFbDivrc,1060
|
|
154
154
|
chellow/templates/scenarios.html,sha256=FIDOSWs9VO_3bJkQoNHh-DdRzVfUyJGK9WbdEHRxxdM,841
|
|
155
|
-
chellow/templates/site.html,sha256=
|
|
155
|
+
chellow/templates/site.html,sha256=rvK4VnSsiSswyYTPJrKn4iKpT_-t1nfH-4yCPF7OKQc,10038
|
|
156
156
|
chellow/templates/site_add.html,sha256=NxYmOIZQH6X8EBOuJUbhUJ8IYB3t0BukjR1yVRhnJhM,422
|
|
157
157
|
chellow/templates/site_edit.html,sha256=TJ_ZDDkodj-uDB3GPP9Cel3FGZY2oP42KCzHOydPWVc,2909
|
|
158
158
|
chellow/templates/site_gen_graph.html,sha256=LXkD4n_aC_sFm9JJTCmBRrczpyTn2UUEgBToFiM5RPo,3468
|
|
159
|
-
chellow/templates/site_hh_data.html,sha256=xmSJ5h_DvI1-bnV7FdBodDUvDCU0-q-UHYj2MuyLOTg,1907
|
|
160
159
|
chellow/templates/site_months.html,sha256=ToqH42dym82Q4ihFIT3St-EwPlhDAfwskNMh4cZ2EsM,6572
|
|
161
160
|
chellow/templates/site_used_graph.html,sha256=NXuQYcPXnk2mHb2O4mxVPZ1R-X-MWPwneUV-J6z285w,3094
|
|
162
161
|
chellow/templates/sites.html,sha256=4ouJ5xYqYHjXCv3cDucTjgbOd_whReFPPHopLBdW6Go,621
|
|
@@ -291,7 +290,7 @@ chellow/templates/e/scenario_edit.html,sha256=Uf64v_qsBP0BxaFEIz214CC_dZXlvro4zv
|
|
|
291
290
|
chellow/templates/e/scenarios.html,sha256=zlNhZvQEcuwLgHObVHS-4THur5Lz9Jf1G6xD98-jamI,847
|
|
292
291
|
chellow/templates/e/site_add_e_supply.html,sha256=_gi1ejI4TMTMX9vCW7z2kToR2XKR6qoVh67qp_VrDsM,2731
|
|
293
292
|
chellow/templates/e/site_add_e_supply_form.html,sha256=q5LfSmp_eamph4FLKslMrxKGOtGCkSFRe9I5AVn-hgM,5553
|
|
294
|
-
chellow/templates/e/site_hh_data.html,sha256=
|
|
293
|
+
chellow/templates/e/site_hh_data.html,sha256=qCmqQcPKWhNiZ7eSVs8NhMIiBXJHVHF5OAzjEdppyjM,1982
|
|
295
294
|
chellow/templates/e/site_site_snags.html,sha256=vWpsFyxZj7GOrMXQz2rKq9zOQdVsqeUVtdBzehp9J5w,847
|
|
296
295
|
chellow/templates/e/site_snag.html,sha256=eZt1H-t-hsoKZBteU9ILpKqKLD0Pf0Uybp8pPQYuTAc,924
|
|
297
296
|
chellow/templates/e/site_snag_edit.html,sha256=O-m95S-ig9sXmFFkQmjfNnF9zJkgSIuPizuF7ieNi7s,1436
|
|
@@ -321,7 +320,7 @@ chellow/templates/e/supplier_contracts.html,sha256=VwWD4q88Fynz7vioFSAsyH6RR_1Sy
|
|
|
321
320
|
chellow/templates/e/supplier_rate_script.html,sha256=tjWeCUAgNip3VLHzbXqe19Msiasys3Wm5Vra936qJjI,1245
|
|
322
321
|
chellow/templates/e/supplier_rate_script_add.html,sha256=Yf2LZEIHbL7qT6oxBCtPf0ZX7vJsSo_ZeOKJhJoVh3o,690
|
|
323
322
|
chellow/templates/e/supplier_rate_script_edit.html,sha256=VaYJt8nxHdnuP-zEAuBJC-ibEpjDU1b80hXtdBQH1dg,1968
|
|
324
|
-
chellow/templates/e/supply.html,sha256=
|
|
323
|
+
chellow/templates/e/supply.html,sha256=kFyYPIzMgRZz7tHY_TfmjYzUkc1zXyaJses6X372Ozg,8427
|
|
325
324
|
chellow/templates/e/supply_edit.html,sha256=2BRGU35nb0ZpUHKCi_fgAPMU6SlHI7ve3_Ne8LXHtms,2333
|
|
326
325
|
chellow/templates/e/supply_eras.html,sha256=5lB7_oC-sTWRQoASuPgBWj5XSZa9ajR0s6V6xKHvf6E,19996
|
|
327
326
|
chellow/templates/e/supply_hh_data.html,sha256=d9ho4Tq3ZkR5GmxSZr_zHGwCU68PH3aSc4OwFG9i9zE,3587
|
|
@@ -370,13 +369,13 @@ chellow/templates/g/supplier_rate_script.html,sha256=e4dwskWTQcLv6qyX150VUeuaUvE
|
|
|
370
369
|
chellow/templates/g/supplier_rate_script_add.html,sha256=zMjTkjupOsHFu-peUXL4IKjjc2OaSL-2ah4T9OdKp_o,620
|
|
371
370
|
chellow/templates/g/supplier_rate_script_edit.html,sha256=GoUqXf52gWEH1iApmNdxOcKLItzpA-o7iQPQ1_in9BA,1950
|
|
372
371
|
chellow/templates/g/supplies.html,sha256=oEAEfZaAuKv7EA6fd3blWjPwv_XKoNHLPlkRJ_afZHs,1267
|
|
373
|
-
chellow/templates/g/supply.html,sha256=
|
|
372
|
+
chellow/templates/g/supply.html,sha256=eWuSDHh8de-LgLVlrNPWLX-_jiRn1uB3CZNpGK1xBYA,11006
|
|
374
373
|
chellow/templates/g/supply_edit.html,sha256=F2Ip4xCXLl4eFiRjMLZyUMIiznWw97GF7mN_50QAEWA,1653
|
|
375
374
|
chellow/templates/g/supply_note_add.html,sha256=zWwppQTxBfN7Dw6Cgr330mw7SgDRoTcaIdAucNisZRE,658
|
|
376
375
|
chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1nAPevz-AgkhQ,1036
|
|
377
376
|
chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
|
|
378
377
|
chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
|
|
379
378
|
chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
|
|
380
|
-
chellow-
|
|
381
|
-
chellow-
|
|
382
|
-
chellow-
|
|
379
|
+
chellow-1736431515.0.0.dist-info/METADATA,sha256=78QJHzK7SfEhS31W3L2h1zcoNfkEVk9udgaEMeqXepU,12204
|
|
380
|
+
chellow-1736431515.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
381
|
+
chellow-1736431515.0.0.dist-info/RECORD,,
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
{% extends "base.html" %}
|
|
2
|
-
|
|
3
|
-
{% block title %}
|
|
4
|
-
Sites » {{site.code}} {{site.name}} » HH data
|
|
5
|
-
{% endblock %}
|
|
6
|
-
|
|
7
|
-
{% block inside_head %}
|
|
8
|
-
<style>
|
|
9
|
-
tbody > tr {
|
|
10
|
-
scroll-margin-top: 8em;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
tbody > tr:target {
|
|
14
|
-
background-color: yellow;
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
{% endblock %}
|
|
18
|
-
|
|
19
|
-
{% block nav %}
|
|
20
|
-
<a href="/sites">Sites</a> »
|
|
21
|
-
<a href="/sites/{{site.id}}">{{site.code}} {{site.name}}</a> » HH data
|
|
22
|
-
{% endblock %}
|
|
23
|
-
|
|
24
|
-
{% block content %}
|
|
25
|
-
<form>
|
|
26
|
-
<fieldset>
|
|
27
|
-
<label>Month</label> {{input_date(resolution='month')}}
|
|
28
|
-
<input type="submit" value="Show">
|
|
29
|
-
</fieldset>
|
|
30
|
-
</form>
|
|
31
|
-
<table class="sticky">
|
|
32
|
-
<caption>HH Data</caption>
|
|
33
|
-
<thead>
|
|
34
|
-
<tr>
|
|
35
|
-
<th>HH Starting</th>
|
|
36
|
-
<th>Imported kWh</th>
|
|
37
|
-
<th>Used kWh</th>
|
|
38
|
-
<th>Displaced kWh</th>
|
|
39
|
-
<th>Generated kWh</th>
|
|
40
|
-
<th>Exported kWh</th>
|
|
41
|
-
<th>Parasitic kWh</th>
|
|
42
|
-
{% for supply in supplies %}
|
|
43
|
-
{% set pref = supply.name + ' '+ supply.source.code +
|
|
44
|
-
(' ' + supply.generator_type.code if
|
|
45
|
-
supply.generator_type != None else '') %}
|
|
46
|
-
<th style="border-left-width: medium;">{{pref}} Imp kWh</th>
|
|
47
|
-
<th>{{pref}} Imp Status</th>
|
|
48
|
-
<th>{{pref}} Exp kWh</th>
|
|
49
|
-
<th>{{pref}} Exp Status</th>
|
|
50
|
-
{% endfor %}
|
|
51
|
-
</tr>
|
|
52
|
-
</thead>
|
|
53
|
-
<tbody>
|
|
54
|
-
{% for hh in hh_data %}
|
|
55
|
-
{% set start_str = hh.start_date|hh_format %}
|
|
56
|
-
<tr id="{{start_str}}">
|
|
57
|
-
<td style="white-space: nowrap">{{start_str}}</td>
|
|
58
|
-
<td>{{hh.import_kwh}}</td>
|
|
59
|
-
<td>{{hh.used_kwh}}</td>
|
|
60
|
-
<td>{{hh.displaced_kwh}}</td>
|
|
61
|
-
<td>{{hh.generated_kwh}}</td>
|
|
62
|
-
<td>{{hh.export_kwh}}</td>
|
|
63
|
-
<td>{{hh.parasitic_kwh}}</td>
|
|
64
|
-
{% for datum in hh.supplies %}
|
|
65
|
-
<td style="border-left-width: medium;"
|
|
66
|
-
>{{datum.import_kwh}}</td>
|
|
67
|
-
<td>{{datum.import_status}}</td>
|
|
68
|
-
<td>{{datum.export_kwh}}</td>
|
|
69
|
-
<td>{{datum.export_status}}</td>
|
|
70
|
-
{% endfor %}
|
|
71
|
-
</tr>
|
|
72
|
-
{% endfor %}
|
|
73
|
-
</tbody>
|
|
74
|
-
</table>
|
|
75
|
-
{% endblock %}
|