Skip to content

A local-first personal finance app

Pending Transaction Support for SimpleFIN Integration (#315)

Dan D04147fb9b901
diff --git a/src/app-simplefin/app-simplefin.js b/src/app-simplefin/app-simplefin.js
index 82f0010118..705df5c72c 100644
--- a/src/app-simplefin/app-simplefin.js
+++ b/src/app-simplefin/app-simplefin.js
@@ -88,32 +88,48 @@ app.post('/transactions', async (req, res) => {
response.startingBalance = balance; // could be named differently in this use case.
let allTransactions = [];
+ let bookedTransactions = [];
+ let pendingTransactions = [];
for (let trans of account.transactions) {
let newTrans = {};
- //newTrans.bankTransactionCode = don't have compared to GoCardless
- newTrans.booked = true;
- newTrans.bookingDate = new Date(trans.posted * 1000)
+ let dateToUse = 0;
+
+ if (trans.posted == 0) {
+ newTrans.booked = false;
+ dateToUse = trans.transacted_at;
+ } else {
+ newTrans.booked = true;
+ dateToUse = trans.posted;
+ }
+
+ newTrans.bookingDate = new Date(dateToUse * 1000)
.toISOString()
.split('T')[0];
- newTrans.date = new Date(trans.posted * 1000).toISOString().split('T')[0];
+
+ newTrans.date = new Date(dateToUse * 1000).toISOString().split('T')[0];
newTrans.debtorName = trans.payee;
//newTrans.debtorAccount = don't have compared to GoCardless
newTrans.remittanceInformationUnstructured = trans.description;
newTrans.transactionAmount = { amount: trans.amount, currency: 'USD' };
newTrans.transactionId = trans.id;
- newTrans.valueDate = new Date(trans.posted * 1000)
+ newTrans.valueDate = new Date(dateToUse * 1000)
.toISOString()
.split('T')[0];
+ if (newTrans.booked) {
+ bookedTransactions.push(newTrans);
+ } else {
+ pendingTransactions.push(newTrans);
+ }
allTransactions.push(newTrans);
}
response.transactions = {
all: allTransactions,
- booked: allTransactions,
- pending: [],
+ booked: bookedTransactions,
+ pending: pendingTransactions,
};
res.send({
@@ -202,6 +218,9 @@ async function getAccounts(accessKey, startDate, endDate) {
if (endDate) {
params.push(`end-date=${normalizeDate(endDate)}`);
}
+
+ params.push(`pending=1`);
+
if (params.length > 0) {
queryString += '?' + params.join('&');
}
diff --git a/upcoming-release-notes/315.md b/upcoming-release-notes/315.md
new file mode 100644
index 0000000000..8bde445fd7
--- /dev/null
+++ b/upcoming-release-notes/315.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [duplaja]
+---
+
+Add pending transaction import and handling, where supported, to SimpleFIN integration.