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
chellow/edi_lib.py CHANGED
@@ -6,33 +6,6 @@ from werkzeug.exceptions import BadRequest
6
6
  from chellow.utils import ct_datetime, to_ct, to_utc
7
7
 
8
8
 
9
- def line_iter(f):
10
- line = []
11
- while c := f.read(1) != "":
12
- if c == "'":
13
- yield "".join(line)
14
- line.clear()
15
- else:
16
- line.append(c)
17
-
18
-
19
- class EdiParser:
20
- def __init__(self, f):
21
-
22
- self.line_iterator = line_iter(f)
23
- self.line_number = 0
24
-
25
- def __iter__(self):
26
- return self
27
-
28
- def __next__(self):
29
- self.line = next(self.line_iterator).strip()
30
- self.line_number += 1
31
-
32
- self.elements = [element.split(":") for element in self.line[4].split("+")]
33
- return self.line[:3]
34
-
35
-
36
9
  def parse_edi(edi_str):
37
10
  for line_number, raw_line in enumerate(edi_str.split("'"), start=1):
38
11
  line = raw_line.strip()
@@ -68,6 +41,10 @@ def to_decimal(components):
68
41
  return result
69
42
 
70
43
 
44
+ def to_gbp(components):
45
+ return Decimal("0.00") + round(to_decimal(components) / Decimal("100"), 2)
46
+
47
+
71
48
  def to_ct_date(component):
72
49
  if len(component) == 0:
73
50
  return None
chellow/models.py CHANGED
@@ -705,6 +705,72 @@ class BatchFile(Base, PersistentClass):
705
705
  sess.flush()
706
706
 
707
707
 
708
+ class Element(Base, PersistentClass):
709
+ __tablename__ = "element"
710
+ id = Column(Integer, primary_key=True)
711
+ bill_id = Column(
712
+ Integer, ForeignKey("bill.id", ondelete="CASCADE"), nullable=False, index=True
713
+ )
714
+ name = Column(String, nullable=False, index=True)
715
+ start_date = Column(DateTime(timezone=True), nullable=False, index=True)
716
+ finish_date = Column(DateTime(timezone=True), nullable=False, index=True)
717
+ net = Column(Numeric, nullable=False)
718
+ breakdown = Column(String, nullable=False)
719
+
720
+ def __init__(
721
+ self,
722
+ bill,
723
+ name,
724
+ start_date,
725
+ finish_date,
726
+ net,
727
+ breakdown,
728
+ ):
729
+ self.bill = bill
730
+ self.update(name, start_date, finish_date, net, breakdown)
731
+
732
+ @property
733
+ def bd(self):
734
+ if not hasattr(self, "_bd"):
735
+ self._bd = loads(self.breakdown)
736
+ return self._bd
737
+
738
+ def update(
739
+ self,
740
+ name,
741
+ start_date,
742
+ finish_date,
743
+ net,
744
+ breakdown,
745
+ ):
746
+
747
+ self.name = name
748
+ if start_date > finish_date:
749
+ raise BadRequest(
750
+ f"The element start date {hh_format(start_date)} can't be after the "
751
+ f"finish date {hh_format(finish_date)}."
752
+ )
753
+
754
+ self.start_date = start_date
755
+ self.finish_date = finish_date
756
+
757
+ if net.as_tuple().exponent != -2:
758
+ raise BadRequest(
759
+ f"The 'net' field of an element must be written to at exactly two "
760
+ f"decimal places. It's actually {net}"
761
+ )
762
+ self.net = net
763
+
764
+ if isinstance(breakdown, Mapping):
765
+ self.breakdown = dumps(breakdown)
766
+ else:
767
+ raise BadRequest("The 'breakdown' parameter must be a mapping type.")
768
+
769
+ def delete(self, sess):
770
+ sess.delete(self)
771
+ sess.flush()
772
+
773
+
708
774
  class Bill(Base, PersistentClass):
709
775
  __tablename__ = "bill"
710
776
  id = Column(Integer, primary_key=True)
@@ -728,6 +794,12 @@ class Bill(Base, PersistentClass):
728
794
  cascade="all, delete-orphan",
729
795
  passive_deletes=True,
730
796
  )
797
+ elements = relationship(
798
+ "Element",
799
+ backref="bill",
800
+ cascade="all, delete-orphan",
801
+ passive_deletes=True,
802
+ )
731
803
 
732
804
  def __init__(
733
805
  self,
@@ -864,6 +936,20 @@ class Bill(Base, PersistentClass):
864
936
  raise
865
937
  return read
866
938
 
939
+ def insert_element(
940
+ self,
941
+ sess,
942
+ name,
943
+ start_date,
944
+ finish_date,
945
+ net,
946
+ breakdown,
947
+ ):
948
+ element = Element(self, name, start_date, finish_date, net, breakdown)
949
+ sess.add(element)
950
+ sess.flush()
951
+ return element
952
+
867
953
  def delete(self, sess):
868
954
  sess.delete(self)
869
955
  sess.flush()
@@ -6391,10 +6477,13 @@ class ReportRun(Base, PersistentClass):
6391
6477
  self.data = _jsonize(data)
6392
6478
  attributes.flag_modified(self, "data")
6393
6479
 
6394
- def insert_row(self, sess, tab, titles, values, properties):
6480
+ def insert_row(self, sess, tab, titles, values, properties, data=None):
6395
6481
  vals = {"titles": titles, "values": values, "properties": properties}
6482
+ if data is not None:
6483
+ vals["data"] = data
6396
6484
  row = ReportRunRow(self, tab, vals)
6397
6485
  sess.add(row)
6486
+ return row
6398
6487
 
6399
6488
  def delete(self, sess):
6400
6489
  sess.delete(self)
@@ -6430,10 +6519,10 @@ class ReportRun(Base, PersistentClass):
6430
6519
  wsess.commit()
6431
6520
 
6432
6521
  @staticmethod
6433
- def w_insert_row(report_run_id, tab, titles, values, properties):
6522
+ def w_insert_row(report_run_id, tab, titles, values, properties, data=None):
6434
6523
  with Session() as wsess:
6435
6524
  report_run = ReportRun.get_by_id(wsess, report_run_id)
6436
- report_run.insert_row(wsess, tab, titles, values, properties)
6525
+ report_run.insert_row(wsess, tab, titles, values, properties, data=data)
6437
6526
  wsess.commit()
6438
6527
 
6439
6528