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