fix: customer credit reaches Tiny as CREDITO PRE-PAGO, with its own marcador beside SITE DTF (#42)
All checks were successful
Build and deploy / Validate source (push) Successful in 7s
Build and deploy / Integration suite on a real stack (push) Successful in 7m45s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m25s

Marcus, 2026-11-18: "Pago fora do site › Crédito do cliente" maps to the
forma de recebimento CREDITO PRE-PAGO (987762591), and the order also
gets the marcador CREDITO PRE-PAGO. CORREÇÃO DTF, refused by Tiny for
#42, is for correction orders only. A retry adds only the marcadores
the order is missing.

The outbox computes the forma when it delivers, so #42's queued sale
goes through on its next retry after the deploy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-18 12:24:21 -03:00
parent a52856f3f6
commit b3ecba590b
2 changed files with 41 additions and 15 deletions

View File

@@ -455,13 +455,14 @@ class TinyStatusTests(FakeTinyCase):
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))
# Dinheiro (Marcus, 2026-10-27) and the customer's credit, CREDITO
# PRE-PAGO (Marcus, 2026-11-18; no longer CORREÇÃO DTF).
self.assertEqual((RECEIPT_METHODS['cash'], RECEIPT_METHODS['credit']), (919478944, 987762591))
# 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.assertEqual(batch['pagamento']['formaRecebimento'], {'id': 987762591})
self.assertTrue(batch['observacoesInternas'].startswith('Dropflow DTF · pago fora do site (crédito do cliente) · '))
def test_the_order_is_tagged_kanbandtf_once(self):
@@ -474,6 +475,18 @@ class TinyStatusTests(FakeTinyCase):
self.assertEqual(len(self.orders), 1)
self.assertEqual(self.tags[tiny_id], [{'descricao': 'SITE DTF'}])
def test_customer_credit_also_carries_the_credito_pre_pago_marcador(self):
credit = {**PAID, 'payment': {'method': 'credit', 'outside': True}}
first = self.tiny.deliver('k1', credit)
self.assertEqual(first['marcador'], 'SITE DTF, CREDITO PRE-PAGO')
tiny_id = self.orders[0]['id']
self.assertEqual(self.orders[0]['pagamento']['formaRecebimento'], {'id': 987762591})
self.assertEqual(self.tags[tiny_id], [{'descricao': 'SITE DTF'}, {'descricao': 'CREDITO PRE-PAGO'}])
# A retry adds only what is missing.
self.tags[tiny_id] = [{'descricao': 'SITE DTF'}]
self.tiny.deliver('k1', credit)
self.assertEqual(self.tags[tiny_id], [{'descricao': 'SITE DTF'}, {'descricao': 'CREDITO PRE-PAGO'}])
def test_a_failed_tag_is_retried_without_a_second_order(self):
self.refuse_tag = 1
with self.assertRaises(TinyError):