chellow 1753175604.0.0__py3-none-any.whl → 1753180539.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.

@@ -5,12 +5,13 @@ from decimal import Decimal, InvalidOperation
5
5
  from enum import Enum, auto
6
6
  from io import BytesIO
7
7
 
8
+ from dateutil.relativedelta import relativedelta
8
9
 
9
10
  from openpyxl import load_workbook
10
11
 
11
12
  from werkzeug.exceptions import BadRequest
12
13
 
13
- from chellow.utils import c_months_u, to_ct, to_utc
14
+ from chellow.utils import to_ct, to_utc
14
15
 
15
16
 
16
17
  class Title(Enum):
@@ -151,13 +152,13 @@ def _parse_row(bills, sheet, row, title_row):
151
152
  column_map = make_column_map(title_row)
152
153
  mprn_raw = get_value(sheet, row, column_map[Title.MPRN])
153
154
  mprn = str(mprn_raw)
154
- reference = get_value(sheet, row, column_map[Title.BILL])
155
+ reference = str(get_value(sheet, row, column_map[Title.BILL]))
155
156
  account = get_value(sheet, row, column_map[Title.ACCOUNT])
156
157
  issue_date = get_date(sheet, row, column_map[Title.BILL_DATE])
157
- period_naive = get_date_naive(sheet, row, column_map[Title.BILLING_PERIOD])
158
- start_date, finish_date = list(
159
- c_months_u(start_year=period_naive.year, start_month=period_naive.month)
160
- )[0]
158
+ charge_period_from = get_date(sheet, row, column_map[Title.CHARGE_PERIOD_FROM])
159
+ charge_period_end_naive = get_date_naive(
160
+ sheet, row, column_map[Title.CHARGE_PERIOD_END]
161
+ )
161
162
 
162
163
  try:
163
164
  mprn_values = bills[mprn]
@@ -165,16 +166,18 @@ def _parse_row(bills, sheet, row, title_row):
165
166
  mprn_values = bills[mprn] = {}
166
167
 
167
168
  try:
168
- bill = mprn_values[period_naive]
169
+ bill = mprn_values[reference]
169
170
  except KeyError:
170
- bill = mprn_values[period_naive] = {
171
- "bill_type_code": "N",
171
+ bill = mprn_values[reference] = {
172
+ "bill_type_code": "W" if reference.startswith("CR") else "N",
172
173
  "mprn": mprn,
173
174
  "reference": reference,
174
175
  "account": account,
175
176
  "issue_date": issue_date,
176
- "start_date": start_date,
177
- "finish_date": finish_date,
177
+ "start_date": charge_period_from,
178
+ "finish_date": to_utc(
179
+ to_ct(charge_period_end_naive) + relativedelta(hours=23, minutes=30)
180
+ ),
178
181
  "kwh": Decimal("0"),
179
182
  "breakdown": defaultdict(int, {}),
180
183
  "net_gbp": Decimal("0.00"),
@@ -190,6 +193,8 @@ def _parse_row(bills, sheet, row, title_row):
190
193
  qunit = get_value(sheet, row, column_map[Title.QUNIT])
191
194
  charge = get_dec(sheet, row, column_map[Title.CHARGE]) / Decimal("100")
192
195
  total = get_dec(sheet, row, column_map[Title.TOTAL])
196
+ if bill["bill_type_code"] == "W":
197
+ quantity = quantity * -1
193
198
  if element_desc == "VAT":
194
199
  bill["net_gbp"] += quantity
195
200
  bill["vat_gbp"] += total
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chellow
3
- Version: 1753175604.0.0
3
+ Version: 1753180539.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)
@@ -67,7 +67,7 @@ chellow/e/bill_parsers/settlement_dc_stark_xlsx.py,sha256=osCpUYUdLcPtlo7ngXWGw0
67
67
  chellow/e/bill_parsers/sse_edi.py,sha256=L85DOfNkqexeEIEr8pCBn_2sHJI-zEaw6cogpE3YyYM,15204
68
68
  chellow/e/bill_parsers/sww_xls.py,sha256=QEjiuvwvr5FuWCfqqVw8LaA_vZyAKsvRAS5fw3xtFhM,7533
69
69
  chellow/gas/bill_import.py,sha256=w0lPgK_Drzh8rtnEBQe3qFuxrgzZ6qQSgpaGrrGznMU,6549
70
- chellow/gas/bill_parser_bgs_xlsx.py,sha256=ySYAa6fq990DW01bQMk8Ix_sziWfm_5d2Il7IrYz9Ys,7522
70
+ chellow/gas/bill_parser_bgs_xlsx.py,sha256=ZuLts8Y31gxtCQoXJq2CQRRMMpYbAWqsbfMB1S6fPqU,7757
71
71
  chellow/gas/bill_parser_csv.py,sha256=Ecdy-apFT-mWAxddAsM4k1s-9-FpIaOfjP0oFc0rdQg,5557
72
72
  chellow/gas/bill_parser_engie_edi.py,sha256=Ko0vZP-QdVQ1uuhS_5cdrii60_cM4b_LFJMoY0pZqnk,8950
73
73
  chellow/gas/bill_parser_total_edi.py,sha256=8HZH5Le24bVNFDc7vaKbauMaYR-n9P6u0ZG7gDdqbIA,11325
@@ -385,6 +385,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
385
385
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
386
386
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
387
387
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
388
- chellow-1753175604.0.0.dist-info/METADATA,sha256=jyoTCzAK7PWcHx5zECDlMdAjYry29dMAQXmL90z-3aE,12585
389
- chellow-1753175604.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
390
- chellow-1753175604.0.0.dist-info/RECORD,,
388
+ chellow-1753180539.0.0.dist-info/METADATA,sha256=R7snYgxFJSS1VK-dHXFKW_4rRtTgBe4v6gzOXFUMX6A,12585
389
+ chellow-1753180539.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
390
+ chellow-1753180539.0.0.dist-info/RECORD,,