chellow 1755614564.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.

Files changed (75) hide show
  1. chellow/e/bill_importer.py +136 -80
  2. chellow/e/bill_parsers/activity_mop_stark_xlsx.py +99 -86
  3. chellow/e/bill_parsers/annual_mop_stark_xlsx.py +78 -61
  4. chellow/e/bill_parsers/csv.py +139 -101
  5. chellow/e/bill_parsers/drax_edi.py +65 -88
  6. chellow/e/bill_parsers/engie_edi.py +187 -255
  7. chellow/e/bill_parsers/engie_xls.py +153 -167
  8. chellow/e/bill_parsers/haven_edi.py +189 -228
  9. chellow/e/bill_parsers/haven_edi_tprs.py +67 -67
  10. chellow/e/bill_parsers/nonsettlement_dc_stark_xlsx.py +75 -66
  11. chellow/e/bill_parsers/settlement_dc_stark_xlsx.py +229 -126
  12. chellow/e/bill_parsers/sse_edi.py +107 -75
  13. chellow/e/bill_parsers/sww_xls.py +78 -91
  14. chellow/e/computer.py +1 -1
  15. chellow/e/views.py +626 -281
  16. chellow/edi_lib.py +4 -27
  17. chellow/models.py +92 -3
  18. chellow/reports/report_111.py +478 -616
  19. chellow/reports/report_247.py +96 -137
  20. chellow/templates/e/dc_batch.html +110 -157
  21. chellow/templates/e/dc_batch_add.html +2 -3
  22. chellow/templates/e/dc_batch_edit.html +42 -46
  23. chellow/templates/e/dc_batch_file.html +2 -3
  24. chellow/templates/e/dc_batch_file_edit.html +28 -40
  25. chellow/templates/e/dc_batch_upload_file.html +68 -0
  26. chellow/templates/e/dc_batches.html +2 -1
  27. chellow/templates/e/dc_batches_edit.html +26 -0
  28. chellow/templates/e/dc_bill.html +27 -5
  29. chellow/templates/e/dc_bill_add.html +4 -4
  30. chellow/templates/e/dc_bill_edit.html +43 -63
  31. chellow/templates/e/dc_bill_import.html +1 -1
  32. chellow/templates/e/dc_bill_import_contract.html +130 -0
  33. chellow/templates/e/dc_contract.html +1 -1
  34. chellow/templates/e/dc_element.html +41 -0
  35. chellow/templates/e/dc_element_add.html +36 -0
  36. chellow/templates/e/dc_element_edit.html +49 -0
  37. chellow/templates/e/dc_rate_script_edit.html +27 -43
  38. chellow/templates/e/mop_batch.html +105 -152
  39. chellow/templates/e/mop_batch_add.html +2 -3
  40. chellow/templates/e/mop_batch_edit.html +43 -51
  41. chellow/templates/e/mop_batch_upload_file.html +71 -5
  42. chellow/templates/e/mop_batches.html +2 -1
  43. chellow/templates/e/mop_batches_edit.html +26 -0
  44. chellow/templates/e/mop_bill.html +31 -8
  45. chellow/templates/e/mop_bill_add.html +7 -27
  46. chellow/templates/e/mop_bill_import.html +1 -1
  47. chellow/templates/e/mop_bill_import_contract.html +130 -0
  48. chellow/templates/e/mop_contract.html +4 -5
  49. chellow/templates/e/mop_element.html +41 -0
  50. chellow/templates/e/mop_element_add.html +36 -0
  51. chellow/templates/e/mop_element_edit.html +49 -0
  52. chellow/templates/e/supplier_batch.html +3 -7
  53. chellow/templates/e/supplier_batch_add.html +2 -2
  54. chellow/templates/e/supplier_batch_edit.html +1 -1
  55. chellow/templates/e/supplier_batch_file.html +3 -5
  56. chellow/templates/e/supplier_batch_file_add.html +18 -11
  57. chellow/templates/e/supplier_batch_upload_file.html +83 -9
  58. chellow/templates/e/supplier_batches.html +4 -4
  59. chellow/templates/e/supplier_batches_edit.html +26 -0
  60. chellow/templates/e/supplier_bill.html +29 -6
  61. chellow/templates/e/supplier_bill_add.html +3 -3
  62. chellow/templates/e/supplier_bill_import.html +1 -1
  63. chellow/templates/e/supplier_bill_import_contract.html +118 -0
  64. chellow/templates/e/supplier_contract.html +1 -1
  65. chellow/templates/e/supplier_element.html +45 -0
  66. chellow/templates/e/supplier_element_add.html +36 -0
  67. chellow/templates/e/supplier_element_edit.html +51 -0
  68. chellow/templates/report_run_bill_check.html +137 -179
  69. chellow/templates/report_run_row_bill_check.html +182 -179
  70. chellow/views.py +55 -65
  71. {chellow-1755614564.0.0.dist-info → chellow-1759155233.0.0.dist-info}/METADATA +2 -2
  72. {chellow-1755614564.0.0.dist-info → chellow-1759155233.0.0.dist-info}/RECORD +73 -60
  73. chellow/e/bill_parsers/drax_element_edi.py +0 -459
  74. chellow/templates/e/supplier_bill_imports.html +0 -421
  75. {chellow-1755614564.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, utc_datetime, utc_datetime_now
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 utc_datetime(nums[0], nums[1], nums[2])
50
-
51
-
52
- def _parse_row(row, row_index, datemode, title_row):
53
- titles = [c.value for c in title_row]
54
- bill_start_date = get_date_ct(row, titles, "BILL START DATE")
55
- bill_finish_date = get_date_ct(row, titles, "BILL END DATE") + (HH * 47)
56
- issue_date = utc_datetime_now()
57
-
58
- aahedc_kwh = get_dec(row, titles, "LVY-AAHEDC-ALL USE KWH")
59
-
60
- vals = [
61
- ("capmechob-kwh", get_dec(row, titles, "LVY-CMLOB-ALL USE KWH")),
62
- ("capmechob-rate", get_dec(row, titles, "LVY-CMLOB-ALL RATE P/KWH")),
63
- ("capmechob-gbp", get_dec(row, titles, "LVY-CMLOB-ALL COST GBP")),
64
- ("capmechop-kwh", get_dec(row, titles, "LVY-CMLOP-ALL USE KWH")),
65
- ("capmechop-rate", get_dec(row, titles, "LVY-CMLOP-ALL RATE P/KWH")),
66
- ("capmechop-gbp", get_dec(row, titles, "LVY-CMLOP-ALL COST GBP")),
67
- ("duos-fixed-days", get_dec(row, titles, "DUOS-STND-SITE USE DAY")),
68
- (
69
- "duos-availability-kva-days",
70
- [get_dec(row, titles, "DUOS-AVAIL-AV USE KVADAY")],
71
- ),
72
- (
73
- "duos-availability-rate",
74
- get_rate(row, titles, "DUOS-AVAIL-AV RATE P/KVADAY"),
75
- ),
76
- ("duos-availability-gbp", get_dec(row, titles, "DUOS-AVAIL-AV COST GBP")),
77
- ("duos-fixed-rate", get_rate(row, titles, "DUOS-STND-SITE RATE P/DAY")),
78
- ("duos-fixed-gbp", get_dec(row, titles, "DUOS-STND-SITE COST GBP")),
79
- ("duos-amber-kwh", get_dec(row, titles, "DUOS-UNIT-AMBER USE KWH")),
80
- ("duos-amber-rate", get_rate(row, titles, "DUOS-UNIT-AMBER RATE P/KWH")),
81
- ("duos-amber-gbp", get_dec(row, titles, "DUOS-UNIT-AMBER COST GBP")),
82
- ("duos-green-kwh", get_dec(row, titles, "DUOS-UNIT-GREEN USE KWH")),
83
- ("duos-green-rate", get_rate(row, titles, "DUOS-UNIT-GREEN RATE P/KWH")),
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
- reference = issue_date.strftime("%Y%m%dT%H%M") + "_" + str(row_index + 1)
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": bd,
127
+ "breakdown": {},
145
128
  "account": "2007",
146
129
  "issue_date": issue_date,
147
- "start_date": bill_start_date,
148
- "finish_date": bill_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(_parse_row(row, row_index, datemode, title_row))
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 " + str(row_index) + ": " + str(e.description))
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 = (