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".
This commit is contained in:
hh committed 2026-10-16 15:51:00 +00:00
1 parent f3a597d39c
commit 58b356ea8b
1 file changed
+8 -3
+8 -3
View File
@@ -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,
};
}