fix: a quote held by a test order says so, and its panel closes

Sentry DTF-WEB-D: after "Criar pedido de teste" the quote panel kept
offering "Pedido pago fora do site", and the register answered "Esta
cotação já virou o pedido #N" without saying it was the test order.
The message now names the test order and says to delete it to register
the payment; creating the test order closes the quote panel.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-16 11:28:48 -03:00
parent 392a21082e
commit e8423bec45
3 changed files with 12 additions and 1 deletions

View File

@@ -136,6 +136,11 @@ def register_order(uid: UUID, body: PaidOutside, user=Depends(can('enter'))):
'status': 'paid', 'total_cents': quote['approved']['total_cents'], 'operator': user}
order, created = payments.create_order(c, quote, receipt, body.origin)
if not created:
# A test order holds the quote too (orders.quote_id is unique): say so,
# and how to free it (Sentry DTF-WEB-D).
if payments.is_test(order):
raise HTTPException(409, f"Esta cotação já virou o pedido de teste #{order['number']}. "
'Exclua o pedido de teste para registrar o pagamento.')
raise HTTPException(409, f"Esta cotação já virou o pedido #{order['number']}.")
audit('manual_order_registered', order=str(order['id']), origin=body.origin, operator=user)
return order