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):
|
||||
"""Whether the order goes to Tiny: not a test, and not a Dropflow order,
|
||||
held until Dropstar names that channel's revenue category (it must not be
|
||||
DTF SITE, their rules document says)."""
|
||||
return not is_test(order) and order['origin'] != 'dropflow'
|
||||
"""Whether the order goes to Tiny: every order but a test. A Dropflow
|
||||
order goes in its own revenue category (app/tiny.py, CATEGORIES)."""
|
||||
return not is_test(order)
|
||||
|
||||
|
||||
# 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
|
||||
# (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
|
||||
# DropStar carrier its pickup orders name.
|
||||
RECEIPT_METHODS = {'pix': 919478952, 'card': 977460722}
|
||||
# DropStar carrier its pickup orders name. Dinheiro and, for the customer's
|
||||
# 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
|
||||
# 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
|
||||
@@ -124,6 +126,9 @@ PICKUP_CARRIER = 761565838
|
||||
# POST /pedidos does not take marcadores. Capitals, no accent, no extra
|
||||
# space: the string Kondado reads for Power BI.
|
||||
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'
|
||||
# Freight is the sender's (CIF), as on the store's orders.
|
||||
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:
|
||||
pedido['dataPrevista'] = business_days_after(day, int(days)).isoformat()
|
||||
# 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'))
|
||||
if received:
|
||||
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
|
||||
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"
|
||||
and how, Pix and card naming Tiny's forma de recebimento. A Dropflow order
|
||||
stays out of Tiny, its status updates and cancelling included
|
||||
(payments.in_tiny), until Dropstar names that channel's revenue category.
|
||||
and how, each way named as Tiny's forma de recebimento (Pix, cartão, and
|
||||
from Marcus on 2026-10-27 Dinheiro 919478944 and, for the customer's credit,
|
||||
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
|
||||
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
|
||||
@@ -501,9 +503,7 @@ Still to do (2026-10-26):
|
||||
with a rework carries a "Retrabalho" badge.
|
||||
- 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"
|
||||
is only how a registered order was paid), and the Tiny revenue category
|
||||
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
|
||||
is only how a registered order was paid). 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'
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user