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:
1 parent
f3a597d39c
commit
58b356ea8b
1 file changed
+8
-3
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user