fix pending transaction
This commit is contained in:
@@ -58,4 +58,71 @@ Datum,Naam / Omschrijving,Rekening,Tegenrekening,Code,Af Bij,Bedrag (EUR),Mutati
|
||||
);
|
||||
expect(isSameTransaction(api, csv), isTrue);
|
||||
});
|
||||
|
||||
test('API merge drops stale pending not returned by the bank', () {
|
||||
const stalePending = BankTransaction(
|
||||
date: '2026-09-01',
|
||||
description: 'AH CAMPUS DIEMEN',
|
||||
amount: -12.5,
|
||||
currency: 'EUR',
|
||||
pending: true,
|
||||
);
|
||||
const settled = BankTransaction(
|
||||
date: '2026-09-03',
|
||||
description: 'BCK*AH CAMPUS DIEMEN ZUID NLD',
|
||||
amount: -12.5,
|
||||
currency: 'EUR',
|
||||
pending: false,
|
||||
);
|
||||
const olderBooked = BankTransaction(
|
||||
date: '2026-08-01',
|
||||
description: 'SALARIS',
|
||||
amount: 2000,
|
||||
currency: 'EUR',
|
||||
pending: false,
|
||||
);
|
||||
|
||||
final merged = mergeApiTransactionsWithCache(
|
||||
[settled],
|
||||
[stalePending, olderBooked],
|
||||
);
|
||||
|
||||
expect(merged, hasLength(2));
|
||||
expect(merged.any((tx) => tx.pending), isFalse);
|
||||
expect(merged.any((tx) => tx.description.contains('SALARIS')), isTrue);
|
||||
expect(merged.any((tx) => tx.description.contains('AH CAMPUS')), isTrue);
|
||||
});
|
||||
|
||||
test('API merge keeps live pending from the feed', () {
|
||||
const livePending = BankTransaction(
|
||||
date: '2026-09-10',
|
||||
description: 'PENDING COFFEE',
|
||||
amount: -4.0,
|
||||
currency: 'EUR',
|
||||
pending: true,
|
||||
);
|
||||
final merged = mergeApiTransactionsWithCache([livePending], const []);
|
||||
expect(merged, hasLength(1));
|
||||
expect(merged.single.pending, isTrue);
|
||||
});
|
||||
|
||||
test('dropSettledPendingDuplicates removes pending twin of booked', () {
|
||||
const pending = BankTransaction(
|
||||
date: '2026-09-01',
|
||||
description: 'AH CAMPUS DIEMEN',
|
||||
amount: -12.5,
|
||||
currency: 'EUR',
|
||||
pending: true,
|
||||
);
|
||||
const booked = BankTransaction(
|
||||
date: '2026-09-02',
|
||||
description: 'BCK*AH CAMPUS DIEMEN ZUID',
|
||||
amount: -12.5,
|
||||
currency: 'EUR',
|
||||
pending: false,
|
||||
);
|
||||
final cleaned = dropSettledPendingDuplicates([pending, booked]);
|
||||
expect(cleaned, hasLength(1));
|
||||
expect(cleaned.single.pending, isFalse);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user