show platform editor b4 main win, improve comments

This commit is contained in:
Roland W-H 2025-01-30 15:37:28 +00:00
parent 83c02ec4db
commit 6b4f6bb35f
5 changed files with 83 additions and 67 deletions

View File

@ -41,63 +41,24 @@
<property name="verticalSpacing">
<number>10</number>
</property>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="share_plat_fee_lab">
<property name="text">
<string>Share platform fee</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLineEdit" name="share_deal_fee_box"/>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="share_plat_max_fee_box"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="fund_deal_fee_lab">
<property name="text">
<string>Fund dealing fee</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="fund_deal_fee_box"/>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="share_plat_fee_box"/>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="share_plat_max_fee_lab">
<property name="text">
<string>Share platform fee cap</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLineEdit" name="share_deal_reduce_amount_box"/>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="share_deal_fee_lab">
<property name="text">
<string>Share dealing fee</string>
<string>Share platform fee cap (£/mth)</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="share_deal_reduce_amount_lab">
<property name="text">
<string>Share dealing fee discount</string>
<string>Share dealing fee discount (£)</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLineEdit" name="share_deal_reduce_trades_box"/>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="share_deal_reduce_trades_lab">
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="share_deal_fee_lab">
<property name="text">
<string>Share dealing discount # of trades</string>
<string>Share dealing fee (£)</string>
</property>
</widget>
</item>
@ -108,9 +69,48 @@
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLineEdit" name="share_deal_fee_box"/>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="fund_deal_fee_box"/>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="share_plat_fee_box"/>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="plat_name_box"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="share_plat_fee_lab">
<property name="text">
<string>Share platform fee (%)</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLineEdit" name="share_plat_max_fee_box"/>
</item>
<item row="7" column="2">
<widget class="QLineEdit" name="share_deal_reduce_trades_box"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="fund_deal_fee_lab">
<property name="text">
<string>Fund dealing fee (£)</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLineEdit" name="share_deal_reduce_amount_box"/>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="share_deal_reduce_trades_lab">
<property name="text">
<string>Share dealing discount # of trades</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="save_but">

View File

@ -2,11 +2,11 @@ from PyQt6.QtWidgets import QApplication
import sys
import main_window
import platform_edit
app = QApplication(sys.argv)
window = main_window.SIPPCompare()
# Show platform edit window first, before main win
window = platform_edit.PlatformEdit()
window.show()
window.show_platform_edit()
app.exec()

View File

@ -1,16 +1,16 @@
from PyQt6.QtWidgets import QMainWindow
from PyQt6 import uic
import platform_edit
import output_window
class SIPPCompare(QMainWindow):
def __init__(self):
# Receive instance of PlatformEdit() as parameter
def __init__(self, plat_edit_win):
super().__init__()
uic.loadUi("gui/main_gui.ui", self)
# Define class variables
# Initialise class variables
self.fund_plat_fee = 0.0
self.plat_name = ""
self.fund_deal_fee = 0.0
@ -25,7 +25,8 @@ class SIPPCompare(QMainWindow):
self.share_plat_fees = 0.0
self.share_deal_fees = 0.0
self.platform_win = None
# Create window objects
self.platform_win = plat_edit_win
self.output_win = output_window.OutputWindow()
# Handle events
@ -39,6 +40,7 @@ class SIPPCompare(QMainWindow):
mix_lab_str = f"Investment mix (funds {slider_val}% / shares {100 - slider_val}%)"
self.mix_lab.setText(mix_lab_str)
# Get local variables from user input
def init_variables(self):
self.plat_name = self.platform_win.get_plat_name()
self.fund_plat_fee = self.platform_win.get_fund_plat_fee()
@ -53,7 +55,7 @@ class SIPPCompare(QMainWindow):
def calculate_fees(self):
self.init_variables()
self.fund_plat_fees = 0
value_num = float(self.value_input.text()[1:])
value_num = float(self.value_input.text()[1:]) # Filter out '£' symbol
slider_val = self.mix_slider.value()
funds_value = (slider_val / 100) * value_num
fund_trades_num = int(self.fund_trades_combo.currentText())
@ -94,9 +96,6 @@ class SIPPCompare(QMainWindow):
self.share_plat_fees, self.share_deal_fees, self.plat_name)
self.output_win.show()
# Show the platform editor window (currently useless)
# Show the platform editor window (currently run-time only)
def show_platform_edit(self):
# Check window isn't already open
if self.platform_win is None:
self.platform_win = platform_edit.PlatformEdit()
self.platform_win.show()

