Add 'use main stack settings' toggle for third-party integration credentials

Each of Newbook, Resos, SambaPOS, SMTP, and Nextcloud now has a checkbox at the
top of its credentials block. When enabled, the app reads auth credentials from
the central stack settings service (SETTINGS_URL + STACK_INTERNAL_SECRET) and
the local auth fields are grayed out. App-specific fields (base path, GL codes,
keywords, sync intervals, etc.) remain editable regardless.

Backend: new use_global_* columns on kitchen_settings, migration, global_settings_service
with apply_global_overrides() for in-memory credential injection, GET /api/settings/global-status
endpoint, and apply_global_overrides() called in test-connection endpoints and FileArchivalService.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-12 21:57:10 +00:00
parent 62417d59de
commit d7898ba897
10 changed files with 356 additions and 34 deletions

View file

@ -45,6 +45,7 @@ class NewbookSettingsResponse(BaseModel):
newbook_dinner_gl_codes: str | None
newbook_breakfast_vat_rate: Decimal | None
newbook_dinner_vat_rate: Decimal | None
use_global_newbook: bool = False
class Config:
from_attributes = True
@ -63,6 +64,7 @@ class NewbookSettingsUpdate(BaseModel):
newbook_dinner_gl_codes: str | None = None
newbook_breakfast_vat_rate: Decimal | None = None
newbook_dinner_vat_rate: Decimal | None = None
use_global_newbook: bool | None = None
class GLAccountResponse(BaseModel):
@ -232,7 +234,8 @@ async def get_newbook_settings(
newbook_breakfast_gl_codes=settings.newbook_breakfast_gl_codes,
newbook_dinner_gl_codes=settings.newbook_dinner_gl_codes,
newbook_breakfast_vat_rate=settings.newbook_breakfast_vat_rate,
newbook_dinner_vat_rate=settings.newbook_dinner_vat_rate
newbook_dinner_vat_rate=settings.newbook_dinner_vat_rate,
use_global_newbook=settings.use_global_newbook,
)
@ -285,7 +288,8 @@ async def update_newbook_settings(
newbook_breakfast_gl_codes=settings.newbook_breakfast_gl_codes,
newbook_dinner_gl_codes=settings.newbook_dinner_gl_codes,
newbook_breakfast_vat_rate=settings.newbook_breakfast_vat_rate,
newbook_dinner_vat_rate=settings.newbook_dinner_vat_rate
newbook_dinner_vat_rate=settings.newbook_dinner_vat_rate,
use_global_newbook=settings.use_global_newbook,
)
@ -334,6 +338,9 @@ async def test_newbook_connection(
if not settings:
raise HTTPException(status_code=404, detail="Settings not found")
from services.global_settings_service import apply_global_overrides
await apply_global_overrides(settings)
if not all([
settings.newbook_api_username,
settings.newbook_api_password,