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
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:
@@ -264,6 +264,37 @@ class TinyStatusTests(FakeTinyCase):
|
||||
self.assertEqual(ready['status'], 'not-applicable')
|
||||
self.assertEqual(self.calls, [])
|
||||
|
||||
@mock.patch.dict(os.environ, {'TINY_STATUS_UPDATES': 'true'})
|
||||
def test_printing_is_preparando_envio_but_never_moves_an_invoiced_order_back(self):
|
||||
sale = self.tiny.deliver('k1', PAID)
|
||||
started = {**READY, 'event': 'production_started', 'order': PAID['order'], 'tiny_id': sale['tiny_id']}
|
||||
moved = self.tiny.deliver('k2', started)
|
||||
self.assertEqual((moved['status'], moved['situacao'], self.orders[0]['situacao']),
|
||||
('status-updated', 'Preparando envio', 4))
|
||||
self.orders[0]['situacao'] = 1 # the team invoiced it
|
||||
self.assertEqual(self.tiny.deliver('k2', started)['status'], 'status-unchanged')
|
||||
self.assertEqual(self.orders[0]['situacao'], 1)
|
||||
|
||||
@mock.patch.dict(os.environ, {'TINY_STATUS_UPDATES': 'true'})
|
||||
def test_a_cancelled_order_is_cancelled_in_tiny_unless_invoiced(self):
|
||||
self.tiny.deliver('k1', PAID)
|
||||
cancelled = {**READY, 'event': 'cancelled', 'order': PAID['order']}
|
||||
done = self.tiny.deliver('k3', cancelled)
|
||||
self.assertEqual((done['status'], done['situacao'], self.orders[0]['situacao']),
|
||||
('status-updated', 'Cancelada', 2))
|
||||
self.orders[0]['situacao'] = 1
|
||||
kept = self.tiny.deliver('k3', cancelled)
|
||||
self.assertEqual((kept['status'], kept['situacao'], self.orders[0]['situacao']),
|
||||
('status-unchanged', 'Faturada', 1))
|
||||
|
||||
def test_printing_and_cancelling_change_nothing_while_status_updates_are_off(self):
|
||||
self.tiny.deliver('k1', PAID)
|
||||
self.calls.clear()
|
||||
for event in ('production_started', 'cancelled'):
|
||||
self.assertEqual(self.tiny.deliver('k', {**READY, 'event': event, 'order': PAID['order']})['status'],
|
||||
'not-applicable')
|
||||
self.assertEqual(self.calls, [])
|
||||
|
||||
def test_pickup_orders_carry_the_pickup_forma_de_envio(self):
|
||||
self.assertEqual(order_payload(PICKUP, 1)['transportador'], {'formaEnvio': {'id': 77}})
|
||||
self.assertNotIn('transportador', order_payload(PAID, 1))
|
||||
|
||||
Reference in New Issue
Block a user