From 0baccfd728a1dfba5f9e53ebaaf52e21af6fef82 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys <me@jacken.men> Date: Sun, 12 Mar 2023 21:53:10 +0100 Subject: [PATCH] :bug: (nordigen) fix detection of -0.00 "debited" transactions (#744) Check if the transaction amount is a positive 0 rather than -0. I went for casting the string with `Number` but I could instead replace the whole condition with `!trans.amount.startsWith('-')` or with `trans.amount > 0 || trans.amount == '0.00'` if either of these variants are preferred. Fix for https://github.com/actualbudget/actual/issues/724#issuecomment-1464907064 --- packages/loot-core/src/server/accounts/sync.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/loot-core/src/server/accounts/sync.js b/packages/loot-core/src/server/accounts/sync.js index 7a64ebee0..43fd7d1b2 100644 --- a/packages/loot-core/src/server/accounts/sync.js +++ b/packages/loot-core/src/server/accounts/sync.js @@ -312,7 +312,10 @@ async function normalizeNordigenTransactions(transactions, acctId) { } let payee_name; - if (trans.amount >= 0) { + // When the amount is equal to 0, we need to determine + // if this is a "Credited" or "Debited" transaction. This means + // that it matters whether the amount is a positive or negative zero. + if (trans.amount > 0 || Object.is(Number(trans.amount), 0)) { const nameParts = []; nameParts.push( title( -- GitLab