From 32bc3add9bb671c5f6fa1ef067c4389a3da3022b Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Mon, 17 Mar 2025 15:16:02 +0000 Subject: [PATCH 01/10] make fund_plat_fee user defined (no validation) --- gui/platform_edit.ui | 125 +++++++++++++++++++++++++++++++++++-------- src/platform_edit.py | 79 ++++++++++++++++++++++++--- 2 files changed, 175 insertions(+), 29 deletions(-) diff --git a/gui/platform_edit.ui b/gui/platform_edit.ui index ddf9a0e..5e89f0b 100644 --- a/gui/platform_edit.ui +++ b/gui/platform_edit.ui @@ -6,32 +6,20 @@ 0 0 - 498 - 303 + 630 + 567 - - - 498 - 303 - - - - - 498 - 303 - - Platform Editor - 20 + 10 20 - 461 - 243 + 611 + 241 @@ -261,8 +249,8 @@ - 350 - 270 + 482 + 534 141 24 @@ -274,8 +262,8 @@ - 10 - 280 + 8 + 262 191 21 @@ -287,7 +275,7 @@ - 437 + 577 10 61 16 @@ -300,6 +288,93 @@ Qt::AlignmentFlag::AlignCenter + + + + 11 + 314 + 611 + 31 + + + + + 0 + + + + + QAbstractSpinBox::ButtonSymbols::NoButtons + + + QAbstractSpinBox::CorrectionMode::CorrectToNearestValue + + + % + + + 100.000000000000000 + + + + + + + on the first + + + + + + + the fee is + + + + + + + QAbstractSpinBox::ButtonSymbols::NoButtons + + + QAbstractSpinBox::CorrectionMode::CorrectToNearestValue + + + £ + + + 9999999.000000000000000 + + + + + + + + + 532 + 481 + 91 + 24 + + + + Add row + + + + + + 440 + 481 + 91 + 24 + + + + Remove row + + @@ -321,7 +396,6 @@ share_deal_fee_box share_deal_reduce_trades_box share_deal_reduce_amount_box - save_but plat_name_check fund_deal_fee_check share_plat_fee_check @@ -329,6 +403,11 @@ share_deal_fee_check share_deal_reduce_trades_check share_deal_reduce_amount_check + first_tier_box + first_tier_fee_box + del_row_but + new_row_but + save_but diff --git a/src/platform_edit.py b/src/platform_edit.py index 55f4e4a..1510695 100644 --- a/src/platform_edit.py +++ b/src/platform_edit.py @@ -1,8 +1,9 @@ from PyQt6.QtCore import QRegularExpression from PyQt6.QtGui import QRegularExpressionValidator -from PyQt6.QtWidgets import QWidget +from PyQt6.QtWidgets import QWidget, QLabel from PyQt6 import uic +from widgets.fastedit_spinbox import FastEditQDoubleSpinBox import main_window @@ -16,11 +17,7 @@ class PlatformEdit(QWidget): # Create main window object, passing this instance as param self.main_win = main_window.SIPPCompare(self) - # TODO: Make fund_plat_fee user-defined - self.fund_plat_fee = [ - [0, 250000, 1000000, 2000000], - [0, 0.25, 0.1, 0.05] - ] + self.fund_plat_fee = [] self.plat_name = "" self.fund_deal_fee = 0.0 self.share_plat_fee = 0.0 @@ -28,6 +25,9 @@ class PlatformEdit(QWidget): self.share_deal_fee = 0.0 self.share_deal_reduce_trades = 0.0 self.share_deal_reduce_amount = 0.0 + self.widgets_list_list = [] + + self.fund_fee_rows = 1 # Debugging feature: set with "--DEBUG_AUTOFILL" cmd argument self.autofill = autofill if autofill: @@ -76,6 +76,8 @@ class PlatformEdit(QWidget): # NOTE: Signal defined in UI file to close window when save button clicked self.save_but.clicked.connect(self.init_variables) + self.new_row_but.clicked.connect(self.add_row) + self.del_row_but.clicked.connect(self.remove_row) # Set validators # Regex accepts any characters that match [a-Z], [0-9] or _ @@ -83,6 +85,19 @@ class PlatformEdit(QWidget): QRegularExpressionValidator(QRegularExpression("\\w*")) ) + def create_plat_fee_struct(self): + plat_fee_struct = [[0], [0]] + plat_fee_struct[0].append(self.first_tier_box.value()) + plat_fee_struct[1].append(self.first_tier_fee_box.value()) + + for i in range(len(self.widgets_list_list)): + band = self.widgets_list_list[i][1].value() + fee = self.widgets_list_list[i][3].value() + plat_fee_struct[0].append(band) + plat_fee_struct[1].append(fee) + + return plat_fee_struct + # Get fee structure variables from user input when "Save" clicked def init_variables(self): # If debugging, save time by hardcoding @@ -96,6 +111,7 @@ class PlatformEdit(QWidget): self.share_deal_reduce_amount = 3.50 else: self.plat_name = self.plat_name_box.text() + self.fund_plat_fee = self.create_plat_fee_struct() self.fund_deal_fee = float(self.fund_deal_fee_box.value()) self.share_plat_fee = float(self.share_plat_fee_box.value()) / 100 self.share_plat_max_fee = float(self.share_plat_max_fee_box.value()) @@ -150,6 +166,57 @@ class PlatformEdit(QWidget): else: self.save_but.setEnabled(False) + def add_row(self): + if self.fund_fee_rows > 5: + return -1 + + widgets = [] + + widgets.append(QLabel(self.gridLayoutWidget_2)) + widgets[0].setText(f"between {int(self.first_tier_box.value())} and") + + widgets.append(FastEditQDoubleSpinBox(self.gridLayoutWidget_2)) + widgets[1].setPrefix("£") + widgets[1].setMaximum(9999999) + widgets[1].setButtonSymbols(FastEditQDoubleSpinBox.ButtonSymbols.NoButtons) + + widgets.append(QLabel(self.gridLayoutWidget_2)) + widgets[2].setText(f"the fee is") + + widgets.append(FastEditQDoubleSpinBox(self.gridLayoutWidget_2)) + widgets[3].setSuffix("%") + widgets[3].setMaximum(100) + widgets[3].setButtonSymbols(FastEditQDoubleSpinBox.ButtonSymbols.NoButtons) + + # TODO: why 28.5? + self.gridLayoutWidget_2.setGeometry(11, 314, 611, int(round(28.5 * (self.fund_fee_rows + 1), 0))) + for i in range(len(widgets)): + self.gridLayout_2.addWidget(widgets[i], self.fund_fee_rows, i, 1, 1) + + self.fund_fee_rows += 1 + + self.widgets_list_list.append(widgets) + cur_label_idx = self.gridLayout_2.indexOf(widgets[0]) + cur_box_idx = self.gridLayout_2.indexOf(widgets[1]) + cur_label_pos = list(self.gridLayout_2.getItemPosition(cur_label_idx))[:2] + cur_box_pos = list(self.gridLayout_2.getItemPosition(cur_box_idx))[:2] + + prev_box_row = cur_box_pos[0] - 1 + prev_box_item = self.gridLayout_2.itemAtPosition(prev_box_row, cur_box_pos[1]).widget() + cur_label_item = self.gridLayout_2.itemAtPosition(cur_label_pos[0], cur_label_pos[1]).widget() + cur_label_item.setText(f"between {int(prev_box_item.value())} and") + + def remove_row(self): + if not self.fund_fee_rows > 1: + return -1 + + for widget in self.widgets_list_list[self.fund_fee_rows - 2]: + self.gridLayout_2.removeWidget(widget) + widget.hide() + self.widgets_list_list.pop() + self.fund_fee_rows -= 1 + self.gridLayoutWidget_2.setGeometry(11, 314, 611, int(round(28.5 * self.fund_fee_rows, 0))) + # Getter functions (is this necessary? maybe directly reading class vars would be best...) def get_optional_boxes(self): return self.check_boxes_ticked From f395f155d05978d8cb1a9619dbcbb00643e5325b Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Mon, 17 Mar 2025 21:55:13 +0000 Subject: [PATCH 02/10] make fund deal fee checkbox optional --- gui/platform_edit.ui | 2 +- src/main_window.py | 13 +++++++++---- src/platform_edit.py | 4 +++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gui/platform_edit.ui b/gui/platform_edit.ui index 5e89f0b..e6d1f00 100644 --- a/gui/platform_edit.ui +++ b/gui/platform_edit.ui @@ -80,7 +80,7 @@ - false + true true diff --git a/src/main_window.py b/src/main_window.py index 24a5eea..fed54dd 100644 --- a/src/main_window.py +++ b/src/main_window.py @@ -66,7 +66,6 @@ class SIPPCompare(QMainWindow): def init_variables(self): self.optional_boxes = self.platform_win.get_optional_boxes() self.fund_plat_fee = self.platform_win.get_fund_plat_fee() - self.fund_deal_fee = self.platform_win.get_fund_deal_fee() self.share_plat_fee = self.platform_win.get_share_plat_fee() self.share_deal_fee = self.platform_win.get_share_deal_fee() @@ -77,16 +76,21 @@ class SIPPCompare(QMainWindow): self.plat_name = None if self.optional_boxes[1]: + self.fund_deal_fee = self.platform_win.get_fund_deal_fee() + else: + self.fund_deal_fee = None + + if self.optional_boxes[2]: self.share_plat_max_fee = self.platform_win.get_share_plat_max_fee() else: self.share_plat_max_fee = None - if self.optional_boxes[2]: + if self.optional_boxes[3]: self.share_deal_reduce_trades = self.platform_win.get_share_deal_reduce_trades() else: self.share_deal_reduce_trades = None - if self.optional_boxes[3]: + if self.optional_boxes[4]: self.share_deal_reduce_amount = self.platform_win.get_share_deal_reduce_amount() else: self.share_deal_reduce_amount = None @@ -101,7 +105,8 @@ class SIPPCompare(QMainWindow): slider_val: int = self.mix_slider.value() funds_value = (slider_val / 100) * value_num fund_trades_num = int(self.fund_trades_combo.currentText()) - self.fund_deal_fees = fund_trades_num * self.fund_deal_fee + if self.fund_deal_fee is not None: + self.fund_deal_fees = fund_trades_num * self.fund_deal_fee for i in range(1, len(self.fund_plat_fee[0])): band = self.fund_plat_fee[0][i] diff --git a/src/platform_edit.py b/src/platform_edit.py index 1510695..4f51d58 100644 --- a/src/platform_edit.py +++ b/src/platform_edit.py @@ -34,13 +34,13 @@ class PlatformEdit(QWidget): self.save_but.setEnabled(True) self.required_fields = [ - self.fund_deal_fee_box, self.share_plat_fee_box, self.share_deal_fee_box ] self.optional_fields = [ self.plat_name_box, + self.fund_deal_fee_box, self.share_plat_max_fee_box, self.share_deal_reduce_trades_box, self.share_deal_reduce_amount_box @@ -48,12 +48,14 @@ class PlatformEdit(QWidget): self.optional_check_boxes = [ self.plat_name_check, + self.fund_deal_fee_check, self.share_plat_max_fee_check, self.share_deal_reduce_trades_check, self.share_deal_reduce_amount_check ] self.check_boxes_ticked = [ + True, True, False, False, From d1cf30422cff68e5b7af6aef782f4e35d5699d0c Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Mon, 17 Mar 2025 21:56:39 +0000 Subject: [PATCH 03/10] correct indentation in fee calculation func --- src/main_window.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main_window.py b/src/main_window.py index fed54dd..cd9b0f0 100644 --- a/src/main_window.py +++ b/src/main_window.py @@ -125,15 +125,15 @@ class SIPPCompare(QMainWindow): if self.share_plat_max_fee is not None: if (self.share_plat_fee * shares_value / 12) > self.share_plat_max_fee: self.share_plat_fees = self.share_plat_max_fee * 12 - else: - self.share_plat_fees = self.share_plat_fee * shares_value + else: + self.share_plat_fees = self.share_plat_fee * shares_value share_trades_num = int(self.share_trades_combo.currentText()) if self.share_deal_reduce_trades is not None: if (share_trades_num / 12) >= self.share_deal_reduce_trades: self.share_deal_fees = self.share_deal_reduce_amount * share_trades_num - else: - self.share_deal_fees = self.share_deal_fee * share_trades_num + else: + self.share_deal_fees = self.share_deal_fee * share_trades_num self.show_output_win() From df7baa2df23edd1b94f231ea84627a80d9fd899b Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Mon, 17 Mar 2025 21:57:30 +0000 Subject: [PATCH 04/10] increase font size for better readability --- gui/platform_edit.ui | 108 ++++++++++++++++++++++++++++++++++++++++++- src/platform_edit.py | 13 ++++-- 2 files changed, 117 insertions(+), 4 deletions(-) diff --git a/gui/platform_edit.ui b/gui/platform_edit.ui index e6d1f00..ce389b7 100644 --- a/gui/platform_edit.ui +++ b/gui/platform_edit.ui @@ -63,6 +63,11 @@ false + + + 11 + + QAbstractSpinBox::ButtonSymbols::NoButtons @@ -89,6 +94,11 @@ + + + 11 + + QAbstractSpinBox::ButtonSymbols::NoButtons @@ -105,6 +115,11 @@ + + + 11 + + Share dealing discount # of trades @@ -115,6 +130,11 @@ + + + 11 + + Share platform monthly fee cap @@ -122,6 +142,11 @@ + + + 11 + + QAbstractSpinBox::ButtonSymbols::NoButtons @@ -138,6 +163,11 @@ + + + 11 + + Share dealing fee* @@ -148,6 +178,11 @@ false + + + 11 + + QAbstractSpinBox::ButtonSymbols::NoButtons @@ -174,6 +209,11 @@ + + + 11 + + Fund dealing fee* @@ -183,10 +223,21 @@ - + + + + 11 + + + + + + 11 + + Share dealing discount amount @@ -194,6 +245,11 @@ + + + 11 + + Share platform fee* @@ -201,6 +257,11 @@ + + + 11 + + QAbstractSpinBox::ButtonSymbols::NoButtons @@ -217,6 +278,11 @@ + + + 11 + + Platform name @@ -227,6 +293,11 @@ false + + + 11 + + QAbstractSpinBox::ButtonSymbols::NoButtons @@ -255,6 +326,11 @@ 24 + + + 10 + + Save @@ -303,6 +379,11 @@ + + + 11 + + QAbstractSpinBox::ButtonSymbols::NoButtons @@ -319,6 +400,11 @@ + + + 11 + + on the first @@ -326,6 +412,11 @@ + + + 11 + + the fee is @@ -333,6 +424,11 @@ + + + 11 + + QAbstractSpinBox::ButtonSymbols::NoButtons @@ -358,6 +454,11 @@ 24 + + + 10 + + Add row @@ -371,6 +472,11 @@ 24 + + + 10 + + Remove row diff --git a/src/platform_edit.py b/src/platform_edit.py index 4f51d58..02001df 100644 --- a/src/platform_edit.py +++ b/src/platform_edit.py @@ -1,5 +1,5 @@ from PyQt6.QtCore import QRegularExpression -from PyQt6.QtGui import QRegularExpressionValidator +from PyQt6.QtGui import QRegularExpressionValidator, QFont from PyQt6.QtWidgets import QWidget, QLabel from PyQt6 import uic @@ -173,22 +173,27 @@ class PlatformEdit(QWidget): return -1 widgets = [] + font = QFont() + font.setPointSize(11) widgets.append(QLabel(self.gridLayoutWidget_2)) - widgets[0].setText(f"between {int(self.first_tier_box.value())} and") + widgets[0].setFont(font) widgets.append(FastEditQDoubleSpinBox(self.gridLayoutWidget_2)) widgets[1].setPrefix("£") widgets[1].setMaximum(9999999) widgets[1].setButtonSymbols(FastEditQDoubleSpinBox.ButtonSymbols.NoButtons) + widgets[1].setFont(font) widgets.append(QLabel(self.gridLayoutWidget_2)) widgets[2].setText(f"the fee is") + widgets[2].setFont(font) widgets.append(FastEditQDoubleSpinBox(self.gridLayoutWidget_2)) widgets[3].setSuffix("%") widgets[3].setMaximum(100) widgets[3].setButtonSymbols(FastEditQDoubleSpinBox.ButtonSymbols.NoButtons) + widgets[3].setFont(font) # TODO: why 28.5? self.gridLayoutWidget_2.setGeometry(11, 314, 611, int(round(28.5 * (self.fund_fee_rows + 1), 0))) @@ -206,7 +211,9 @@ class PlatformEdit(QWidget): prev_box_row = cur_box_pos[0] - 1 prev_box_item = self.gridLayout_2.itemAtPosition(prev_box_row, cur_box_pos[1]).widget() cur_label_item = self.gridLayout_2.itemAtPosition(cur_label_pos[0], cur_label_pos[1]).widget() - cur_label_item.setText(f"between {int(prev_box_item.value())} and") + cur_label_item.setText(f"between £{int(prev_box_item.value())} and") + + # TODO: Tab order def remove_row(self): if not self.fund_fee_rows > 1: From ead59079b31ca48de7ab199710f9c8a6740a1498 Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Tue, 18 Mar 2025 10:44:41 +0000 Subject: [PATCH 05/10] make font sizes consistent --- gui/main_gui.ui | 62 +++++++++++++++++++++++++++++++++++++++++++- gui/output_window.ui | 15 +++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/gui/main_gui.ui b/gui/main_gui.ui index defbf8a..64a48cb 100644 --- a/gui/main_gui.ui +++ b/gui/main_gui.ui @@ -35,7 +35,7 @@ 10 0 401 - 171 + 176 @@ -53,6 +53,11 @@ + + + 11 + + Pension value @@ -60,6 +65,11 @@ + + + 11 + + true @@ -82,6 +92,11 @@ + + + 10 + + Investment mix (funds 50% / shares 50%) @@ -108,6 +123,11 @@ + + + 11 + + Annual share trades @@ -115,6 +135,11 @@ + + + 11 + + Annual fund trades @@ -122,6 +147,11 @@ + + + 11 + + true @@ -132,6 +162,11 @@ false + + + 10 + + Calculate @@ -139,6 +174,11 @@ + + + 11 + + true @@ -151,6 +191,11 @@ true + + + 10 + + @@ -161,7 +206,17 @@ 33 + + + 10 + + + + + 10 + + File @@ -173,6 +228,11 @@ Edit Platforms + + + 10 + + diff --git a/gui/output_window.ui b/gui/output_window.ui index c028924..baa549c 100644 --- a/gui/output_window.ui +++ b/gui/output_window.ui @@ -34,6 +34,11 @@ 250 + + + 11 + + @@ -44,6 +49,11 @@ 24 + + + 10 + + OK @@ -57,6 +67,11 @@ 24 + + + 10 + + Save From 93f69cc0da0ddf29858668a753cfeb36f1474b44 Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Tue, 18 Mar 2025 12:17:19 +0000 Subject: [PATCH 06/10] add input validation to fund_plat_fee tiers --- gui/platform_edit.ui | 7 ++++-- src/platform_edit.py | 54 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/gui/platform_edit.ui b/gui/platform_edit.ui index ce389b7..4194e82 100644 --- a/gui/platform_edit.ui +++ b/gui/platform_edit.ui @@ -445,7 +445,7 @@ - + 532 @@ -464,6 +464,9 @@ + + false + 440 @@ -512,7 +515,7 @@ first_tier_box first_tier_fee_box del_row_but - new_row_but + add_row_but save_but diff --git a/src/platform_edit.py b/src/platform_edit.py index 02001df..07c6c51 100644 --- a/src/platform_edit.py +++ b/src/platform_edit.py @@ -76,9 +76,12 @@ class PlatformEdit(QWidget): for check_box in self.optional_check_boxes: check_box.checkStateChanged.connect(self.check_valid) + self.first_tier_box.valueChanged.connect(self.check_valid) + self.first_tier_box.valueChanged.connect(self.update_tier_labels) + # NOTE: Signal defined in UI file to close window when save button clicked self.save_but.clicked.connect(self.init_variables) - self.new_row_but.clicked.connect(self.add_row) + self.add_row_but.clicked.connect(self.add_row) self.del_row_but.clicked.connect(self.remove_row) # Set validators @@ -105,6 +108,10 @@ class PlatformEdit(QWidget): # If debugging, save time by hardcoding if self.autofill: self.plat_name = "AJBell" + self.fund_plat_fee = [ + [0, 250000, 1000000, 2000000], + [0, 0.25, 0.1, 0.05] + ] self.fund_deal_fee = 1.50 self.share_plat_fee = 0.0025 self.share_plat_max_fee = 3.50 @@ -134,6 +141,7 @@ class PlatformEdit(QWidget): # It's also called when any field emits a textChanged() or valueChanged() signal def check_valid(self): valid = True + tiers_valid = True # Check all required fields have a non-zero value for field in self.required_fields: @@ -163,11 +171,34 @@ class PlatformEdit(QWidget): input_box_item.setEnabled(False) self.check_boxes_ticked[i] = False - if valid: + if self.fund_fee_rows > 1: + if self.widgets_list_list[0][1].value() <= self.first_tier_box.value(): + tiers_valid = False + + for i in range(len(self.widgets_list_list) - 1, 0, -1): + if self.widgets_list_list[i][1].value() <= self.widgets_list_list[i-1][1].value(): + tiers_valid = False + print("sad :(") + + if tiers_valid: + self.add_row_but.setEnabled(True) + else: + self.add_row_but.setEnabled(False) + + if valid and tiers_valid: self.save_but.setEnabled(True) else: self.save_but.setEnabled(False) + def update_tier_labels(self): + if self.fund_fee_rows > 1: + prev_value = self.first_tier_box.value() + self.widgets_list_list[0][0].setText(f"between £{int(prev_value)} and") + + for i in range(len(self.widgets_list_list) - 1, 0, -1): + prev_value = self.widgets_list_list[i-1][1].value() + self.widgets_list_list[i][0].setText(f"between £{int(prev_value)} and") + def add_row(self): if self.fund_fee_rows > 5: return -1 @@ -184,6 +215,8 @@ class PlatformEdit(QWidget): widgets[1].setMaximum(9999999) widgets[1].setButtonSymbols(FastEditQDoubleSpinBox.ButtonSymbols.NoButtons) widgets[1].setFont(font) + widgets[1].valueChanged.connect(self.check_valid) + widgets[1].valueChanged.connect(self.update_tier_labels) widgets.append(QLabel(self.gridLayoutWidget_2)) widgets[2].setText(f"the fee is") @@ -213,12 +246,17 @@ class PlatformEdit(QWidget): cur_label_item = self.gridLayout_2.itemAtPosition(cur_label_pos[0], cur_label_pos[1]).widget() cur_label_item.setText(f"between £{int(prev_box_item.value())} and") + if self.fund_fee_rows > 1: + self.del_row_but.setEnabled(True) + + if self.fund_fee_rows > 5: + self.add_row_but.setEnabled(False) + + self.check_valid() + # TODO: Tab order def remove_row(self): - if not self.fund_fee_rows > 1: - return -1 - for widget in self.widgets_list_list[self.fund_fee_rows - 2]: self.gridLayout_2.removeWidget(widget) widget.hide() @@ -226,6 +264,12 @@ class PlatformEdit(QWidget): self.fund_fee_rows -= 1 self.gridLayoutWidget_2.setGeometry(11, 314, 611, int(round(28.5 * self.fund_fee_rows, 0))) + if self.fund_fee_rows < 2: + self.del_row_but.setEnabled(False) + + if self.fund_fee_rows < 6: + self.add_row_but.setEnabled(True) + # Getter functions (is this necessary? maybe directly reading class vars would be best...) def get_optional_boxes(self): return self.check_boxes_ticked From 0338bc0bb739670dcad38de0d82a0824e5e8e482 Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Tue, 18 Mar 2025 12:47:31 +0000 Subject: [PATCH 07/10] fix input validation when removing rows --- src/platform_edit.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform_edit.py b/src/platform_edit.py index 07c6c51..13c4544 100644 --- a/src/platform_edit.py +++ b/src/platform_edit.py @@ -270,6 +270,8 @@ class PlatformEdit(QWidget): if self.fund_fee_rows < 6: self.add_row_but.setEnabled(True) + self.check_valid() + # Getter functions (is this necessary? maybe directly reading class vars would be best...) def get_optional_boxes(self): return self.check_boxes_ticked From a99a6263a82e0d793dfa6d3126023ef6a2ff0d2e Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Tue, 18 Mar 2025 13:00:02 +0000 Subject: [PATCH 08/10] ensure the fee for a band is non-zero --- src/platform_edit.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/platform_edit.py b/src/platform_edit.py index 13c4544..a78c0d9 100644 --- a/src/platform_edit.py +++ b/src/platform_edit.py @@ -171,14 +171,20 @@ class PlatformEdit(QWidget): input_box_item.setEnabled(False) self.check_boxes_ticked[i] = False + if self.first_tier_fee_box.value() == 0: + tiers_valid = False + if self.fund_fee_rows > 1: if self.widgets_list_list[0][1].value() <= self.first_tier_box.value(): tiers_valid = False + if self.widgets_list_list[0][3].value() == 0: + tiers_valid = False for i in range(len(self.widgets_list_list) - 1, 0, -1): if self.widgets_list_list[i][1].value() <= self.widgets_list_list[i-1][1].value(): tiers_valid = False - print("sad :(") + if self.widgets_list_list[i][3].value() == 0: + tiers_valid = False if tiers_valid: self.add_row_but.setEnabled(True) @@ -227,6 +233,7 @@ class PlatformEdit(QWidget): widgets[3].setMaximum(100) widgets[3].setButtonSymbols(FastEditQDoubleSpinBox.ButtonSymbols.NoButtons) widgets[3].setFont(font) + widgets[3].valueChanged.connect(self.check_valid) # TODO: why 28.5? self.gridLayoutWidget_2.setGeometry(11, 314, 611, int(round(28.5 * (self.fund_fee_rows + 1), 0))) From 255fed7ce78b5bc8ad3bf3dca616aa2119f54eff Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Tue, 18 Mar 2025 13:06:45 +0000 Subject: [PATCH 09/10] fix inout validation on first row --- gui/platform_edit.ui | 3 +++ src/platform_edit.py | 1 + 2 files changed, 4 insertions(+) diff --git a/gui/platform_edit.ui b/gui/platform_edit.ui index 4194e82..c5a4737 100644 --- a/gui/platform_edit.ui +++ b/gui/platform_edit.ui @@ -446,6 +446,9 @@ + + false + 532 diff --git a/src/platform_edit.py b/src/platform_edit.py index a78c0d9..165e344 100644 --- a/src/platform_edit.py +++ b/src/platform_edit.py @@ -77,6 +77,7 @@ class PlatformEdit(QWidget): check_box.checkStateChanged.connect(self.check_valid) self.first_tier_box.valueChanged.connect(self.check_valid) + self.first_tier_fee_box.valueChanged.connect(self.check_valid) self.first_tier_box.valueChanged.connect(self.update_tier_labels) # NOTE: Signal defined in UI file to close window when save button clicked From e0f49a1c14eae5cce4c7e98b7e1f89fe42739cf8 Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Tue, 18 Mar 2025 13:35:55 +0000 Subject: [PATCH 10/10] add dynamic 'on the value above' label --- gui/platform_edit.ui | 20 +++++++++++++++++++- src/platform_edit.py | 16 ++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/gui/platform_edit.ui b/gui/platform_edit.ui index c5a4737..fe3a57d 100644 --- a/gui/platform_edit.ui +++ b/gui/platform_edit.ui @@ -368,7 +368,7 @@ 11 - 314 + 309 611 31 @@ -487,6 +487,24 @@ Remove row + + + + 6 + 479 + 421 + 21 + + + + + 10 + + + + on the value above £ there is no charge + + diff --git a/src/platform_edit.py b/src/platform_edit.py index 165e344..06573cc 100644 --- a/src/platform_edit.py +++ b/src/platform_edit.py @@ -187,7 +187,7 @@ class PlatformEdit(QWidget): if self.widgets_list_list[i][3].value() == 0: tiers_valid = False - if tiers_valid: + if tiers_valid and self.fund_fee_rows < 6: self.add_row_but.setEnabled(True) else: self.add_row_but.setEnabled(False) @@ -206,10 +206,13 @@ class PlatformEdit(QWidget): prev_value = self.widgets_list_list[i-1][1].value() self.widgets_list_list[i][0].setText(f"between £{int(prev_value)} and") - def add_row(self): - if self.fund_fee_rows > 5: - return -1 + if self.fund_fee_rows > 1: + max_band = self.widgets_list_list[self.fund_fee_rows - 2][1].value() + else: + max_band = self.first_tier_box.value() + self.val_above_lab.setText(f"on the value above £{int(max_band)} there is no charge") + def add_row(self): widgets = [] font = QFont() font.setPointSize(11) @@ -237,7 +240,7 @@ class PlatformEdit(QWidget): widgets[3].valueChanged.connect(self.check_valid) # TODO: why 28.5? - self.gridLayoutWidget_2.setGeometry(11, 314, 611, int(round(28.5 * (self.fund_fee_rows + 1), 0))) + self.gridLayoutWidget_2.setGeometry(11, 309, 611, int(round(28.5 * (self.fund_fee_rows + 1), 0))) for i in range(len(widgets)): self.gridLayout_2.addWidget(widgets[i], self.fund_fee_rows, i, 1, 1) @@ -270,7 +273,7 @@ class PlatformEdit(QWidget): widget.hide() self.widgets_list_list.pop() self.fund_fee_rows -= 1 - self.gridLayoutWidget_2.setGeometry(11, 314, 611, int(round(28.5 * self.fund_fee_rows, 0))) + self.gridLayoutWidget_2.setGeometry(11, 309, 611, int(round(28.5 * self.fund_fee_rows, 0))) if self.fund_fee_rows < 2: self.del_row_but.setEnabled(False) @@ -279,6 +282,7 @@ class PlatformEdit(QWidget): self.add_row_but.setEnabled(True) self.check_valid() + self.update_tier_labels() # Getter functions (is this necessary? maybe directly reading class vars would be best...) def get_optional_boxes(self):