Skip to content

A local-first personal finance app

Sort SimpleFIN transactions in date order (#4354)

Matt Fiddaman5e217ec9a283
diff --git a/packages/sync-server/src/app-simplefin/app-simplefin.js b/packages/sync-server/src/app-simplefin/app-simplefin.js
index f453f0b150..50ad78fafe 100644
--- a/packages/sync-server/src/app-simplefin/app-simplefin.js
+++ b/packages/sync-server/src/app-simplefin/app-simplefin.js
@@ -216,6 +216,7 @@ function getAccountResponse(results, accountId, startDate) {
continue;
}
+ newTrans.sortOrder = dateToUse;
newTrans.date = getDate(transactionDate);
newTrans.payeeName = trans.payee;
newTrans.remittanceInformationUnstructured = trans.description;
@@ -231,7 +232,21 @@ function getAccountResponse(results, accountId, startDate) {
all.push(newTrans);
}
- return { balances, startingBalance, transactions: { all, booked, pending } };
+ const sortFunction = (a, b) => b.sortOrder - a.sortOrder;
+
+ const bookedSorted = booked.sort(sortFunction);
+ const pendingSorted = pending.sort(sortFunction);
+ const allSorted = all.sort(sortFunction);
+
+ return {
+ balances,
+ startingBalance,
+ transactions: {
+ all: allSorted,
+ booked: bookedSorted,
+ pending: pendingSorted,
+ },
+ };
}
function invalidToken(res) {
diff --git a/upcoming-release-notes/4354.md b/upcoming-release-notes/4354.md
new file mode 100644
index 0000000000..af1df9d27e
--- /dev/null
+++ b/upcoming-release-notes/4354.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [matt-fidd]
+---
+
+Ensure SimpleFIN transactions are sorted by date