From 89602494997a2101cb5662dd4938dc2dba324eea Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Wed, 1 Apr 2026 00:42:48 -0400 Subject: [PATCH] fix: use DB cassettes for HAL init instead of compiled preset The HAL inventory was built from the config preset, ignoring operator changes made via atm-tui or SQL. Now reads cassettes from the DB at HAL init time so denomination/count changes take effect on restart. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/machine/electron/main.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/machine/electron/main.ts b/apps/machine/electron/main.ts index e4f244c..ac55672 100644 --- a/apps/machine/electron/main.ts +++ b/apps/machine/electron/main.ts @@ -261,6 +261,18 @@ let pendingBillDenomination: number | null = null ipcMain.handle('hal:init', async (_event, config) => { try { + // Override cassette config with DB values (operator may have changed them via atm-tui) + const dbCassettes = loadCassettes() + if (dbCassettes.length > 0) { + config.dispenser.cassettes = dbCassettes.map( + (c: { denomination: number; count: number }) => ({ + denomination: c.denomination, + count: c.count, + }) + ) + console.log('[Electron] Using DB cassettes for HAL init:', config.dispenser.cassettes) + } + halInstance = await initializeHal(config) // Wire validator events → forward to renderer via IPC