chellow 1726737247.0.0__py3-none-any.whl → 1726820485.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/gas/views.py CHANGED
@@ -50,7 +50,6 @@ from chellow.models import (
50
50
  from chellow.utils import (
51
51
  HH,
52
52
  csv_make_val,
53
- hh_format,
54
53
  req_bool,
55
54
  req_date,
56
55
  req_decimal,
@@ -1457,47 +1456,88 @@ def exit_zone_get(g_exit_zone_id):
1457
1456
  @gas.route("/batches/<int:g_batch_id>/csv")
1458
1457
  def batch_csv_get(g_batch_id):
1459
1458
  g_batch = GBatch.get_by_id(g.sess, g_batch_id)
1460
- si = StringIO()
1461
- cw = csv.writer(si)
1462
- cw.writerow(
1463
- [
1464
- "Contract",
1465
- "Batch Reference",
1466
- "Bill Reference",
1467
- "Account",
1468
- "Issued",
1469
- "From",
1470
- "To",
1471
- "kWh",
1472
- "Net",
1473
- "VAT",
1474
- "Gross",
1475
- "Type",
1476
- ]
1477
- )
1478
- for g_bill in (
1479
- g.sess.query(GBill)
1480
- .filter(GBill.g_batch == g_batch)
1459
+ rows = []
1460
+ max_reads = 0
1461
+ for g_bill in g.sess.scalars(
1462
+ select(GBill)
1463
+ .where(GBill.g_batch == g_batch)
1481
1464
  .order_by(GBill.reference, GBill.start_date)
1482
- .options(joinedload(GBill.bill_type))
1483
- ):
1484
- cw.writerow(
1485
- [
1486
- g_batch.g_contract.name,
1487
- g_batch.reference,
1488
- g_bill.reference,
1489
- g_bill.account,
1490
- hh_format(g_bill.issue_date),
1491
- hh_format(g_bill.start_date),
1492
- hh_format(g_bill.finish_date),
1493
- str(g_bill.kwh),
1494
- str(g_bill.net),
1495
- str(g_bill.vat),
1496
- str(g_bill.gross),
1497
- g_bill.bill_type.code,
1498
- ]
1465
+ .options(
1466
+ joinedload(GBill.bill_type),
1467
+ joinedload(GBill.g_reads).joinedload(GRegisterRead.g_unit),
1468
+ joinedload(GBill.g_reads).joinedload(GRegisterRead.pres_type),
1469
+ joinedload(GBill.g_reads).joinedload(GRegisterRead.prev_type),
1499
1470
  )
1471
+ ).unique():
1472
+ row = [
1473
+ g_batch.g_contract.name,
1474
+ g_batch.reference,
1475
+ g_bill.reference,
1476
+ g_bill.account,
1477
+ g_bill.issue_date,
1478
+ g_bill.start_date,
1479
+ g_bill.finish_date,
1480
+ g_bill.kwh,
1481
+ g_bill.net,
1482
+ g_bill.vat,
1483
+ g_bill.gross,
1484
+ g_bill.bill_type.code,
1485
+ g_bill.breakdown,
1486
+ ]
1487
+ g_reads = g_bill.g_reads
1488
+ max_reads = max(max_reads, len(g_reads))
1489
+ for g_read in g_reads:
1490
+ row.extend(
1491
+ [
1492
+ g_read.msn,
1493
+ g_read.g_unit.code,
1494
+ g_read.correction_factor,
1495
+ g_read.calorific_value,
1496
+ g_read.prev_date,
1497
+ g_read.prev_value,
1498
+ g_read.prev_type.code,
1499
+ g_read.pres_date,
1500
+ g_read.pres_value,
1501
+ g_read.pres_type.code,
1502
+ ]
1503
+ )
1504
+ rows.append(row)
1500
1505
 
1506
+ si = StringIO()
1507
+ cw = csv.writer(si)
1508
+ read_titles = [
1509
+ "msn",
1510
+ "unit",
1511
+ "correction_factor",
1512
+ "calorific_value",
1513
+ "prev_date",
1514
+ "prev_value",
1515
+ "prev_type",
1516
+ "pres_date",
1517
+ "pres_value",
1518
+ "pres_type",
1519
+ ]
1520
+ titles = [
1521
+ "Contract",
1522
+ "Batch Reference",
1523
+ "Bill Reference",
1524
+ "Account",
1525
+ "Issued",
1526
+ "From",
1527
+ "To",
1528
+ "kWh",
1529
+ "Net",
1530
+ "VAT",
1531
+ "Gross",
1532
+ "Type",
1533
+ "breakdown",
1534
+ ]
1535
+ for i in range(max_reads):
1536
+ for rt in read_titles:
1537
+ titles.append(f"{i}_{rt}")
1538
+ cw.writerow(titles)
1539
+ for row in rows:
1540
+ cw.writerow(csv_make_val(v) for v in row)
1501
1541
  disp = f'attachment; filename="g_batch_{g_batch.id}.csv"'
1502
1542
  output = make_response(si.getvalue())
1503
1543
  output.headers["Content-Disposition"] = disp
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chellow
3
- Version: 1726737247.0.0
3
+ Version: 1726820485.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/gas/cv.py,sha256=4cdYYQ8Qak6NeYdBCB4YaQ0jX8-UkaydIIdibCQuXxM,7344
67
67
  chellow/gas/dn_rate_parser.py,sha256=Mq8rAcUEUxIQOks59bsCKl8GrefvoHbrTCHqon9N0z0,11340
68
68
  chellow/gas/engine.py,sha256=jT7m6vddi5GnWd51wCYEVhBS-LZEn1T9ggZX7Y9HGK0,25263
69
69
  chellow/gas/transportation.py,sha256=Bkg8TWOs-v0ES-4qqwbleiOhqbE_t2KauUx9JYMZELM,5300
70
- chellow/gas/views.py,sha256=zOlJnL6eVq7Tag-0NMabzCPQk5AoTrclEz-923pbwAE,57851
70
+ chellow/gas/views.py,sha256=vwGz4Go2qcebH9Pm2_H0UtJbrtpUIMvxgn5JYc2Zn3g,59027
71
71
  chellow/reports/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
72
  chellow/reports/report_109.py,sha256=FmRWG8wQC97cj0nqQH7mrfbYesRIKWXQLh6ERHvtHrU,11212
73
73
  chellow/reports/report_111.py,sha256=rgwoOPfvbfwIC_IjBqs2e8umF_YTtpyejLrX_uCgyHE,28145
@@ -366,6 +366,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
366
366
  chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
367
367
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
368
368
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
369
- chellow-1726737247.0.0.dist-info/METADATA,sha256=wBmQto7B3ObM92iQVscFqANnSgOFH9lwv0AAP5mCCu0,12204
370
- chellow-1726737247.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
371
- chellow-1726737247.0.0.dist-info/RECORD,,
369
+ chellow-1726820485.0.0.dist-info/METADATA,sha256=j0nAcz-8hnKflBNKt3m-dhLdmRz6JKAGhoXo6yFiye8,12204
370
+ chellow-1726820485.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
371
+ chellow-1726820485.0.0.dist-info/RECORD,,