fix: prevent "852,500" corruption in Finance Ledger calculate

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.
This commit is contained in:
2026-06-03 00:05:18 +01:00
parent b744b91354
commit 313850dcd2
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"id": "zero-engine", "id": "zero-engine",
"title": "Zero Engine (SLA Industries)", "title": "Zero Engine (SLA Industries)",
"description": "A basic game system for SLA Industries using the Zero Engine rules.", "description": "A basic game system for SLA Industries using the Zero Engine rules.",
"version": "1.5.0", "version": "1.5.1",
"compatibility": { "compatibility": {
"minimum": 13, "minimum": 13,
"verified": "14.359" "verified": "14.359"
+9 -1
View File
@@ -5602,6 +5602,9 @@ class SLAGMFinanceTool extends Application {
const current = this._readCredits(actor); const current = this._readCredits(actor);
const newBal = current + income - expenses; 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({ await actor.update({
'system.details.credits': newBal, 'system.details.credits': newBal,
'system.finances.income.salary': 0, 'system.finances.income.salary': 0,
@@ -5614,7 +5617,12 @@ class SLAGMFinanceTool extends Application {
'system.finances.expenses.bulletTax': 0, 'system.finances.expenses.bulletTax': 0,
'system.finances.ammoSpentSession': 0, 'system.finances.ammoSpentSession': 0,
'system.finances.debt': 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( ui.notifications.info(
`${actor.name}: ${current}c + ${income}c income − ${expenses}c expenses = ${newBal}c` `${actor.name}: ${current}c + ${income}c income − ${expenses}c expenses = ${newBal}c`