62 lines
2.1 KiB
Dart
62 lines
2.1 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:myapp/models/bank.dart';
|
|
import 'package:myapp/services/ing_csv_import.dart';
|
|
|
|
void main() {
|
|
test('parses ING Dutch semicolon CSV with Af/Bij and YYYYMMDD', () {
|
|
const raw = '''
|
|
"Datum";"Naam / Omschrijving";"Rekening";"Tegenrekening";"Code";"Af Bij";"Bedrag (EUR)";"Mutatiesoort";"Mededelingen"
|
|
"20260901";"AH CAMPUS DIEMEN";"NL00INGB0000000000";"";"GT";"Af";"12,50";"Betaalautomaat";"Pasvolgnr: 001"
|
|
"20260902";"SALARIS";"NL00INGB0000000000";"NL00ABCD";"OV";"Bij";"2000,00";"Overboeking";"Salaris september"
|
|
''';
|
|
final txs = parseIngCsv(raw);
|
|
expect(txs, hasLength(2));
|
|
expect(txs[0].date, '2026-09-01');
|
|
expect(txs[0].amount, -12.5);
|
|
expect(txs[0].description, contains('AH CAMPUS'));
|
|
expect(txs[1].date, '2026-09-02');
|
|
expect(txs[1].amount, 2000);
|
|
});
|
|
|
|
test('skips duplicates against existing API-like rows', () {
|
|
final existing = [
|
|
const BankTransaction(
|
|
date: '2026-09-01',
|
|
description:
|
|
'BCK*AH CAMPUS DIEMEN ZUID NLD Pasvolgnr: 001 Transactie: C00338',
|
|
amount: -12.5,
|
|
currency: 'EUR',
|
|
pending: false,
|
|
),
|
|
];
|
|
const raw = '''
|
|
Datum,Naam / Omschrijving,Rekening,Tegenrekening,Code,Af Bij,Bedrag (EUR),Mutatiesoort,Mededelingen
|
|
20260901,AH CAMPUS DIEMEN,,,,Af,"12,50",Betaalautomaat,Pasvolgnr: 001
|
|
20260903,JUMBO,,,,Af,"8,00",Betaalautomaat,
|
|
''';
|
|
final result = importIngCsvAgainst(raw: raw, existing: existing);
|
|
expect(result.parsed, 2);
|
|
expect(result.skippedDuplicates, 1);
|
|
expect(result.added, hasLength(1));
|
|
expect(result.added.single.description, contains('JUMBO'));
|
|
});
|
|
|
|
test('isSameTransaction matches merchant fingerprints', () {
|
|
const api = BankTransaction(
|
|
date: '2026-09-01',
|
|
description: 'BCK*AH CAMPUS DIEMEN ZUID NLD Pasvolgnr: 001 Transactie: X',
|
|
amount: -3.5,
|
|
currency: 'EUR',
|
|
pending: false,
|
|
);
|
|
const csv = BankTransaction(
|
|
date: '2026-09-01',
|
|
description: 'AH CAMPUS DIEMEN · Pasvolgnr: 001',
|
|
amount: -3.5,
|
|
currency: 'EUR',
|
|
pending: false,
|
|
);
|
|
expect(isSameTransaction(api, csv), isTrue);
|
|
});
|
|
}
|