admin user able to create test txs
This commit is contained in:
@@ -648,6 +648,7 @@ class PbSyncService {
|
||||
8,
|
||||
),
|
||||
'pending': tx.pending,
|
||||
'is_manual': tx.isManual,
|
||||
};
|
||||
final remote = existing[syncId];
|
||||
if (remote == null) {
|
||||
@@ -699,6 +700,7 @@ class PbSyncService {
|
||||
? 'EUR'
|
||||
: r.getStringValue('currency'),
|
||||
pending: r.getBoolValue('pending'),
|
||||
isManual: r.getBoolValue('is_manual'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -715,7 +717,30 @@ class PbSyncService {
|
||||
(remoteAmount * 100).round() == (tx.amount * 100).round() &&
|
||||
remote.getStringValue('currency').toUpperCase() ==
|
||||
tx.currency.toUpperCase() &&
|
||||
remote.getBoolValue('pending') == tx.pending;
|
||||
remote.getBoolValue('pending') == tx.pending &&
|
||||
remote.getBoolValue('is_manual') == tx.isManual;
|
||||
}
|
||||
|
||||
/// Deletes remote bank rows by local [BankTransaction.id] (tx_id field).
|
||||
Future<String> deleteTransactionsByTxIds(Iterable<String> txIds) async {
|
||||
final ids = {
|
||||
for (final id in txIds)
|
||||
if (_clip(id, 2000).isNotEmpty) _clip(id, 2000),
|
||||
};
|
||||
if (ids.isEmpty) return 'Bank txs: nothing to delete';
|
||||
|
||||
final userId = _userId;
|
||||
final filter = 'user="$userId"';
|
||||
final existing = await _fullList('transactions', filter);
|
||||
final ops = <_BatchOp>[
|
||||
for (final r in existing)
|
||||
if (ids.contains(r.getStringValue('tx_id'))) _BatchOp.delete(r.id),
|
||||
];
|
||||
if (ops.isEmpty) {
|
||||
return 'Bank txs: 0 remote deletes (ids ${ids.length})';
|
||||
}
|
||||
await _runWriteOps('transactions', ops);
|
||||
return 'Bank txs: deleted ${ops.length} remote row(s)';
|
||||
}
|
||||
|
||||
Future<void> _runOne(String collection, _BatchOp op) {
|
||||
|
||||
@@ -65,14 +65,7 @@ class BankCache {
|
||||
'balanceType': balance!.balanceType,
|
||||
},
|
||||
'transactions': [
|
||||
for (final tx in transactions)
|
||||
{
|
||||
'date': tx.date,
|
||||
'description': tx.description,
|
||||
'amount': tx.amount,
|
||||
'currency': tx.currency,
|
||||
'pending': tx.pending,
|
||||
},
|
||||
for (final tx in transactions) tx.toJson(),
|
||||
],
|
||||
};
|
||||
|
||||
@@ -258,16 +251,7 @@ class StorageService {
|
||||
}
|
||||
|
||||
Future<void> saveImportedTransactions(List<BankTransaction> txs) async {
|
||||
final encoded = [
|
||||
for (final tx in txs)
|
||||
{
|
||||
'date': tx.date,
|
||||
'description': tx.description,
|
||||
'amount': tx.amount,
|
||||
'currency': tx.currency,
|
||||
'pending': tx.pending,
|
||||
},
|
||||
];
|
||||
final encoded = [for (final tx in txs) tx.toJson()];
|
||||
final json = await compute(jsonEncode, encoded);
|
||||
await _prefs.setString(StorageKeys.importedTransactions, json);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user