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

Commit 04147fb

Browse files
authored
Pending Transaction Support for SimpleFIN Integration (#315)
* Add Pending Transaction Support Adds support for pending transactions (for banks that support them) from SimpleFIN. * Release Note - Pending Transactions for SimpleFIN * Fix Linter Errors * Fix additional Iinter errors * Spacing - Lint Error Fix
1 parent cd4a2b6 commit 04147fb

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

src/app-simplefin/app-simplefin.js

+26-7
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,48 @@ app.post('/transactions', async (req, res) => {
8888
response.startingBalance = balance; // could be named differently in this use case.
8989

9090
let allTransactions = [];
91+
let bookedTransactions = [];
92+
let pendingTransactions = [];
9193

9294
for (let trans of account.transactions) {
9395
let newTrans = {};
9496

95-
//newTrans.bankTransactionCode = don't have compared to GoCardless
96-
newTrans.booked = true;
97-
newTrans.bookingDate = new Date(trans.posted * 1000)
97+
let dateToUse = 0;
98+
99+
if (trans.posted == 0) {
100+
newTrans.booked = false;
101+
dateToUse = trans.transacted_at;
102+
} else {
103+
newTrans.booked = true;
104+
dateToUse = trans.posted;
105+
}
106+
107+
newTrans.bookingDate = new Date(dateToUse * 1000)
98108
.toISOString()
99109
.split('T')[0];
100-
newTrans.date = new Date(trans.posted * 1000).toISOString().split('T')[0];
110+
111+
newTrans.date = new Date(dateToUse * 1000).toISOString().split('T')[0];
101112
newTrans.debtorName = trans.payee;
102113
//newTrans.debtorAccount = don't have compared to GoCardless
103114
newTrans.remittanceInformationUnstructured = trans.description;
104115
newTrans.transactionAmount = { amount: trans.amount, currency: 'USD' };
105116
newTrans.transactionId = trans.id;
106-
newTrans.valueDate = new Date(trans.posted * 1000)
117+
newTrans.valueDate = new Date(dateToUse * 1000)
107118
.toISOString()
108119
.split('T')[0];
109120

121+
if (newTrans.booked) {
122+
bookedTransactions.push(newTrans);
123+
} else {
124+
pendingTransactions.push(newTrans);
125+
}
110126
allTransactions.push(newTrans);
111127
}
112128

113129
response.transactions = {
114130
all: allTransactions,
115-
booked: allTransactions,
116-
pending: [],
131+
booked: bookedTransactions,
132+
pending: pendingTransactions,
117133
};
118134

119135
res.send({
@@ -202,6 +218,9 @@ async function getAccounts(accessKey, startDate, endDate) {
202218
if (endDate) {
203219
params.push(`end-date=${normalizeDate(endDate)}`);
204220
}
221+
222+
params.push(`pending=1`);
223+
205224
if (params.length > 0) {
206225
queryString += '?' + params.join('&');
207226
}

upcoming-release-notes/315.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: Enhancements
3+
authors: [duplaja]
4+
---
5+
6+
Add pending transaction import and handling, where supported, to SimpleFIN integration.

0 commit comments

Comments
 (0)