diff --git a/gui/platform_edit.ui b/gui/platform_edit.ui index cfa5bce..ba3416c 100644 --- a/gui/platform_edit.ui +++ b/gui/platform_edit.ui @@ -41,63 +41,24 @@ 10 - - - - Share platform fee - - - - - - - - - - - - - Fund dealing fee - - - - - - - - - - Share platform fee cap - - - - - - - - - - Share dealing fee + Share platform fee cap (£/mth) - Share dealing fee discount + Share dealing fee discount (£) - - - - - + + - Share dealing discount # of trades + Share dealing fee (£) @@ -108,9 +69,48 @@ + + + + + + + + + + + + + Share platform fee (%) + + + + + + + + + + + + + Fund dealing fee (£) + + + + + + + + + + Share dealing discount # of trades + + + diff --git a/src/main.py b/src/main.py index 8247e20..9aa47e9 100644 --- a/src/main.py +++ b/src/main.py @@ -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() diff --git a/src/main_window.py b/src/main_window.py index ed11b69..892cb1a 100644 --- a/src/main_window.py +++ b/src/main_window.py @@ -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() diff --git a/src/output_window.py b/src/output_window.py index 07f8f5e..0c7dbda 100644 --- a/src/output_window.py +++ b/src/output_window.py @@ -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 diff --git a/src/platform_edit.py b/src/platform_edit.py index 9e16c79..71c8664 100644 --- a/src/platform_edit.py +++ b/src/platform_edit.py @@ -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