feat: Site orders carry DTF-<n> as Tiny's numeroPedidoEcommerce
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 3m47s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m14s

Dropstar asked on 2026-10-23 for the Kanban number in numeroPedidoEcommerce.
It goes there on every order now, next to numeroOrdemCompra, which the
resend check still searches. Tiny's v3 model takes the e-commerce block
without a channel id; TINY_ECOMMERCE_ID adds one and can now be set in the
stack. The supervised test order reads the number back from Tiny and fails
if Tiny did not keep it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-26 11:47:21 -03:00
parent 88819c3a5f
commit 93cb289940
5 changed files with 45 additions and 7 deletions

View File

@@ -198,11 +198,19 @@ def pedido(orders, payload, confirm, out, wait=time.sleep):
out(f'FALHA: a busca por {tiny.purchase_order(payload["number"])} não encontrou o pedido. '
'Um reenvio criaria um duplicado; o 2º envio não foi feito.')
return False
# What Tiny kept of the e-commerce number, read back from the order.
wanted = tiny.purchase_order(payload['number'])
shop = orders.request('GET', f"/pedidos/{first['tiny_id']}").get('ecommerce') or {}
out(f"E-commerce no Tiny: numeroPedidoEcommerce {shop.get('numeroPedidoEcommerce') or '(vazio)'}" +
(f" · canal {shop.get('nome') or '?'} (id {shop['id']})" if shop.get('id') else ' · sem canal'))
numbered = shop.get('numeroPedidoEcommerce') == wanted
if not numbered:
out(f'FALHA: o Tiny não guardou {wanted} em numeroPedidoEcommerce.')
second = orders.deliver('teste-integracao', payload)
out(f"2º envio: {second['status']} · Tiny id {second['tiny_id']}")
passed = second['status'] == 'already-created' and second['tiny_id'] == first['tiny_id']
out('OK: o reenvio encontrou o mesmo pedido.' if passed else 'FALHA: o reenvio não devolveu o mesmo pedido.')
return passed
found_again = second['status'] == 'already-created' and second['tiny_id'] == first['tiny_id']
out('OK: o reenvio encontrou o mesmo pedido.' if found_again else 'FALHA: o reenvio não devolveu o mesmo pedido.')
return numbered and found_again
finally:
# Whatever happened above, the test order does not stay open.
cancelar(orders, first['tiny_id'], out)