make fund_plat_fee user defined (no validation)

This commit is contained in:
Roland W-H 2025-03-17 15:16:02 +00:00
parent fca1b384bd
commit 32bc3add9b
2 changed files with 175 additions and 29 deletions

View File

@ -6,32 +6,20 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>498</width> <width>630</width>
<height>303</height> <height>567</height>
</rect> </rect>
</property> </property>
<property name="minimumSize">
<size>
<width>498</width>
<height>303</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>498</width>
<height>303</height>
</size>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Platform Editor</string> <string>Platform Editor</string>
</property> </property>
<widget class="QWidget" name="gridLayoutWidget"> <widget class="QWidget" name="gridLayoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>10</x>
<y>20</y> <y>20</y>
<width>461</width> <width>611</width>
<height>243</height> <height>241</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
@ -261,8 +249,8 @@
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>350</x> <x>482</x>
<y>270</y> <y>534</y>
<width>141</width> <width>141</width>
<height>24</height> <height>24</height>
</rect> </rect>
@ -274,8 +262,8 @@
<widget class="QLabel" name="req_field_lab"> <widget class="QLabel" name="req_field_lab">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>8</x>
<y>280</y> <y>262</y>
<width>191</width> <width>191</width>
<height>21</height> <height>21</height>
</rect> </rect>
@ -287,7 +275,7 @@
<widget class="QLabel" name="active_lab"> <widget class="QLabel" name="active_lab">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>437</x> <x>577</x>
<y>10</y> <y>10</y>
<width>61</width> <width>61</width>
<height>16</height> <height>16</height>
@ -300,6 +288,93 @@
<set>Qt::AlignmentFlag::AlignCenter</set> <set>Qt::AlignmentFlag::AlignCenter</set>
</property> </property>
</widget> </widget>
<widget class="QWidget" name="gridLayoutWidget_2">
<property name="geometry">
<rect>
<x>11</x>
<y>314</y>
<width>611</width>
<height>31</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="3">
<widget class="FastEditQDoubleSpinBox" name="first_tier_fee_box">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property>
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
</property>
<property name="suffix">
<string>%</string>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="first_tier_lab">
<property name="text">
<string>on the first</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="first_tier_fee_lab">
<property name="text">
<string>the fee is</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="FastEditQDoubleSpinBox" name="first_tier_box">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property>
<property name="correctionMode">
<enum>QAbstractSpinBox::CorrectionMode::CorrectToNearestValue</enum>
</property>
<property name="prefix">
<string>£</string>
</property>
<property name="maximum">
<double>9999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="new_row_but">
<property name="geometry">
<rect>
<x>532</x>
<y>481</y>
<width>91</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>Add row</string>
</property>
</widget>
<widget class="QPushButton" name="del_row_but">
<property name="geometry">
<rect>
<x>440</x>
<y>481</y>
<width>91</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>Remove row</string>
</property>
</widget>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
@ -321,7 +396,6 @@
<tabstop>share_deal_fee_box</tabstop> <tabstop>share_deal_fee_box</tabstop>
<tabstop>share_deal_reduce_trades_box</tabstop> <tabstop>share_deal_reduce_trades_box</tabstop>
<tabstop>share_deal_reduce_amount_box</tabstop> <tabstop>share_deal_reduce_amount_box</tabstop>
<tabstop>save_but</tabstop>
<tabstop>plat_name_check</tabstop> <tabstop>plat_name_check</tabstop>
<tabstop>fund_deal_fee_check</tabstop> <tabstop>fund_deal_fee_check</tabstop>
<tabstop>share_plat_fee_check</tabstop> <tabstop>share_plat_fee_check</tabstop>
@ -329,6 +403,11 @@
<tabstop>share_deal_fee_check</tabstop> <tabstop>share_deal_fee_check</tabstop>
<tabstop>share_deal_reduce_trades_check</tabstop> <tabstop>share_deal_reduce_trades_check</tabstop>
<tabstop>share_deal_reduce_amount_check</tabstop> <tabstop>share_deal_reduce_amount_check</tabstop>
<tabstop>first_tier_box</tabstop>
<tabstop>first_tier_fee_box</tabstop>
<tabstop>del_row_but</tabstop>
<tabstop>new_row_but</tabstop>
<tabstop>save_but</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections> <connections>

View File

@ -1,8 +1,9 @@
from PyQt6.QtCore import QRegularExpression from PyQt6.QtCore import QRegularExpression
from PyQt6.QtGui import QRegularExpressionValidator from PyQt6.QtGui import QRegularExpressionValidator
from PyQt6.QtWidgets import QWidget from PyQt6.QtWidgets import QWidget, QLabel
from PyQt6 import uic from PyQt6 import uic
from widgets.fastedit_spinbox import FastEditQDoubleSpinBox
import main_window import main_window
@ -16,11 +17,7 @@ class PlatformEdit(QWidget):
# Create main window object, passing this instance as param # Create main window object, passing this instance as param
self.main_win = main_window.SIPPCompare(self) self.main_win = main_window.SIPPCompare(self)
# TODO: Make fund_plat_fee user-defined self.fund_plat_fee = []
self.fund_plat_fee = [
[0, 250000, 1000000, 2000000],
[0, 0.25, 0.1, 0.05]
]
self.plat_name = "" self.plat_name = ""
self.fund_deal_fee = 0.0 self.fund_deal_fee = 0.0
self.share_plat_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_fee = 0.0
self.share_deal_reduce_trades = 0.0 self.share_deal_reduce_trades = 0.0
self.share_deal_reduce_amount = 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 # Debugging feature: set with "--DEBUG_AUTOFILL" cmd argument
self.autofill = autofill self.autofill = autofill
if autofill: if autofill:
@ -76,6 +76,8 @@ class PlatformEdit(QWidget):
# NOTE: Signal defined in UI file to close window when save button clicked # NOTE: Signal defined in UI file to close window when save button clicked
self.save_but.clicked.connect(self.init_variables) 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 # Set validators
# Regex accepts any characters that match [a-Z], [0-9] or _ # Regex accepts any characters that match [a-Z], [0-9] or _
@ -83,6 +85,19 @@ class PlatformEdit(QWidget):
QRegularExpressionValidator(QRegularExpression("\\w*")) 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 # Get fee structure variables from user input when "Save" clicked
def init_variables(self): def init_variables(self):
# If debugging, save time by hardcoding # If debugging, save time by hardcoding
@ -96,6 +111,7 @@ class PlatformEdit(QWidget):
self.share_deal_reduce_amount = 3.50 self.share_deal_reduce_amount = 3.50
else: else:
self.plat_name = self.plat_name_box.text() 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.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_fee = float(self.share_plat_fee_box.value()) / 100
self.share_plat_max_fee = float(self.share_plat_max_fee_box.value()) self.share_plat_max_fee = float(self.share_plat_max_fee_box.value())
@ -150,6 +166,57 @@ class PlatformEdit(QWidget):
else: else:
self.save_but.setEnabled(False) 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...) # Getter functions (is this necessary? maybe directly reading class vars would be best...)
def get_optional_boxes(self): def get_optional_boxes(self):
return self.check_boxes_ticked return self.check_boxes_ticked