From 58b356ea8b05a629c2893db26121c3cd7664e341 Mon Sep 17 00:00:00 2001 From: h Date: Fri, 16 Oct 2026 15:51:00 +0000 Subject: [PATCH] fix(editor): clearing the foreign amount clears it in Firefly Firefly keeps a foreign amount sent as null on update and only drops it for "0". --- src/lib/components/editor/model.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/components/editor/model.ts b/src/lib/components/editor/model.ts index 098666d..90d4472 100644 --- a/src/lib/components/editor/model.ts +++ b/src/lib/components/editor/model.ts @@ -364,15 +364,20 @@ function splitPayload(form: Form, split: SplitForm, update: boolean) { return body; } const foreign = hasForeign(split) && split.foreignAmount.trim() !== ""; + let foreignAmount = update ? "0" : null; + if (foreign) { + foreignAmount = amountString( + split.foreignAmount, + split.foreignCurrency?.decimals ?? 2 + ); + } return { ...body, ...accountFields("source", sideOf(form, split, "source")), ...accountFields("destination", sideOf(form, split, "destination")), amount: amountString(split.amount, split.currency?.decimals ?? 2), currency_code: split.currency?.code, - foreign_amount: foreign - ? amountString(split.foreignAmount, split.foreignCurrency?.decimals ?? 2) - : null, + foreign_amount: foreignAmount, foreign_currency_code: foreign ? split.foreignCurrency?.code : null, }; }