chellow 1757320031.0.0__py3-none-any.whl → 1759155233.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_importer.py +136 -80
- chellow/e/bill_parsers/activity_mop_stark_xlsx.py +99 -86
- chellow/e/bill_parsers/annual_mop_stark_xlsx.py +78 -61
- chellow/e/bill_parsers/csv.py +139 -101
- chellow/e/bill_parsers/drax_edi.py +65 -89
- chellow/e/bill_parsers/engie_edi.py +187 -255
- chellow/e/bill_parsers/engie_xls.py +153 -167
- chellow/e/bill_parsers/haven_edi.py +189 -228
- chellow/e/bill_parsers/haven_edi_tprs.py +67 -67
- chellow/e/bill_parsers/nonsettlement_dc_stark_xlsx.py +75 -66
- chellow/e/bill_parsers/settlement_dc_stark_xlsx.py +229 -126
- chellow/e/bill_parsers/sse_edi.py +107 -75
- chellow/e/bill_parsers/sww_xls.py +78 -91
- chellow/e/computer.py +1 -1
- chellow/e/views.py +626 -281
- chellow/edi_lib.py +4 -27
- chellow/models.py +92 -3
- chellow/reports/report_111.py +478 -616
- chellow/reports/report_247.py +96 -137
- chellow/templates/e/dc_batch.html +110 -157
- chellow/templates/e/dc_batch_add.html +2 -3
- chellow/templates/e/dc_batch_edit.html +42 -46
- chellow/templates/e/dc_batch_file.html +2 -3
- chellow/templates/e/dc_batch_file_edit.html +28 -40
- chellow/templates/e/dc_batch_upload_file.html +68 -0
- chellow/templates/e/dc_batches.html +2 -1
- chellow/templates/e/dc_batches_edit.html +26 -0
- chellow/templates/e/dc_bill.html +27 -5
- chellow/templates/e/dc_bill_add.html +4 -4
- chellow/templates/e/dc_bill_edit.html +43 -63
- chellow/templates/e/dc_bill_import.html +1 -1
- chellow/templates/e/dc_bill_import_contract.html +130 -0
- chellow/templates/e/dc_contract.html +1 -1
- chellow/templates/e/dc_element.html +41 -0
- chellow/templates/e/dc_element_add.html +36 -0
- chellow/templates/e/dc_element_edit.html +49 -0
- chellow/templates/e/dc_rate_script_edit.html +27 -43
- chellow/templates/e/mop_batch.html +105 -152
- chellow/templates/e/mop_batch_add.html +2 -3
- chellow/templates/e/mop_batch_edit.html +43 -51
- chellow/templates/e/mop_batch_upload_file.html +71 -5
- chellow/templates/e/mop_batches.html +2 -1
- chellow/templates/e/mop_batches_edit.html +26 -0
- chellow/templates/e/mop_bill.html +31 -8
- chellow/templates/e/mop_bill_add.html +7 -27
- chellow/templates/e/mop_bill_import.html +1 -1
- chellow/templates/e/mop_bill_import_contract.html +130 -0
- chellow/templates/e/mop_contract.html +4 -5
- chellow/templates/e/mop_element.html +41 -0
- chellow/templates/e/mop_element_add.html +36 -0
- chellow/templates/e/mop_element_edit.html +49 -0
- chellow/templates/e/supplier_batch.html +3 -7
- chellow/templates/e/supplier_batch_add.html +2 -2
- chellow/templates/e/supplier_batch_edit.html +1 -1
- chellow/templates/e/supplier_batch_file.html +3 -5
- chellow/templates/e/supplier_batch_file_add.html +18 -11
- chellow/templates/e/supplier_batch_upload_file.html +83 -9
- chellow/templates/e/supplier_batches.html +4 -4
- chellow/templates/e/supplier_batches_edit.html +26 -0
- chellow/templates/e/supplier_bill.html +29 -6
- chellow/templates/e/supplier_bill_add.html +3 -3
- chellow/templates/e/supplier_bill_import.html +1 -1
- chellow/templates/e/supplier_bill_import_contract.html +118 -0
- chellow/templates/e/supplier_contract.html +1 -1
- chellow/templates/e/supplier_element.html +45 -0
- chellow/templates/e/supplier_element_add.html +36 -0
- chellow/templates/e/supplier_element_edit.html +51 -0
- chellow/templates/report_run_bill_check.html +137 -179
- chellow/templates/report_run_row_bill_check.html +182 -179
- chellow/views.py +55 -65
- {chellow-1757320031.0.0.dist-info → chellow-1759155233.0.0.dist-info}/METADATA +2 -2
- {chellow-1757320031.0.0.dist-info → chellow-1759155233.0.0.dist-info}/RECORD +73 -60
- chellow/e/bill_parsers/drax_element_edi.py +0 -459
- chellow/templates/e/supplier_bill_imports.html +0 -421
- {chellow-1757320031.0.0.dist-info → chellow-1759155233.0.0.dist-info}/WHEEL +0 -0
|
@@ -6,7 +6,7 @@ from werkzeug.exceptions import BadRequest
|
|
|
6
6
|
|
|
7
7
|
from xlrd import open_workbook
|
|
8
8
|
|
|
9
|
-
from chellow.utils import HH,
|
|
9
|
+
from chellow.utils import HH, ct_datetime, to_utc, utc_datetime_now
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def get_value(row, title_row, name):
|
|
@@ -46,93 +46,76 @@ def get_rate(row, title_row, name):
|
|
|
46
46
|
def get_date_ct(row, title_row, name):
|
|
47
47
|
s = get_value(row, title_row, name)
|
|
48
48
|
nums = list(map(int, s.split("-")))
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
("duos-green-gbp", get_dec(row, titles, "DUOS-UNIT-GREEN COST GBP")),
|
|
85
|
-
("duos-red-kwh", get_dec(row, titles, "DUOS-UNIT-RED USE KWH")),
|
|
86
|
-
("duos-red-rate", get_rate(row, titles, "DUOS-UNIT-RED RATE P/KWH")),
|
|
87
|
-
("duos-red-gbp", get_dec(row, titles, "DUOS-UNIT-RED COST GBP")),
|
|
88
|
-
("aahedc-kwh", aahedc_kwh),
|
|
89
|
-
("aahedc-rate", get_rate(row, titles, "LVY-AAHEDC-ALL RATE P/KWH")),
|
|
90
|
-
("aahedc-gbp", get_dec(row, titles, "LVY-AAHEDC-ALL COST GBP")),
|
|
91
|
-
("bsuos-nbp-kwh", get_dec(row, titles, "LVY-BSUOS-ALL USE KWH")),
|
|
92
|
-
("bsuos-rate", get_rate(row, titles, "LVY-BSUOS-ALL RATE P/KWH")),
|
|
93
|
-
("bsuos-gbp", get_dec(row, titles, "LVY-BSUOS-ALL COST GBP")),
|
|
94
|
-
("ccl-kwh", get_dec(row, titles, "LVY-CCL-ALL USE KWH")),
|
|
95
|
-
("ccl-rate", get_rate(row, titles, "LVY-CCL-ALL RATE P/KWH")),
|
|
96
|
-
("ccl-gbp", get_dec(row, titles, "LVY-CCL-ALL COST GBP")),
|
|
97
|
-
("cfdob-kwh", get_dec(row, titles, "LVY-CFDOB-ALL USE KWH")),
|
|
98
|
-
("cfdob-rate", get_rate(row, titles, "LVY-CFDOB-ALL RATE P/KWH")),
|
|
99
|
-
("cfdob-gbp", get_dec(row, titles, "LVY-CFDOB-ALL COST GBP")),
|
|
100
|
-
("cfdop-kwh", get_dec(row, titles, "LVY-CFDOP-ALL USE KWH")),
|
|
101
|
-
("cfdop-rate", get_rate(row, titles, "LVY-CFDOP-ALL RATE P/KWH")),
|
|
102
|
-
("cfdop-gbp", get_dec(row, titles, "LVY-CFDOP-ALL COST GBP")),
|
|
103
|
-
("fit-kwh", get_dec(row, titles, "LVY-FIT-ALL USE KWH")),
|
|
104
|
-
("fit-rate", get_rate(row, titles, "LVY-FIT-ALL RATE P/KWH")),
|
|
105
|
-
("fit-gbp", get_dec(row, titles, "LVY-FIT-ALL COST GBP")),
|
|
106
|
-
("ro-kwh", get_dec(row, titles, "LVY-RO-ALL USE KWH")),
|
|
107
|
-
("ro-rate", get_rate(row, titles, "LVY-RO-ALL RATE P/KWH")),
|
|
108
|
-
("ro-gbp", get_dec(row, titles, "LVY-RO-ALL COST GBP")),
|
|
109
|
-
("summer-kwh", get_dec(row, titles, "NRG-UNIT-SUMMER USE KWH")),
|
|
110
|
-
("summer-rate", get_rate(row, titles, "NRG-UNIT-SUMMER RATE P/KWH")),
|
|
111
|
-
("summer-gbp", get_dec(row, titles, "NRG-UNIT-SUMMER COST GBP")),
|
|
112
|
-
("winter-kwh", get_dec(row, titles, "NRG-UNIT-WINTER USE KWH")),
|
|
113
|
-
("winter-rate", get_rate(row, titles, "NRG-UNIT-WINTER RATE P/KWH")),
|
|
114
|
-
("winter-gbp", get_dec(row, titles, "NRG-UNIT-WINTER COST GBP")),
|
|
115
|
-
("admin-months", get_dec(row, titles, "SYS-ADMIN-ALL USE MO")),
|
|
116
|
-
("admin-rate", [get_dec(row, titles, "SYS-ADMIN-ALL RATE GBP/MO")]),
|
|
117
|
-
("admin-gbp", get_dec(row, titles, "SYS-ADMIN-ALL COST GBP")),
|
|
118
|
-
("triad-days", get_dec(row, titles, "TUOS-TRIAD-SITE USE DAY")),
|
|
119
|
-
("triad-rate", [get_dec(row, titles, "TUOS-TRIAD-SITE RATE GBP/DAY")]),
|
|
120
|
-
("triad-gbp", get_dec(row, titles, "TUOS-TRIAD-SITE COST GBP")),
|
|
121
|
-
]
|
|
122
|
-
|
|
123
|
-
bd = {
|
|
124
|
-
"raw_lines": [str(title_row), str(row)],
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
for k, v in vals:
|
|
128
|
-
if v is not None and v != [None]:
|
|
129
|
-
bd[k] = v
|
|
130
|
-
|
|
131
|
-
kwh = Decimal("0.00") if aahedc_kwh is None else aahedc_kwh
|
|
49
|
+
return ct_datetime(nums[0], nums[1], nums[2])
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
ELEMENT_NAME_LOOKUP = {
|
|
53
|
+
"LVY-CMLOB-ALL": "capmechob",
|
|
54
|
+
"LVY-CMLOP-ALL": "capmechop",
|
|
55
|
+
"DUOS-STND-SITE": "duos-fixed",
|
|
56
|
+
"DUOS-AVAIL-AV": "duos-availability",
|
|
57
|
+
"DUOS-UNIT-AMBER": "duos-amber",
|
|
58
|
+
"DUOS-UNIT-GREEN": "duos-green",
|
|
59
|
+
"DUOS-UNIT-RED": "duos-red",
|
|
60
|
+
"LVY-AAHEDC-ALL": "aahedc",
|
|
61
|
+
"LVY-BSUOS-ALL": "bsuos",
|
|
62
|
+
"LVY-CCL-ALL": "ccl",
|
|
63
|
+
"LVY-CFDOB-ALL": "cfdob",
|
|
64
|
+
"LVY-CFDOP-ALL": "cfdop",
|
|
65
|
+
"LVY-FIT-ALL": "fit",
|
|
66
|
+
"LVY-RO-ALL": "ro",
|
|
67
|
+
"NRG-UNIT-SUMMER": "summer",
|
|
68
|
+
"NRG-UNIT-WINTER": "winter",
|
|
69
|
+
"SYS-ADMIN-ALL": "admin",
|
|
70
|
+
"TUOS-TRIAD-SITE": "triad",
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _parse_row(issue_date, row, row_index, datemode, title_row):
|
|
75
|
+
titles = [c.value for c in title_row if c.value is not None]
|
|
76
|
+
bill_start_date_ct = get_date_ct(row, titles, "BILL START DATE")
|
|
77
|
+
start_date = to_utc(bill_start_date_ct)
|
|
78
|
+
bill_finish_date_ct = get_date_ct(row, titles, "BILL END DATE") + (HH * 47)
|
|
79
|
+
finish_date = to_utc(bill_finish_date_ct)
|
|
80
|
+
|
|
81
|
+
elements = {}
|
|
82
|
+
|
|
83
|
+
kwh = 0
|
|
132
84
|
net_gbp = Decimal("0.00")
|
|
133
|
-
net_gbp += sum(v for k, v in bd.items() if k.endswith("-gbp"))
|
|
134
85
|
vat_gbp = Decimal("0.00")
|
|
135
|
-
|
|
86
|
+
for title in titles[3:]:
|
|
87
|
+
val = get_dec(row, titles, title)
|
|
88
|
+
if val is not None:
|
|
89
|
+
parts = title.split()
|
|
90
|
+
if len(parts) != 3:
|
|
91
|
+
continue
|
|
92
|
+
element_code, typ, units = parts
|
|
93
|
+
element_name = ELEMENT_NAME_LOOKUP[element_code]
|
|
94
|
+
try:
|
|
95
|
+
element = elements[element_name]
|
|
96
|
+
except KeyError:
|
|
97
|
+
element = elements[element_name] = {
|
|
98
|
+
"name": element_name,
|
|
99
|
+
"breakdown": {},
|
|
100
|
+
"net": Decimal("0.00"),
|
|
101
|
+
"start_date": start_date,
|
|
102
|
+
"finish_date": finish_date,
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
bd = element["breakdown"]
|
|
106
|
+
if typ == "COST":
|
|
107
|
+
element["net"] += round(val, 2)
|
|
108
|
+
net_gbp += round(val, 2)
|
|
109
|
+
elif typ == "USE":
|
|
110
|
+
bd[units.lower()] = val
|
|
111
|
+
if element_name == "aahedc":
|
|
112
|
+
kwh += val
|
|
113
|
+
elif typ == "RATE":
|
|
114
|
+
bd["rate"] = val
|
|
115
|
+
|
|
116
|
+
bd = {"raw_lines": [str(title_row), str(row)]}
|
|
117
|
+
|
|
118
|
+
reference = f"{issue_date.strftime('%Y%m%dT%H%M')}_{row_index + 1}"
|
|
136
119
|
|
|
137
120
|
return {
|
|
138
121
|
"bill_type_code": "N",
|
|
@@ -141,13 +124,14 @@ def _parse_row(row, row_index, datemode, title_row):
|
|
|
141
124
|
"net": net_gbp,
|
|
142
125
|
"gross": net_gbp + vat_gbp,
|
|
143
126
|
"reads": [],
|
|
144
|
-
"breakdown":
|
|
127
|
+
"breakdown": {},
|
|
145
128
|
"account": "2007",
|
|
146
129
|
"issue_date": issue_date,
|
|
147
|
-
"start_date":
|
|
148
|
-
"finish_date":
|
|
130
|
+
"start_date": start_date,
|
|
131
|
+
"finish_date": finish_date,
|
|
149
132
|
"mpan_core": "22 0003 0354 632",
|
|
150
133
|
"reference": reference,
|
|
134
|
+
"elements": list(elements.values()),
|
|
151
135
|
}
|
|
152
136
|
|
|
153
137
|
|
|
@@ -176,11 +160,14 @@ class Parser:
|
|
|
176
160
|
def make_raw_bills(self):
|
|
177
161
|
bills = []
|
|
178
162
|
title_row = self.sheet.row(0)
|
|
163
|
+
issue_date = utc_datetime_now()
|
|
179
164
|
for row_index in range(1, self.sheet.nrows):
|
|
180
165
|
row = self.sheet.row(row_index)
|
|
181
166
|
datemode = self.book.datemode
|
|
182
167
|
try:
|
|
183
|
-
bills.append(
|
|
168
|
+
bills.append(
|
|
169
|
+
_parse_row(issue_date, row, row_index, datemode, title_row)
|
|
170
|
+
)
|
|
184
171
|
except BadRequest as e:
|
|
185
|
-
raise BadRequest("On row
|
|
172
|
+
raise BadRequest(f"On row {row_index}: {e.description}")
|
|
186
173
|
return bills
|
chellow/e/computer.py
CHANGED
|
@@ -967,7 +967,7 @@ class SupplySource(DataSource):
|
|
|
967
967
|
|
|
968
968
|
self.is_displaced = False
|
|
969
969
|
self.bill = bill
|
|
970
|
-
if self.bill is not None:
|
|
970
|
+
if self.bill is not None and hasattr(self.bill, "start_date"):
|
|
971
971
|
self.bill_start = bill.start_date
|
|
972
972
|
self.bill_finish = bill.finish_date
|
|
973
973
|
self.is_last_bill_gen = (
|