A local-first personal finance app
Move bank sync payee name normalisation from `actual` to `actual-server` (#2721)
Matt Fiddaman771c01c8b4a1
diff --git a/packages/loot-core/src/server/accounts/sync.ts b/packages/loot-core/src/server/accounts/sync.tsindex 51300ba1dd..b89969dc4b 100644--- a/packages/loot-core/src/server/accounts/sync.ts+++ b/packages/loot-core/src/server/accounts/sync.ts@@ -255,55 +255,11 @@ async function normalizeBankSyncTransactions(transactions, acctId) {throw new Error('`date` is required when adding a transaction');}- let payee_name;- // 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 = [];- const name =- trans.debtorName ||- trans.remittanceInformationUnstructured ||- (trans.remittanceInformationUnstructuredArray || []).join(', ') ||- trans.additionalInformation;-- if (name) {- nameParts.push(title(name));- }- if (trans.debtorAccount && trans.debtorAccount.iban) {- nameParts.push(- '(' +- trans.debtorAccount.iban.slice(0, 4) +- ' XXX ' +- trans.debtorAccount.iban.slice(-4) +- ')',- );- }- payee_name = nameParts.join(' ');- } else {- const nameParts = [];- const name =- trans.creditorName ||- trans.remittanceInformationUnstructured ||- (trans.remittanceInformationUnstructuredArray || []).join(', ') ||- trans.additionalInformation;-- if (name) {- nameParts.push(title(name));- }- if (trans.creditorAccount && trans.creditorAccount.iban) {- nameParts.push(- '(' +- trans.creditorAccount.iban.slice(0, 4) +- ' XXX ' +- trans.creditorAccount.iban.slice(-4) +- ')',- );- }- payee_name = nameParts.join(' ');+ if (trans.payeeName == null) {+ throw new Error('`payeeName` is required when adding a transaction');}- trans.imported_payee = trans.imported_payee || payee_name;+ trans.imported_payee = trans.imported_payee || trans.payeeName;if (trans.imported_payee) {trans.imported_payee = trans.imported_payee.trim();}@@ -312,12 +268,12 @@ async function normalizeBankSyncTransactions(transactions, acctId) {// when rules are run, they have the right data. Resolving payees// also simplifies the payee creation processtrans.account = acctId;- trans.payee = await resolvePayee(trans, payee_name, payeesToCreate);+ trans.payee = await resolvePayee(trans, trans.payeeName, payeesToCreate);trans.cleared = Boolean(trans.booked);normalized.push({- payee_name,+ payee_name: trans.payeeName,trans: {amount: amountToInteger(trans.amount),payee: trans.payee,diff --git a/upcoming-release-notes/2721.md b/upcoming-release-notes/2721.mdnew file mode 100644index 0000000000..7169051af7--- /dev/null+++ b/upcoming-release-notes/2721.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [matt-fidd]+---++Move bank sync payee name normalization from actual to actual-server