From 313850dcd2ddfc8a2226d072441801122aead960 Mon Sep 17 00:00:00 2001 From: Tim Evans Date: Wed, 3 Jun 2026 00:05:18 +0100 Subject: [PATCH] fix: prevent "852,500" corruption in Finance Ledger calculate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When actor.update() fires, Foundry auto-submits any open character sheet form before re-rendering. If the sheet still showed the old credits value (e.g. 500), that stale value raced the new one (852) and got merged server-side into the corrupt string "852,500". Fix: pass {render: false} to actor.update() so Foundry skips the auto-submit entirely, then manually call app.render() on all open sheets for that actor — they read fresh data and render cleanly. --- system.json | 2 +- zero-engine.mjs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/system.json b/system.json index 8ce7835..4ddbd76 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "id": "zero-engine", "title": "Zero Engine (SLA Industries)", "description": "A basic game system for SLA Industries using the Zero Engine rules.", - "version": "1.5.0", + "version": "1.5.1", "compatibility": { "minimum": 13, "verified": "14.359" diff --git a/zero-engine.mjs b/zero-engine.mjs index fad1ca1..ba7b0c3 100644 --- a/zero-engine.mjs +++ b/zero-engine.mjs @@ -5602,6 +5602,9 @@ class SLAGMFinanceTool extends Application { const current = this._readCredits(actor); const newBal = current + income - expenses; + // {render: false} stops Foundry from auto-submitting open character sheets + // before they re-render, which was causing stale form values (e.g. 500) + // to be merged with the new value (e.g. 852) into a corrupt "852,500" string. await actor.update({ 'system.details.credits': newBal, 'system.finances.income.salary': 0, @@ -5614,7 +5617,12 @@ class SLAGMFinanceTool extends Application { 'system.finances.expenses.bulletTax': 0, 'system.finances.ammoSpentSession': 0, 'system.finances.debt': 0 - }); + }, { render: false }); + + // Now re-render any open sheets for this actor cleanly from fresh data. + for (const app of Object.values(actor.apps ?? {})) { + app.render(false); + } ui.notifications.info( `${actor.name}: ${current}c + ${income}c income − ${expenses}c expenses = ${newBal}c`