Add AI batch reconciliation for accessibility bills
This commit is contained in:
@@ -951,6 +951,37 @@ class LocalDatabase {
|
||||
return transaction(id, includeDeleted: true)!;
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> createTransactionsBatch(
|
||||
List<Map<String, dynamic>> values, {
|
||||
bool enqueueSyncChanges = false,
|
||||
}) {
|
||||
_db.execute('BEGIN');
|
||||
try {
|
||||
final created = <Map<String, dynamic>>[];
|
||||
for (final value in values) {
|
||||
final clientRequestId = value['clientRequestId'] as String?;
|
||||
final existed =
|
||||
clientRequestId != null &&
|
||||
clientRequestId.isNotEmpty &&
|
||||
_db.select(
|
||||
'SELECT 1 FROM transactions WHERE client_request_id = ? LIMIT 1',
|
||||
[clientRequestId],
|
||||
).isNotEmpty;
|
||||
final transaction = createTransaction(value);
|
||||
created.add(transaction);
|
||||
final id = (transaction['id'] as num).toInt();
|
||||
if (enqueueSyncChanges && id < 0 && !existed) {
|
||||
enqueueSync('transaction', id, 'create', value);
|
||||
}
|
||||
}
|
||||
_db.execute('COMMIT');
|
||||
return created;
|
||||
} catch (_) {
|
||||
_db.execute('ROLLBACK');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic>? transaction(int id, {bool includeDeleted = false}) {
|
||||
final rows = _db.select(
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user