feat: Tiny follows printing and cancellation
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Publish images (push) Has been cancelled
Build and deploy / Secret scan and release gate (push) Has been cancelled
Build and deploy / Integration suite on a real stack (push) Has been cancelled

With TINY_STATUS_UPDATES on, an order entering Imprimindo becomes
"Preparando envio" in Tiny, and a cancelled order "Cancelada", next to the
"Aprovada" on payment and the pickup "Pronto para envio" there already.
Neither sends a WhatsApp in the client's n8n. An order the team already
moved further in Tiny is never moved back, and an invoiced one is not
cancelled here: its nota fiscal is cancelled in Tiny. Cancelling a paid
order now tells Tiny, which it did not before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-16 18:45:23 -03:00
parent 1f2358c8b5
commit dbf1efc112
5 changed files with 77 additions and 13 deletions

View File

@@ -72,6 +72,12 @@ def run():
board = client.call('/operator/board', operator=True)
order = next(o for o in board['orders'] if o['id'] == str(paid_order))
assert order['cancelled_at'] and order['cancel_reason'] == 'Cliente desistiu'
# Tiny is told, once (app/tiny.py cancels it there while not invoiced).
with db.connect() as c:
told = c.execute("SELECT provider,payload FROM dtf_local.outbox WHERE event_key=%s",
(f'{paid_order}:cancelled:tiny',)).fetchall()
assert [(t['provider'], t['payload']['event'], t['payload']['reason']) for t in told] == \
[('tiny', 'cancelled', 'Cliente desistiu')], told
# The automatic folder hears it is cancelled, and so removes its files.
held = client.call('/operator/queue/folder', {'early': True, 'held': [str(paid_order)]}, operator=True)
assert held['states'] == {str(paid_order): 'cancelled'}, held['states']