From e8423bec4532568f858b3b7db546e5effcdb9c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Mon, 16 Nov 2026 11:28:48 -0300 Subject: [PATCH] fix: a quote held by a test order says so, and its panel closes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- app/api/operator/quotes.py | 5 +++++ tests/payment_test.py | 4 ++++ web/kanban-quotes.js | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/api/operator/quotes.py b/app/api/operator/quotes.py index 6e5e2b5..ecd985b 100644 --- a/app/api/operator/quotes.py +++ b/app/api/operator/quotes.py @@ -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 diff --git a/tests/payment_test.py b/tests/payment_test.py index ebbe3ea..a57e6a4 100644 --- a/tests/payment_test.py +++ b/tests/payment_test.py @@ -151,6 +151,10 @@ def run(): order = tester.call('/operator/quotes/' + test_quote + '/test-order', {}, operator=True) assert order['payment']['provider'] == 'teste' and order['state'] == 'rec', order assert tester.call('/operator/quotes/' + test_quote + '/test-order', {}, operator=True)['id'] == order['id'] + # The quote is that test order's now: registering it names the test order (Sentry DTF-WEB-D). + refused = tester.call('/operator/quotes/' + test_quote + '/register', {'origin': 'atendimento', 'method': 'cash'}, + operator=True, expected=409) + assert 'pedido de teste #' + str(order['number']) in refused['detail'], refused version = order['version'] # Arte conferida, the print queue, takes the order once its final is approved. from tests.smoke_test import final_png_bytes diff --git a/web/kanban-quotes.js b/web/kanban-quotes.js index b9b0499..832fa4a 100644 --- a/web/kanban-quotes.js +++ b/web/kanban-quotes.js @@ -196,7 +196,9 @@ function review(quote){ const test=button('Criar pedido de teste',async()=>{ if(!await ask('Criar um pedido de teste?','Ele entra em Arte recebida sem cobrar nada e não vai para o Tiny.','Criar pedido de teste'))return; const order=await api('/quotes/'+quote.id+'/test-order',{}); - say('Pedido de teste #'+order.number+' criado em Arte recebida.');await load(); + // The quote is now that test order's: it leaves the list, and its + // panel closes so nobody registers it again (Sentry DTF-WEB-D). + currentQuote=null;say('Pedido de teste #'+order.number+' criado em Arte recebida.');await load(); },'btn'); foot.append(test); if(chat)foot.append(chat);