From 593dec96d166e5b3dace2e3cd38b9c85edbb1ff4 Mon Sep 17 00:00:00 2001 From: Roland W-H Date: Sat, 26 Apr 2025 16:37:23 +0100 Subject: [PATCH] add enable/disable platform functionality --- src/db_handler.py | 3 +-- src/main_window.py | 5 ++++- src/platform_list.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/db_handler.py b/src/db_handler.py index 3543e1e..47c7cdf 100644 --- a/src/db_handler.py +++ b/src/db_handler.py @@ -243,8 +243,7 @@ class DBHandler: return user_details_dict def toggle_platform_state(self, index: int, state: bool): - state_data = [state, index] - self.cur.execute("UPDATE tblPlatforms SET IsEnabled = ? WHERE PlatformID = ?", state_data) + self.cur.execute("UPDATE tblPlatforms SET IsEnabled = ? WHERE PlatformID = ?", [state, index]) self.conn.commit() def remove_platform(self, index: int): diff --git a/src/main_window.py b/src/main_window.py index 3d4e4e2..b999c49 100644 --- a/src/main_window.py +++ b/src/main_window.py @@ -77,7 +77,7 @@ class SIPPCompare(QMainWindow): else: self.calc_but.setEnabled(False) - # Calculate fees + # Calculate fees for all active platforms def calculate_fees(self): # Set to empty list each time to avoid persistence self.results = [] @@ -90,6 +90,9 @@ class SIPPCompare(QMainWindow): shares_value = (1 - (slider_val / 100)) * value_num for platform in self.platform_list_win.plat_list: + if not platform.enabled: + continue + fund_plat_fees = 0.0 fund_deal_fees = 0.0 share_plat_fees = 0.0 diff --git a/src/platform_list.py b/src/platform_list.py index 0630462..a2261c0 100644 --- a/src/platform_list.py +++ b/src/platform_list.py @@ -137,7 +137,7 @@ class PlatformList(QWidget): def toggle_platform_state(self): index = self.platListWidget.currentRow() state = self.plat_enabled_check.isChecked() - self.db.toggle_platform_state(index, state) + self.plat_list[index].enabled = state def remove_platform(self): index = self.platListWidget.currentRow()