feat: the team registers an order paid outside the site, choosing its origin and payment (Dropstar's rule D-35)
Some checks failed
Build and deploy / Integration suite on a real stack (push) Failing after 3m26s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Has been skipped
Build and deploy / Validate source (push) Successful in 6s

On an approved quote in Cotacoes, Administrador, Gestao and Vendedor pick
the origin (Site, Dropflow, Atendimento) and how it was paid (Pix, cartao,
dinheiro, credito do cliente), neither preselected, with an optional note.
The price is the quote's, the Site's table price. The order is marked paid
outside, counts in Numeros, and goes to Tiny like a Site order with the
payment named in its internal note; a Dropflow order stays out of Tiny,
status updates and cancelling included, until its revenue category exists.
Auto-refresh waits while a register form on screen is half filled in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-27 12:36:40 -03:00
parent 0319039328
commit c45e5f732b
12 changed files with 176 additions and 23 deletions

View File

@@ -92,6 +92,18 @@ SITUACOES = {0: 'Aberta', 3: 'Aprovada', 4: 'Preparando envio', 1: 'Faturada', 7
# react to these situações. Off until go-live: while n8n still sends the
# designer message for DTFIMP products on "Aprovado", setting it would reach
# Site customers.
# Where the order came from (D-21) and, when the team registered it, how it was
# paid outside the system (D-35), for whoever reads the order in Tiny.
ORIGIN_NOTES = {'site': 'Site DTF', 'atendimento': 'Atendimento DTF', 'dropflow': 'Dropflow DTF'}
OUTSIDE_NOTES = {'pix': 'Pix', 'card': 'cartão', 'cash': 'dinheiro', 'credit': 'crédito do cliente'}
def internal_note(payload):
paid = payload.get('payment') or {}
how = f"pago fora do site ({OUTSIDE_NOTES.get(paid.get('method'), paid.get('method'))})" if paid.get('outside') else 'pago'
return f"{ORIGIN_NOTES.get(payload.get('origin') or 'site')} · {how} · {payload['order_id']}"
STATUS_UPDATES_SETTING = 'TINY_STATUS_UPDATES'
# The client's custom "retirar pessoalmente" forma de envio (v2 code X), which
# the pickup notice is keyed on. Found in Tiny by name; this setting, an id,
@@ -482,7 +494,7 @@ def order_payload(payload, contact_id, today=None, product_id=None, shipping=Non
'itens': items,
'valorFrete': money(freight['total_cents']),
'observacoes': f"Pedido DTF #{payload['number']}" + (' · retirada em Franca' if pickup else ''),
'observacoesInternas': f"Site DTF · pago · {payload['order_id']}"}
'observacoesInternas': internal_note(payload)}
carrier = shipping(service) if shipping else None
if carrier:
pedido['transportador'] = {'fretePorConta': FREIGHT_PAID_BY, **carrier}