ing csv import

This commit is contained in:
davmar
2026-09-08 12:58:32 +02:00
parent 21df7b0085
commit e7a7b1a357
14 changed files with 1271 additions and 541 deletions
+36
View File
@@ -141,6 +141,42 @@ class StorageService {
return _prefs.remove(StorageKeys.bankCache);
}
List<BankTransaction> loadImportedTransactions() {
final raw = _prefs.getString(StorageKeys.importedTransactions);
if (raw == null || raw.isEmpty) return const [];
try {
final decoded = jsonDecode(raw);
if (decoded is! List) return const [];
return decoded
.whereType<Map>()
.map((e) => BankTransaction.fromJson(Map<String, dynamic>.from(e)))
.toList(growable: false);
} catch (_) {
return const [];
}
}
Future<void> saveImportedTransactions(List<BankTransaction> txs) {
final encoded = [
for (final tx in txs)
{
'date': tx.date,
'description': tx.description,
'amount': tx.amount,
'currency': tx.currency,
'pending': tx.pending,
},
];
return _prefs.setString(
StorageKeys.importedTransactions,
jsonEncode(encoded),
);
}
Future<void> clearImportedTransactions() {
return _prefs.remove(StorageKeys.importedTransactions);
}
TxMetaStoreData loadTxMetaStore() {
final raw = _prefs.getString(StorageKeys.txMeta);
if (raw != null && raw.isNotEmpty) {