View File

@ -4,19 +4,21 @@ from PyQt6 import uic
import datetime
import os
import platform_edit
class OutputWindow(QWidget):
def __init__(self):
super().__init__()
uic.loadUi("gui/output_window.ui", self)
self.res_save_but.clicked.connect(self.save_results)
# Initialise class variables
self.results_str = ""
self.platform_name = ""
# Handle events
self.res_save_but.clicked.connect(self.save_results)
def save_results(self):
# Use datatime for txt filename
cur_time = datetime.datetime.now()
if not os.path.exists("output"):
os.makedirs("output")
@ -24,13 +26,14 @@ class OutputWindow(QWidget):
output_file = open(filename_str, "wt")
output_file.write(self.results_str)
# Display fees in output window as plaintext readout
def display_output(self, fund_plat_fees: float, fund_deal_fees: float,
share_plat_fees: float, share_deal_fees: float, plat_name: str):
self.platform_name = plat_name
self.results_str = f"Fees breakdown (Platform \"{self.platform_name}\"):"
self.results_str += "\n\nPlatform fees:"
# :.2f is used in order to display 2 decimal places (currency form)
self.results_str += f"\n\tFund platform fees: £{round(fund_plat_fees, 2):.2f}"
self.results_str += f"\n\tShare platform fees: £{round(share_plat_fees, 2):.2f}"
total_plat_fees = fund_plat_fees + share_plat_fees

View File

@ -1,12 +1,16 @@
from PyQt6.QtWidgets import QWidget
from PyQt6 import uic
import main_window
class PlatformEdit(QWidget):
def __init__(self):
super().__init__()
uic.loadUi("gui/platform_edit.ui", self)
# Initialise class variables
# TODO: Make fund_plat_fee user-defined
self.fund_plat_fee = [
[0, 250000, 1000000, 2000000],
[0, 0.25, 0.1, 0.05]
@ -19,17 +23,27 @@ class PlatformEdit(QWidget):
self.share_deal_reduce_trades = 0.0
self.share_deal_reduce_amount = 0.0
# Create main window object, passing this instance as param
self.main_win = main_window.SIPPCompare(self)
# Handle events
# NOTE: Signal defined in Qt designer to close window when clicked
self.save_but.clicked.connect(self.init_variables)
# Get fee structure variables from user input
def init_variables(self):
self.plat_name = self.plat_name_box.text()
self.fund_deal_fee = float(self.fund_deal_fee_box.text())
self.share_plat_fee = float(self.share_plat_fee_box.text()) / 100
self.share_plat_max_fee = float(self.share_plat_max_fee_box.text())
self.share_deal_fee = float(self.share_deal_fee_box.text())
self.share_deal_reduce_trades = float(self.share_deal_reduce_trades_box.text())
self.share_deal_reduce_amount = float(self.share_deal_reduce_amount_box.text())
self.plat_name = self.plat_name_box.text()
self.fund_deal_fee = float(self.fund_deal_fee_box.text())
self.share_plat_fee = float(self.share_plat_fee_box.text()) / 100
self.share_plat_max_fee = float(self.share_plat_max_fee_box.text())
self.share_deal_fee = float(self.share_deal_fee_box.text())
self.share_deal_reduce_trades = float(self.share_deal_reduce_trades_box.text())
self.share_deal_reduce_amount = float(self.share_deal_reduce_amount_box.text())
# Once user input is received show main window
self.main_win.show()
# Getter functions
def get_plat_name(self):
return self.plat_name