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:
+1
-1
@@ -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
@@ -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`
|
||||||
|
|||||||
Reference in New Issue
Block a user