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")