Skip to content

Commit

Permalink
fix date calculation in Nationwide bank handler (actualbudget#406)
Browse files Browse the repository at this point in the history
* fix date calculation in Nationwide bank handler

* release note
  • Loading branch information
matt-fidd authored Jul 29, 2024
1 parent b4a620e commit 943f903
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/app-gocardless/banks/nationwide-naiagb21.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ export default {
accessValidForDays: 90,

normalizeTransaction(transaction, booked) {
// Nationwide returns pending transactions with a date representing
// the latest a transaction could be booked. This stops actual's
// deduplication logic from working as it only checks 7 days ahead/behind
// and the transactionID from Nationwide changes when a transaction is
// booked
// Nationwide can sometimes return pending transactions with a date
// representing the latest a transaction could be booked. This stops
// actual's deduplication logic from working as it only checks 7 days
// ahead/behind and the transactionID from Nationwide changes when a
// transaction is booked
if (!booked) {
const d = new Date(transaction.bookingDate);
d.setDate(d.getDate() - 8);

const useDate = new Date(Math.min(d.getTime(), new Date().getTime()));

const useDate = new Date(
Math.min(
new Date(transaction.bookingDate).getTime(),
new Date().getTime(),
),
);
transaction.bookingDate = useDate.toISOString().slice(0, 10);
}

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

Fix date calculation in Nationwide bank handler

0 comments on commit 943f903

Please sign in to comment.