Skip to content

A local-first personal finance app

SSK_DUSSELDORF_DUSSDEDDXXX: remove non-booked transactions from import (#553)

Denna0312f516ad28
diff --git a/src/app-gocardless/banks/ssk_dusseldorf_dussdeddxxx.js b/src/app-gocardless/banks/ssk_dusseldorf_dussdeddxxx.js
index 1de9f4848d..b196afe443 100644
--- a/src/app-gocardless/banks/ssk_dusseldorf_dussdeddxxx.js
+++ b/src/app-gocardless/banks/ssk_dusseldorf_dussdeddxxx.js
@@ -7,6 +7,18 @@ export default {
institutionIds: ['SSK_DUSSELDORF_DUSSDEDDXXX'],
normalizeTransaction(transaction, _booked) {
+ // If the transaction is not booked yet by the bank, don't import it.
+ // Reason being that the transaction doesn't have the information yet
+ // to make the payee and notes field be of any use. It's filled with
+ // a placeholder text and wouldn't be corrected on the next sync.
+ if (!_booked) {
+ console.debug(
+ 'Skipping unbooked transaction:',
+ transaction.transactionId,
+ );
+ return null;
+ }
+
// Prioritize unstructured information, falling back to structured formats
let remittanceInformationUnstructured =
transaction.remittanceInformationUnstructured ??
@@ -14,10 +26,12 @@ export default {
transaction.remittanceInformationStructuredArray?.join(' ');
if (transaction.additionalInformation)
- remittanceInformationUnstructured =
- (remittanceInformationUnstructured ?? '') +
- ' ' +
- transaction.additionalInformation;
+ remittanceInformationUnstructured = [
+ remittanceInformationUnstructured,
+ transaction.additionalInformation,
+ ]
+ .filter(Boolean)
+ .join(' ');
const usefulCreditorName =
transaction.ultimateCreditor ||
diff --git a/src/app-gocardless/banks/tests/ssk_dusseldorf_dussdeddxxx.spec.js b/src/app-gocardless/banks/tests/ssk_dusseldorf_dussdeddxxx.spec.js
new file mode 100644
index 0000000000..d04f8daeae
--- /dev/null
+++ b/src/app-gocardless/banks/tests/ssk_dusseldorf_dussdeddxxx.spec.js
@@ -0,0 +1,101 @@
+import { jest } from '@jest/globals';
+import SskDusseldorfDussdeddxxx from '../ssk_dusseldorf_dussdeddxxx.js';
+
+describe('ssk_dusseldorf_dussdeddxxx', () => {
+ let consoleSpy;
+
+ beforeEach(() => {
+ consoleSpy = jest.spyOn(console, 'debug');
+ });
+
+ afterEach(() => {
+ consoleSpy.mockRestore();
+ });
+
+ describe('#normalizeTransaction', () => {
+ const bookedTransactionOne = {
+ transactionId: '2024102900000000-1',
+ bookingDate: '2024-10-29',
+ valueDate: '2024-10-29',
+ transactionAmount: {
+ amount: '-99.99',
+ currency: 'EUR',
+ },
+ creditorName: 'a useful creditor name',
+ remittanceInformationStructured: 'structured information',
+ remittanceInformationUnstructured: 'unstructured information',
+ additionalInformation: 'some additional information',
+ };
+
+ const bookedTransactionTwo = {
+ transactionId: '2024102900000000-2',
+ bookingDate: '2024-10-29',
+ valueDate: '2024-10-29',
+ transactionAmount: {
+ amount: '-99.99',
+ currency: 'EUR',
+ },
+ creditorName: 'a useful creditor name',
+ ultimateCreditor: 'ultimate creditor',
+ remittanceInformationStructured: 'structured information',
+ additionalInformation: 'some additional information',
+ };
+
+ it('properly combines remittance information', () => {
+ expect(
+ SskDusseldorfDussdeddxxx.normalizeTransaction(
+ bookedTransactionOne,
+ true,
+ ).remittanceInformationUnstructured,
+ ).toEqual('unstructured information some additional information');
+
+ expect(
+ SskDusseldorfDussdeddxxx.normalizeTransaction(
+ bookedTransactionTwo,
+ true,
+ ).remittanceInformationUnstructured,
+ ).toEqual('structured information some additional information');
+ });
+
+ it('prioritizes creditor names correctly', () => {
+ expect(
+ SskDusseldorfDussdeddxxx.normalizeTransaction(
+ bookedTransactionOne,
+ true,
+ ).payeeName,
+ ).toEqual('A Useful Creditor Name');
+
+ expect(
+ SskDusseldorfDussdeddxxx.normalizeTransaction(
+ bookedTransactionTwo,
+ true,
+ ).payeeName,
+ ).toEqual('Ultimate Creditor');
+ });
+
+ const unbookedTransaction = {
+ transactionId: '2024102900000000-1',
+ valueDate: '2024-10-29',
+ transactionAmount: {
+ amount: '-99.99',
+ currency: 'EUR',
+ },
+ creditorName: 'some nonsensical creditor',
+ remittanceInformationUnstructured: 'some nonsensical information',
+ };
+
+ it('returns null for unbooked transactions', () => {
+ expect(
+ SskDusseldorfDussdeddxxx.normalizeTransaction(
+ unbookedTransaction,
+ false,
+ ),
+ ).toBeNull();
+
+ expect(consoleSpy).toHaveBeenCalledWith(
+ 'Skipping unbooked transaction:',
+ unbookedTransaction.transactionId,
+ );
+ });
+ });
+});
diff --git a/upcoming-release-notes/553.md b/upcoming-release-notes/553.md
new file mode 100644
index 0000000000..0f6ee353e8
--- /dev/null
+++ b/upcoming-release-notes/553.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [DennaGherlyn]
+---
+
+Remove non-booked transactions from import of SSK_DUSSELDORF_DUSSDEDDXXX due to placeholder text in the payee and notes field
\ No newline at end of file