fix: deleting a cancelled order keeps its Tiny cancellation, and production without the real Tiny holds the sends
Some checks failed
Some checks failed
- Deleting an order removed its Tiny events, delivered or not: cancelled and deleted before the worker sent it (or with Tiny down), the order stayed open in Tiny. A real order's events now stay; only a test order's go. - With TINY_ADAPTER missing from the production stack, the simulator marked paid orders delivered with made-up receipts, and they had to be queued again by hand. Production now holds the sends (the outbox retries and Sentry is told); with the real Tiny back, the worker sends them at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -50,7 +50,11 @@ def delete_order(uid: UUID, user=Depends(can('manage'))):
|
||||
cards = [r['id'] for r in c.execute('SELECT id FROM dtf_local.orders WHERE parent_id=%s', (uid,)).fetchall()]
|
||||
for table in ('movements', 'order_files', 'print_files'):
|
||||
c.execute(f'DELETE FROM dtf_local.{table} WHERE order_id=ANY(%s)', ([uid] + cards,))
|
||||
c.execute('DELETE FROM dtf_local.outbox WHERE event_key LIKE %s', (f'{uid}:%',))
|
||||
# A real order's Tiny events stay: its cancellation may not have
|
||||
# reached Tiny yet (Tiny down, or deleted at once), and what was sent
|
||||
# stays on record. A test order never goes to Tiny.
|
||||
if test:
|
||||
c.execute('DELETE FROM dtf_local.outbox WHERE event_key LIKE %s', (f'{uid}:%',))
|
||||
c.execute('DELETE FROM dtf_local.orders WHERE id=%s', (uid,))
|
||||
if not test:
|
||||
c.execute('UPDATE dtf_local.quotes SET discarded_at=COALESCE(discarded_at,now()), discarded_by=COALESCE(discarded_by,%s) WHERE id=%s',
|
||||
|
||||
Reference in New Issue
Block a user