From 9e82032595f23c92f0075590cb27e30d468cd7ed Mon Sep 17 00:00:00 2001 From: Szymon Romanko <61514620+szymon-romanko@users.noreply.github.com> Date: Tue, 4 Mar 2025 13:34:01 +0100 Subject: [PATCH] Fixed transaction dates in bank sync with `MBANK_RETAIL_BREXPLPW` (#4493) * fixed transaction date for MBANK_RETAIL_BREXPLPW * cleared up imports after previous commit (9251d3e1) * added release notes * linted code * Update packages/sync-server/src/app-gocardless/banks/mbank_retail_brexplpw.js Co-authored-by: Matt Fiddaman --------- Co-authored-by: Matt Fiddaman --- .../banks/mbank_retail_brexplpw.js | 22 +++++++++++++++++++ upcoming-release-notes/4493.md | 6 +++++ 2 files changed, 28 insertions(+) create mode 100644 upcoming-release-notes/4493.md diff --git a/packages/sync-server/src/app-gocardless/banks/mbank_retail_brexplpw.js b/packages/sync-server/src/app-gocardless/banks/mbank_retail_brexplpw.js index 6e15cd8f9c..4f24c399e4 100644 --- a/packages/sync-server/src/app-gocardless/banks/mbank_retail_brexplpw.js +++ b/packages/sync-server/src/app-gocardless/banks/mbank_retail_brexplpw.js @@ -8,6 +8,28 @@ export default { institutionIds: ['MBANK_RETAIL_BREXPLPW'], + /** + * When requesting transaction details for MBANK_RETAIL_BREXPLPW + * using gocardless API, it seems that bookingDate and valueDate are swapped. + * valueDate will always come before bookingDate, so as a simple fix, + * I have overwritten integration-bank.normalizeTransaction() here, + * swapped dates back (by giving valueDate higher priority) and + * called parent method with edited transaction as argument + */ + normalizeTransaction(transaction, booked) { + const editedTrans = { ...transaction }; + + const date = + transaction.valueDate || + transaction.valueDateTime || + transaction.bookingDate || + transaction.bookingDateTime; + + editedTrans.date = date; + + return Fallback.normalizeTransaction(transaction, booked, editedTrans); + }, + sortTransactions(transactions = []) { return transactions.sort( (a, b) => Number(b.transactionId) - Number(a.transactionId), diff --git a/upcoming-release-notes/4493.md b/upcoming-release-notes/4493.md new file mode 100644 index 0000000000..4913d66c98 --- /dev/null +++ b/upcoming-release-notes/4493.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [szymon-romanko] +--- + +Fixed transaction dates for bank sync with mbank_retail_brexplpw