From dae96f2cd38efc6b767781b567569cf3bbcd2183 Mon Sep 17 00:00:00 2001 From: behrinml Date: Thu, 30 Jul 2026 22:36:39 +0200 Subject: [PATCH] cleanup of billing/costcenter pr --- backend/app/core/database.py | 12 ++++-------- backend/tests/unit/test_finance_table_migration.py | 4 +++- frontend/src/__tests__/pages/SettingsPage.test.tsx | 5 +++-- frontend/src/pages/SettingsPage.tsx | 3 +-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/backend/app/core/database.py b/backend/app/core/database.py index 52f52d489..aafe53bac 100644 --- a/backend/app/core/database.py +++ b/backend/app/core/database.py @@ -1214,22 +1214,18 @@ async def _migrate_create_finance_indexes(conn) -> None: "CREATE INDEX IF NOT EXISTS ix_cost_center_invitations_email ON cost_center_invitations (email)", "CREATE INDEX IF NOT EXISTS ix_wallet_transactions_user_id ON wallet_transactions (user_id)", "CREATE INDEX IF NOT EXISTS ix_wallet_transactions_cost_center_id ON wallet_transactions (cost_center_id)", - "CREATE INDEX IF NOT EXISTS ix_wallet_transactions_transaction_type " - "ON wallet_transactions (transaction_type)", + "CREATE INDEX IF NOT EXISTS ix_wallet_transactions_transaction_type ON wallet_transactions (transaction_type)", "CREATE INDEX IF NOT EXISTS ix_wallet_transactions_created_by_user_id " "ON wallet_transactions (created_by_user_id)", "CREATE INDEX IF NOT EXISTS ix_wallet_transactions_print_run_id ON wallet_transactions (print_run_id)", - "CREATE INDEX IF NOT EXISTS ix_wallet_transactions_print_archive_id " - "ON wallet_transactions (print_archive_id)", + "CREATE INDEX IF NOT EXISTS ix_wallet_transactions_print_archive_id ON wallet_transactions (print_archive_id)", "CREATE INDEX IF NOT EXISTS ix_wallet_transactions_print_queue_id ON wallet_transactions (print_queue_id)", "CREATE INDEX IF NOT EXISTS ix_wallet_transactions_created_at ON wallet_transactions (created_at)", - "CREATE INDEX IF NOT EXISTS ix_budget_reservations_cost_center_id " - "ON budget_reservations (cost_center_id)", + "CREATE INDEX IF NOT EXISTS ix_budget_reservations_cost_center_id ON budget_reservations (cost_center_id)", "CREATE INDEX IF NOT EXISTS ix_budget_reservations_status ON budget_reservations (status)", "CREATE INDEX IF NOT EXISTS ix_budget_reservations_source_type ON budget_reservations (source_type)", "CREATE INDEX IF NOT EXISTS ix_budget_reservations_source_id ON budget_reservations (source_id)", - "CREATE INDEX IF NOT EXISTS ix_budget_reservations_print_archive_id " - "ON budget_reservations (print_archive_id)", + "CREATE INDEX IF NOT EXISTS ix_budget_reservations_print_archive_id ON budget_reservations (print_archive_id)", ] for statement in indexes: await _safe_execute(conn, statement) diff --git a/backend/tests/unit/test_finance_table_migration.py b/backend/tests/unit/test_finance_table_migration.py index 449caf341..98088761d 100644 --- a/backend/tests/unit/test_finance_table_migration.py +++ b/backend/tests/unit/test_finance_table_migration.py @@ -86,7 +86,9 @@ async def test_postgres_finance_ddl_uses_postgres_types(): assert all("id SERIAL PRIMARY KEY" in sql for sql in create_statements) assert "TIMESTAMP" in "\n".join(create_statements) - created_tables = {sql.split("CREATE TABLE IF NOT EXISTS", 1)[1].split("(", 1)[0].strip() for sql in create_statements} + created_tables = { + sql.split("CREATE TABLE IF NOT EXISTS", 1)[1].split("(", 1)[0].strip() for sql in create_statements + } assert created_tables == EXPECTED_TABLES diff --git a/frontend/src/__tests__/pages/SettingsPage.test.tsx b/frontend/src/__tests__/pages/SettingsPage.test.tsx index c98f62a0d..38449b778 100644 --- a/frontend/src/__tests__/pages/SettingsPage.test.tsx +++ b/frontend/src/__tests__/pages/SettingsPage.test.tsx @@ -303,7 +303,7 @@ describe('SettingsPage', () => { expect(localStorage.setItem).toHaveBeenCalledWith( SIDEBAR_ORDER_KEY, - JSON.stringify(['ext-7', 'printers', 'inventory', 'archives', 'queue', 'projects', 'files', 'makerworld', 'profiles', 'maintenance', 'stats', 'notifications', 'settings']), + JSON.stringify(['ext-7', 'printers', 'inventory', 'archives', 'queue', 'projects', 'finance', 'files', 'makerworld', 'profiles', 'maintenance', 'stats', 'notifications', 'settings']), ); }); @@ -345,7 +345,7 @@ describe('SettingsPage', () => { expect(localStorage.setItem).toHaveBeenCalledWith(SIDEBAR_HIDDEN_SYSTEM_ITEMS_KEY, JSON.stringify([])); expect(localStorage.setItem).toHaveBeenCalledWith( SIDEBAR_ORDER_KEY, - JSON.stringify(['printers', 'inventory', 'archives', 'queue', 'projects', 'files', 'makerworld', 'profiles', 'maintenance', 'stats', 'notifications', 'settings', 'ext-7']), + JSON.stringify(['printers', 'inventory', 'archives', 'queue', 'projects', 'finance', 'files', 'makerworld', 'profiles', 'maintenance', 'stats', 'notifications', 'settings', 'ext-7']), ); const settingsRow = screen.getAllByText('Settings') @@ -411,6 +411,7 @@ describe('SettingsPage', () => { 'archives', 'queue', 'projects', + 'finance', 'files', 'makerworld', 'profiles', diff --git a/frontend/src/pages/SettingsPage.tsx b/frontend/src/pages/SettingsPage.tsx index 6076b66ef..1ee2612d4 100644 --- a/frontend/src/pages/SettingsPage.tsx +++ b/frontend/src/pages/SettingsPage.tsx @@ -1032,8 +1032,7 @@ export function SettingsPage() { (settings.bed_temp_presets ?? '') !== (localSettings.bed_temp_presets ?? '') || (settings.chamber_temp_presets ?? '') !== (localSettings.chamber_temp_presets ?? '') || (settings.fan_speed_presets ?? '') !== (localSettings.fan_speed_presets ?? '') || - (settings.session_max_hours ?? 24) !== (localSettings.session_max_hours ?? 24); - (settings.require_plate_clear ?? false) !== (localSettings.require_plate_clear ?? false) || + (settings.session_max_hours ?? 24) !== (localSettings.session_max_hours ?? 24) || (settings.billing_enabled ?? false) !== (localSettings.billing_enabled ?? false) || (settings.printer_kill_switch_enabled ?? false) !== (localSettings.printer_kill_switch_enabled ?? false) || (settings.finance_budget_reset_day ?? 1) !== (localSettings.finance_budget_reset_day ?? 1) ||