chellow 1703674731.0.0__py3-none-any.whl → 1704201609.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/views.py CHANGED
@@ -1579,7 +1579,7 @@ def era_edit_form_get(era_id):
1579
1579
 
1580
1580
  RateScriptAliasStart = aliased(RateScript)
1581
1581
  RateScriptAliasFinish = aliased(RateScript)
1582
- mop_contracts = g.sess.scalars(
1582
+ mop_contracts_q = (
1583
1583
  select(Contract)
1584
1584
  .join(MarketRole)
1585
1585
  .join(
@@ -1593,11 +1593,22 @@ def era_edit_form_get(era_id):
1593
1593
  .where(
1594
1594
  MarketRole.code == "M",
1595
1595
  start_date >= RateScriptAliasStart.start_date,
1596
- RateScriptAliasFinish.finish_date == null(),
1597
1596
  )
1598
1597
  .order_by(Contract.name)
1599
1598
  )
1600
- dc_contracts = g.sess.scalars(
1599
+ if finish_date is None:
1600
+ mop_contracts_q = mop_contracts_q.where(
1601
+ RateScriptAliasFinish.finish_date == null()
1602
+ )
1603
+ else:
1604
+ mop_contracts_q = mop_contracts_q.where(
1605
+ or_(
1606
+ RateScriptAliasFinish.finish_date == null(),
1607
+ RateScriptAliasFinish.finish_date >= finish_date,
1608
+ )
1609
+ )
1610
+ mop_contracts = g.sess.scalars(mop_contracts_q)
1611
+ dc_contracts_q = (
1601
1612
  select(Contract)
1602
1613
  .join(MarketRole)
1603
1614
  .join(
@@ -1611,11 +1622,22 @@ def era_edit_form_get(era_id):
1611
1622
  .where(
1612
1623
  MarketRole.code.in_(("C", "D")),
1613
1624
  start_date >= RateScriptAliasStart.start_date,
1614
- RateScriptAliasFinish.finish_date == null(),
1615
1625
  )
1616
1626
  .order_by(Contract.name)
1617
1627
  )
1618
- supplier_contracts = g.sess.scalars(
1628
+ if finish_date is None:
1629
+ dc_contracts_q = dc_contracts_q.where(
1630
+ RateScriptAliasFinish.finish_date == null()
1631
+ )
1632
+ else:
1633
+ dc_contracts_q = dc_contracts_q.where(
1634
+ or_(
1635
+ RateScriptAliasFinish.finish_date == null(),
1636
+ RateScriptAliasFinish.finish_date >= finish_date,
1637
+ )
1638
+ )
1639
+ dc_contracts = g.sess.scalars(dc_contracts_q)
1640
+ supplier_contracts_q = (
1619
1641
  select(Contract)
1620
1642
  .join(MarketRole)
1621
1643
  .join(
@@ -1629,10 +1651,21 @@ def era_edit_form_get(era_id):
1629
1651
  .where(
1630
1652
  MarketRole.code == "X",
1631
1653
  start_date >= RateScriptAliasStart.start_date,
1632
- RateScriptAliasFinish.finish_date == null(),
1633
1654
  )
1634
1655
  .order_by(Contract.name)
1635
- ).all()
1656
+ )
1657
+ if finish_date is None:
1658
+ supplier_contracts_q = supplier_contracts_q.where(
1659
+ RateScriptAliasFinish.finish_date == null()
1660
+ )
1661
+ else:
1662
+ supplier_contracts_q = supplier_contracts_q.where(
1663
+ or_(
1664
+ RateScriptAliasFinish.finish_date == null(),
1665
+ RateScriptAliasFinish.finish_date >= finish_date,
1666
+ )
1667
+ )
1668
+ supplier_contracts = g.sess.scalars(supplier_contracts_q).all()
1636
1669
  pcs = g.sess.scalars(select(Pc).order_by(Pc.code))
1637
1670
  pc_id = req_int_none("pc_id")
1638
1671
  if pc_id is None:
@@ -1647,7 +1680,7 @@ def era_edit_form_get(era_id):
1647
1680
  if pc.code == "00":
1648
1681
  sscs = None
1649
1682
  else:
1650
- sscs = g.sess.scalars(
1683
+ sscs_q = (
1651
1684
  select(Ssc)
1652
1685
  .select_from(MtcSsc)
1653
1686
  .join(Ssc, MtcSsc.ssc_id == Ssc.id)
@@ -1658,11 +1691,20 @@ def era_edit_form_get(era_id):
1658
1691
  MtcParticipant.participant == participant,
1659
1692
  MtcLlfcSscPc.pc == pc,
1660
1693
  start_date >= MtcLlfcSscPc.valid_from,
1661
- MtcLlfcSscPc.valid_to == null(),
1662
1694
  )
1663
1695
  .distinct()
1664
1696
  .order_by(Ssc.code, Ssc.valid_from.desc())
1665
- ).all()
1697
+ )
1698
+ if finish_date is None:
1699
+ sscs_q = sscs_q.where(MtcLlfcSscPc.valid_to == null())
1700
+ else:
1701
+ sscs_q = sscs_q.where(
1702
+ or_(
1703
+ MtcLlfcSscPc.valid_to == null(),
1704
+ MtcLlfcSscPc.valid_to >= finish_date,
1705
+ )
1706
+ )
1707
+ sscs = g.sess.scalars(sscs_q).all()
1666
1708
  ssc_id = req_int_none("ssc_id")
1667
1709
  if ssc_id in {s.id for s in sscs}:
1668
1710
  ssc = Ssc.get_by_id(g.sess, ssc_id)
@@ -1684,25 +1726,36 @@ def era_edit_form_get(era_id):
1684
1726
  )
1685
1727
  ]
1686
1728
  else:
1687
- mtc_participants = [
1688
- mtc_participant
1689
- for mtc_participant, mtc in g.sess.execute(
1690
- select(MtcParticipant, Mtc)
1691
- .select_from(MtcLlfcSscPc)
1692
- .join(MtcLlfcSsc)
1693
- .join(MtcSsc)
1694
- .join(MtcParticipant)
1695
- .join(Mtc)
1696
- .where(
1697
- MtcParticipant.participant == participant,
1698
- MtcLlfcSscPc.pc == pc,
1699
- MtcSsc.ssc == ssc,
1700
- start_date >= MtcLlfcSscPc.valid_from,
1729
+ mtc_participants_q = (
1730
+ select(MtcParticipant, Mtc)
1731
+ .select_from(MtcLlfcSscPc)
1732
+ .join(MtcLlfcSsc)
1733
+ .join(MtcSsc)
1734
+ .join(MtcParticipant)
1735
+ .join(Mtc)
1736
+ .where(
1737
+ MtcParticipant.participant == participant,
1738
+ MtcLlfcSscPc.pc == pc,
1739
+ MtcSsc.ssc == ssc,
1740
+ start_date >= MtcLlfcSscPc.valid_from,
1741
+ )
1742
+ .distinct()
1743
+ .order_by(Mtc.code, MtcParticipant.valid_from.desc())
1744
+ )
1745
+ if finish_date is None:
1746
+ mtc_participants_q = mtc_participants_q.where(
1747
+ MtcLlfcSscPc.valid_to == null()
1748
+ )
1749
+ else:
1750
+ mtc_participants_q = mtc_participants_q.where(
1751
+ or_(
1701
1752
  MtcLlfcSscPc.valid_to == null(),
1753
+ MtcLlfcSscPc.valid_to >= finish_date,
1702
1754
  )
1703
- .distinct()
1704
- .order_by(Mtc.code, MtcParticipant.valid_from.desc())
1705
1755
  )
1756
+ mtc_participants = [
1757
+ mtc_participant
1758
+ for mtc_participant, mtc in g.sess.execute(mtc_participants_q)
1706
1759
  ]
1707
1760
 
1708
1761
  mtc_participant_id = req_int_none("mtc_participant_id")
@@ -1754,7 +1807,7 @@ def era_edit_form_get(era_id):
1754
1807
  exp_llfcs = g.sess.scalars(exp_llfcs_q)
1755
1808
  else:
1756
1809
  mtc_ssc = MtcSsc.find_by_values(g.sess, mtc_participant, ssc, start_date)
1757
- imp_llfcs = g.sess.scalars(
1810
+ imp_llfcs_q = (
1758
1811
  select(Llfc)
1759
1812
  .join(MtcLlfcSsc)
1760
1813
  .join(MtcLlfcSscPc)
@@ -1762,14 +1815,23 @@ def era_edit_form_get(era_id):
1762
1815
  MtcLlfcSsc.mtc_ssc == mtc_ssc,
1763
1816
  MtcLlfcSscPc.pc == pc,
1764
1817
  start_date >= MtcLlfcSscPc.valid_from,
1765
- MtcLlfcSscPc.valid_to == null(),
1766
1818
  Llfc.is_import == true(),
1767
1819
  )
1768
1820
  .distinct()
1769
1821
  .order_by(Llfc.code, Llfc.valid_from.desc())
1770
- ).all()
1822
+ )
1823
+ if finish_date is None:
1824
+ imp_llfcs_q = imp_llfcs_q.where(MtcLlfcSscPc.valid_to == null())
1825
+ else:
1826
+ imp_llfcs_q = imp_llfcs_q.where(
1827
+ or_(
1828
+ MtcLlfcSscPc.valid_to == null(),
1829
+ MtcLlfcSscPc.valid_to >= finish_date,
1830
+ )
1831
+ )
1832
+ imp_llfcs = g.sess.scalars(imp_llfcs_q).all()
1771
1833
 
1772
- exp_llfcs = g.sess.scalars(
1834
+ exp_llfcs_q = (
1773
1835
  select(Llfc)
1774
1836
  .join(MtcLlfcSsc)
1775
1837
  .join(MtcLlfcSscPc)
@@ -1777,12 +1839,21 @@ def era_edit_form_get(era_id):
1777
1839
  MtcLlfcSsc.mtc_ssc == mtc_ssc,
1778
1840
  MtcLlfcSscPc.pc == pc,
1779
1841
  start_date >= MtcLlfcSscPc.valid_from,
1780
- MtcLlfcSscPc.valid_to == null(),
1781
1842
  Llfc.is_import == false(),
1782
1843
  )
1783
1844
  .distinct()
1784
1845
  .order_by(Llfc.code, Llfc.valid_from.desc())
1785
- ).all()
1846
+ )
1847
+ if finish_date is None:
1848
+ exp_llfcs_q = exp_llfcs_q.where(MtcLlfcSscPc.valid_to == null())
1849
+ else:
1850
+ exp_llfcs_q = exp_llfcs_q.where(
1851
+ or_(
1852
+ MtcLlfcSscPc.valid_to == null(),
1853
+ MtcLlfcSscPc.valid_to >= finish_date,
1854
+ )
1855
+ )
1856
+ exp_llfcs = g.sess.scalars(exp_llfcs_q).all()
1786
1857
 
1787
1858
  return render_template(
1788
1859
  "era_edit_form.html",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chellow
3
- Version: 1703674731.0.0
3
+ Version: 1704201609.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)
@@ -34,7 +34,7 @@ chellow/e/scenario.py,sha256=1tUxnvwTzr6cKqiw2wphdv5XDzV6JO6UVYkyQa67vHs,23263
34
34
  chellow/e/system_price.py,sha256=F2GF_TNapfpbhoYjuGYAUCtD4JnccOUfd3w2ClG55qc,8032
35
35
  chellow/e/tlms.py,sha256=m6bUY1LNRlPoZ8va7Y3TlXAIktlTz36UVygFoDqwXIc,9586
36
36
  chellow/e/tnuos.py,sha256=Ry5Re7h5lOwzDgFRg4KhhFX1HMJ2vVWEwPJKYeESecs,20806
37
- chellow/e/views.py,sha256=pdqQtAjAsEK1Fk3Ongg8af5vlS25vEUauYCK2Dh99vA,209207
37
+ chellow/e/views.py,sha256=VuWVbHT5z7WttVMxLixynjbpjRxbviLElRD7DbGfKdQ,211828
38
38
  chellow/e/bill_parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  chellow/e/bill_parsers/activity_mop_stark_xlsx.py,sha256=UgWXDPzQkQghyj_lfgBqoSJpHB-t-qOdSaB8qY6GLog,4071
40
40
  chellow/e/bill_parsers/annual_mop_stark_xlsx.py,sha256=-HMoIfa_utXYKA44RuC0Xqv3vd2HLeQU_4P0iBUd3WA,4219
@@ -357,6 +357,6 @@ chellow/templates/g/supply_note_edit.html,sha256=6UQf_qbhFDys3cVsTp-c7ABWZpggW9R
357
357
  chellow/templates/g/supply_notes.html,sha256=WR3YwGh_qqTklSJ7JqWX6BKBc9rk_jMff4RiWZiF2CM,936
358
358
  chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
359
359
  chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
360
- chellow-1703674731.0.0.dist-info/METADATA,sha256=WyHhcv3GIXOXKs2dbec6KwvYjU8EBV4yjq5g0PT5HEY,12160
361
- chellow-1703674731.0.0.dist-info/WHEEL,sha256=mRYSEL3Ih6g5a_CVMIcwiF__0Ae4_gLYh01YFNwiq1k,87
362
- chellow-1703674731.0.0.dist-info/RECORD,,
360
+ chellow-1704201609.0.0.dist-info/METADATA,sha256=4Eh7v-CuaiCqg65UOPltcmbyeHecKSGtg-PazQj-BVQ,12160
361
+ chellow-1704201609.0.0.dist-info/WHEEL,sha256=mRYSEL3Ih6g5a_CVMIcwiF__0Ae4_gLYh01YFNwiq1k,87
362
+ chellow-1704201609.0.0.dist-info/RECORD,,