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
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:
@@ -63,10 +63,9 @@ OUTSIDE_METHODS = ('pix', 'card', 'cash', 'credit')
|
|||||||
|
|
||||||
|
|
||||||
def in_tiny(order):
|
def in_tiny(order):
|
||||||
"""Whether the order goes to Tiny: not a test, and not a Dropflow order,
|
"""Whether the order goes to Tiny: every order but a test. A Dropflow
|
||||||
held until Dropstar names that channel's revenue category (it must not be
|
order goes in its own revenue category (app/tiny.py, CATEGORIES)."""
|
||||||
DTF SITE, their rules document says)."""
|
return not is_test(order)
|
||||||
return not is_test(order) and order['origin'] != 'dropflow'
|
|
||||||
|
|
||||||
|
|
||||||
# How long a file is kept while nothing has been paid for it. A cart's files
|
# How long a file is kept while nothing has been paid for it. A cart's files
|
||||||
|
|||||||
11
app/tiny.py
11
app/tiny.py
@@ -114,8 +114,10 @@ PICKUP_EXACT = 'retirar pessoalmente'
|
|||||||
# Dropstar's own ids, read from its store orders with app.tiny_probe exemplo
|
# Dropstar's own ids, read from its store orders with app.tiny_probe exemplo
|
||||||
# (2026-10-19). The app may not list formas de recebimento, so these are not
|
# (2026-10-19). The app may not list formas de recebimento, so these are not
|
||||||
# looked up: Pix and credit card, as the store's orders are paid, and the
|
# looked up: Pix and credit card, as the store's orders are paid, and the
|
||||||
# DropStar carrier its pickup orders name.
|
# DropStar carrier its pickup orders name. Dinheiro and, for the customer's
|
||||||
RECEIPT_METHODS = {'pix': 919478952, 'card': 977460722}
|
# credit, Dropstar's own "CORREÇÃO DTF" were sent by Marcus on 2026-10-27, for
|
||||||
|
# the orders the team registers as paid outside the site (D-35).
|
||||||
|
RECEIPT_METHODS = {'pix': 919478952, 'card': 977460722, 'cash': 919478944, 'credit': 977493654}
|
||||||
PICKUP_CARRIER = 761565838
|
PICKUP_CARRIER = 761565838
|
||||||
# Dropstar's answers: the financial category "DTF SITE" (RECEITAS, id sent on
|
# Dropstar's answers: the financial category "DTF SITE" (RECEITAS, id sent on
|
||||||
# 2026-10-26; it goes in pagamento.categoria, and replaced the store's
|
# 2026-10-26; it goes in pagamento.categoria, and replaced the store's
|
||||||
@@ -124,6 +126,9 @@ PICKUP_CARRIER = 761565838
|
|||||||
# POST /pedidos does not take marcadores. Capitals, no accent, no extra
|
# POST /pedidos does not take marcadores. Capitals, no accent, no extra
|
||||||
# space: the string Kondado reads for Power BI.
|
# space: the string Kondado reads for Power BI.
|
||||||
CATEGORY = 986932924
|
CATEGORY = 986932924
|
||||||
|
# Dropflow's orders in their own category, "DTF DROPFLOW" (sent 2026-10-27):
|
||||||
|
# the rules document (D-21) keeps the two channels apart in the financial.
|
||||||
|
CATEGORIES = {'dropflow': 987032506}
|
||||||
TAG = 'SITE DTF'
|
TAG = 'SITE DTF'
|
||||||
# Freight is the sender's (CIF), as on the store's orders.
|
# Freight is the sender's (CIF), as on the store's orders.
|
||||||
FREIGHT_PAID_BY = 'R'
|
FREIGHT_PAID_BY = 'R'
|
||||||
@@ -503,7 +508,7 @@ def order_payload(payload, contact_id, today=None, product_id=None, shipping=Non
|
|||||||
if days is not None:
|
if days is not None:
|
||||||
pedido['dataPrevista'] = business_days_after(day, int(days)).isoformat()
|
pedido['dataPrevista'] = business_days_after(day, int(days)).isoformat()
|
||||||
# Paid at once, in full, as the store's orders: one parcel on the day.
|
# Paid at once, in full, as the store's orders: one parcel on the day.
|
||||||
pedido['pagamento'] = {'categoria': {'id': CATEGORY}}
|
pedido['pagamento'] = {'categoria': {'id': CATEGORIES.get(payload.get('origin'), CATEGORY)}}
|
||||||
received = RECEIPT_METHODS.get((payload.get('payment') or {}).get('method'))
|
received = RECEIPT_METHODS.get((payload.get('payment') or {}).get('method'))
|
||||||
if received:
|
if received:
|
||||||
total = money(order['total_cents'])
|
total = money(order['total_cents'])
|
||||||
|
|||||||
@@ -482,9 +482,11 @@ Still to do (2026-10-26):
|
|||||||
'method', 'note', 'operator'}`; it counts in Números like any paid order and
|
'method', 'note', 'operator'}`; it counts in Números like any paid order and
|
||||||
the customer gets the usual paid e-mail. An Atendimento (or Site) order
|
the customer gets the usual paid e-mail. An Atendimento (or Site) order
|
||||||
goes to Tiny like a Site one, its internal note saying "pago fora do site"
|
goes to Tiny like a Site one, its internal note saying "pago fora do site"
|
||||||
and how, Pix and card naming Tiny's forma de recebimento. A Dropflow order
|
and how, each way named as Tiny's forma de recebimento (Pix, cartão, and
|
||||||
stays out of Tiny, its status updates and cancelling included
|
from Marcus on 2026-10-27 Dinheiro 919478944 and, for the customer's credit,
|
||||||
(payments.in_tiny), until Dropstar names that channel's revenue category.
|
their "CORREÇÃO DTF" 977493654; RECEIPT_METHODS in app/tiny.py). A Dropflow
|
||||||
|
order goes to Tiny too, in its own revenue category "DTF DROPFLOW"
|
||||||
|
(987032506, CATEGORIES in app/tiny.py), not DTF SITE (D-21).
|
||||||
- Rework register (Dropstar's rules D-02 to D-04; the user's answers of
|
- Rework register (Dropstar's rules D-02 to D-04; the user's answers of
|
||||||
2026-10-27), dtf_local.reworks. Gestão opens it from the order panel's menu
|
2026-10-27), dtf_local.reworks. Gestão opens it from the order panel's menu
|
||||||
("Abrir retrabalho") with its cause, the metres redone (the order's printed
|
("Abrir retrabalho") with its cause, the metres redone (the order's printed
|
||||||
@@ -501,9 +503,7 @@ Still to do (2026-10-26):
|
|||||||
with a rework carries a "Retrabalho" badge.
|
with a rework carries a "Retrabalho" badge.
|
||||||
- Still open from the internal rules (docs received 2026-10-26): customer
|
- Still open from the internal rules (docs received 2026-10-26): customer
|
||||||
credit as a payment the system keeps track of (today "crédito do cliente"
|
credit as a payment the system keeps track of (today "crédito do cliente"
|
||||||
is only how a registered order was paid), and the Tiny revenue category
|
is only how a registered order was paid). Done 2026-10-27: the folders catch up on what passed while the Kanban
|
||||||
for Dropflow orders (not DTF SITE; its name and the origin value must be
|
|
||||||
the same word, the document says). Done 2026-10-27: the folders catch up on what passed while the Kanban
|
|
||||||
computer was off, time in "Aguardando contato" no longer counts in Números'
|
computer was off, time in "Aguardando contato" no longer counts in Números'
|
||||||
time figures (D-38; each wait is kept in dtf_local.contact_waits, from mark
|
time figures (D-38; each wait is kept in dtf_local.contact_waits, from mark
|
||||||
to clear), and a file's type comes from its first bytes (D-13, see the
|
to clear), and a file's type comes from its first bytes (D-13, see the
|
||||||
|
|||||||
@@ -181,14 +181,17 @@ def run():
|
|||||||
with db.connect() as c:
|
with db.connect() as c:
|
||||||
sent = c.execute("SELECT payload FROM dtf_local.outbox WHERE event_key=%s", (order['id'] + ':paid:tiny',)).fetchone()
|
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
|
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_quote, _ = reviewed_quote()
|
||||||
batch = register(batch_quote, {'origin': 'dropflow', 'method': 'credit'})
|
batch = register(batch_quote, {'origin': 'dropflow', 'method': 'credit'})
|
||||||
board.call('/operator/orders/' + batch['id'] + '/cancel', {'note': 'Lote refeito'}, operator=True)
|
board.call('/operator/orders/' + batch['id'] + '/cancel', {'note': 'Lote refeito'}, operator=True)
|
||||||
with db.connect() as c:
|
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']
|
events = {r['event_key']: r['payload'] for r in c.execute(
|
||||||
assert batch['origin'] == 'dropflow' and held == 0, (batch, held)
|
"SELECT event_key, payload FROM dtf_local.outbox WHERE event_key LIKE %s", (batch['id'] + ':%',)).fetchall()}
|
||||||
print('PASS: an order paid outside is registered with its origin and payment; Dropflow stays out of Tiny')
|
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
|
# 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
|
# paid order keeps them for its 30 days; a payment never starts for files
|
||||||
|
|||||||
@@ -372,14 +372,24 @@ class TinyStatusTests(FakeTinyCase):
|
|||||||
self.assertNotIn('vendedor', plain)
|
self.assertNotIn('vendedor', plain)
|
||||||
self.assertTrue(plain['observacoesInternas'].startswith('Site DTF · pago · '))
|
self.assertTrue(plain['observacoesInternas'].startswith('Site DTF · pago · '))
|
||||||
# An order the team registered (D-35): its origin, and how it was paid
|
# 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}},
|
counter = order_payload({**PAID, 'origin': 'atendimento', 'payment': {'method': 'cash', 'outside': True}},
|
||||||
1, thursday, shipping=self.tiny.shipping)
|
1, thursday, shipping=self.tiny.shipping)
|
||||||
self.assertTrue(counter['observacoesInternas'].startswith('Atendimento DTF · pago fora do site (dinheiro) · '))
|
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}},
|
pix = order_payload({**PAID, 'origin': 'atendimento', 'payment': {'method': 'pix', 'outside': True}},
|
||||||
1, thursday, shipping=self.tiny.shipping)
|
1, thursday, shipping=self.tiny.shipping)
|
||||||
self.assertEqual(pix['pagamento']['formaRecebimento'], {'id': RECEIPT_METHODS['pix']})
|
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):
|
def test_the_order_is_tagged_kanbandtf_once(self):
|
||||||
first = self.tiny.deliver('k1', PAID)
|
first = self.tiny.deliver('k1', PAID)
|
||||||
|
|||||||
Reference in New Issue
Block a user