ing csv import
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user