Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Sort SimpleFIN transactions in date order #559

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/app-simplefin/app-simplefin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -231,7 +232,19 @@ function getAccountResponse(results, accountId, startDate) {
all.push(newTrans);
}

return { balances, startingBalance, transactions: { all, booked, pending } };
const bookedSorted = booked.sort((a, b) => b.sortOrder - a.sortOrder);
const pendingSorted = pending.sort((a, b) => b.sortOrder - a.sortOrder);
const allSorted = all.sort((a, b) => b.sortOrder - a.sortOrder);

return {
balances,
startingBalance,
transactions: {
all: allSorted,
booked: bookedSorted,
pending: pendingSorted,
},
};
}

function invalidToken(res) {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/559.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [matt-fidd]
---

Ensure SimpleFIN transactions are sorted by date