From 3c66e777e46b835c35e41d3dbbe49bf8388eb4ce Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Sun, 5 Jul 2026 09:26:49 +0000 Subject: [PATCH] Patch fetch_room_categories and fetch_gl_accounts to use central NewBook creds These two endpoints were missed in the central settings migration. They now try the Settings service first and fall back to app-local system_config. Co-Authored-By: Claude Sonnet 4.6 --- backend/api/config.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/backend/api/config.py b/backend/api/config.py index fa4a889..e85354f 100644 --- a/backend/api/config.py +++ b/backend/api/config.py @@ -280,10 +280,15 @@ async def fetch_room_categories( """Fetch room categories from Newbook API site_list endpoint""" import httpx - api_key = await _get_config_value(db, "newbook_api_key") - username = await _get_config_value(db, "newbook_username") - password = await _get_config_value(db, "newbook_password") - region = await _get_config_value(db, "newbook_region") + from services.central_settings import get_newbook_credentials + central = await get_newbook_credentials() + if central: + api_key, username, password, region = central["api_key"], central["username"], central["password"], central["region"] + else: + api_key = await _get_config_value(db, "newbook_api_key") + username = await _get_config_value(db, "newbook_username") + password = await _get_config_value(db, "newbook_password") + region = await _get_config_value(db, "newbook_region") if not all([api_key, username, password, region]): raise HTTPException(status_code=400, detail="Newbook credentials not configured") @@ -468,10 +473,15 @@ async def fetch_gl_accounts( """Fetch GL accounts from Newbook API gl_account_list endpoint""" import httpx - api_key = await _get_config_value(db, "newbook_api_key") - username = await _get_config_value(db, "newbook_username") - password = await _get_config_value(db, "newbook_password") - region = await _get_config_value(db, "newbook_region") + from services.central_settings import get_newbook_credentials + central = await get_newbook_credentials() + if central: + api_key, username, password, region = central["api_key"], central["username"], central["password"], central["region"] + else: + api_key = await _get_config_value(db, "newbook_api_key") + username = await _get_config_value(db, "newbook_username") + password = await _get_config_value(db, "newbook_password") + region = await _get_config_value(db, "newbook_region") if not all([api_key, username, password, region]): raise HTTPException(status_code=400, detail="Newbook credentials not configured")