fixed transaction date for MBANK_RETAIL_BREXPLPW

This commit is contained in:
Szymon Romanko
2025-02-28 18:39:33 +00:00
parent b4f423eac0
commit 9251d3e155

View File

@@ -1,6 +1,7 @@
import { amountToInteger } from '../utils.js';
import { amountToInteger, printIban } from '../utils.js';
import Fallback from './integration-bank.js';
import { formatPayeeName } from '../../util/payee-name.js';
/** @type {import('./bank.interface.js').IBank} */
export default {
@@ -8,6 +9,31 @@ 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, editedTransaction = null) {
const trans = editedTransaction ?? transaction;
const date =
trans.date ||
transaction.valueDate || // swapped this
transaction.valueDateTime ||
transaction.bookingDate || // with that
transaction.bookingDateTime;
trans.date = date;
return Fallback.normalizeTransaction(transaction, _booked, trans);
},
sortTransactions(transactions = []) {
return transactions.sort(
(a, b) => Number(b.transactionId) - Number(a.transactionId),