feat: Dropflow orders reach Tiny in DTF DROPFLOW, and dinheiro and customer credit name their forma de recebimento
All checks were successful
Build and deploy / Validate source (push) Successful in 13s
Build and deploy / Integration suite on a real stack (push) Successful in 4m40s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Successful in 1m27s

Marcus's ids of 2026-10-27: the revenue category DTF DROPFLOW (987032506)
for Dropflow orders, which no longer stay out of Tiny, and the formas de
recebimento Dinheiro (919478944) and CORREÇÃO DTF (977493654) for the
customer's credit, on orders the team registers as paid outside the site.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-27 15:38:33 -03:00
parent 5692804c6f
commit 258128de9f
5 changed files with 36 additions and 19 deletions

View File

@@ -181,14 +181,17 @@ def run():
with db.connect() as c:
sent = c.execute("SELECT payload FROM dtf_local.outbox WHERE event_key=%s", (order['id'] + ':paid:tiny',)).fetchone()
assert sent and sent['payload']['origin'] == 'atendimento' and sent['payload']['payment'] == {'method': 'cash', 'outside': True}, sent
# A Dropflow batch stays out of Tiny until its revenue category exists, cancelled or not.
# A Dropflow batch reaches Tiny too, carrying its origin for its own category; and its cancel.
_, batch_quote, _ = reviewed_quote()
batch = register(batch_quote, {'origin': 'dropflow', 'method': 'credit'})
board.call('/operator/orders/' + batch['id'] + '/cancel', {'note': 'Lote refeito'}, operator=True)
with db.connect() as c:
held = c.execute("SELECT count(*) AS n FROM dtf_local.outbox WHERE event_key LIKE %s", (batch['id'] + ':%',)).fetchone()['n']
assert batch['origin'] == 'dropflow' and held == 0, (batch, held)
print('PASS: an order paid outside is registered with its origin and payment; Dropflow stays out of Tiny')
events = {r['event_key']: r['payload'] for r in c.execute(
"SELECT event_key, payload FROM dtf_local.outbox WHERE event_key LIKE %s", (batch['id'] + ':%',)).fetchall()}
paid = events.get(batch['id'] + ':paid:tiny')
assert batch['origin'] == 'dropflow' and paid and paid['origin'] == 'dropflow', (batch, events)
assert batch['id'] + ':cancelled:tiny' in events, events
print('PASS: an order paid outside is registered with its origin and payment, Dropflow ones included')
# Files are uploaded before payment. An unpaid cart keeps them briefly; a
# paid order keeps them for its 30 days; a payment never starts for files

View File

@@ -372,14 +372,24 @@ class TinyStatusTests(FakeTinyCase):
self.assertNotIn('vendedor', plain)
self.assertTrue(plain['observacoesInternas'].startswith('Site DTF · pago · '))
# An order the team registered (D-35): its origin, and how it was paid
# outside the site; Pix and card still name Tiny's forma de recebimento.
# outside the site, each way named as Tiny's forma de recebimento.
counter = order_payload({**PAID, 'origin': 'atendimento', 'payment': {'method': 'cash', 'outside': True}},
1, thursday, shipping=self.tiny.shipping)
self.assertTrue(counter['observacoesInternas'].startswith('Atendimento DTF · pago fora do site (dinheiro) · '))
self.assertEqual(counter['pagamento'], {'categoria': {'id': CATEGORY}})
self.assertEqual(counter['pagamento']['categoria'], {'id': CATEGORY})
self.assertEqual(counter['pagamento']['formaRecebimento'], {'id': RECEIPT_METHODS['cash']})
pix = order_payload({**PAID, 'origin': 'atendimento', 'payment': {'method': 'pix', 'outside': True}},
1, thursday, shipping=self.tiny.shipping)
self.assertEqual(pix['pagamento']['formaRecebimento'], {'id': RECEIPT_METHODS['pix']})
self.assertEqual(pix['pagamento']['categoria'], {'id': CATEGORY})
# Dinheiro and the customer's credit (CORREÇÃO DTF), Marcus's ids of 2026-10-27.
self.assertEqual((RECEIPT_METHODS['cash'], RECEIPT_METHODS['credit']), (919478944, 977493654))
# A Dropflow order goes in DTF DROPFLOW, not DTF SITE (D-21).
batch = order_payload({**PAID, 'origin': 'dropflow', 'payment': {'method': 'credit', 'outside': True}},
1, thursday, shipping=self.tiny.shipping)
self.assertEqual(batch['pagamento']['categoria'], {'id': 987032506})
self.assertEqual(batch['pagamento']['formaRecebimento'], {'id': 977493654})
self.assertTrue(batch['observacoesInternas'].startswith('Dropflow DTF · pago fora do site (crédito do cliente) · '))
def test_the_order_is_tagged_kanbandtf_once(self):
first = self.tiny.deliver('k1', PAID)