Skip to content

Commit

Permalink
sort SimpleFIN transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Feb 11, 2025
1 parent 6710456 commit a4c7338
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/sync-server/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,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) {
Expand Down

0 comments on commit a4c7338

Please sign in to comment.