feat: the team registers an order paid outside the site, choosing its origin and payment (Dropstar's rule D-35)
Some checks failed
Build and deploy / Integration suite on a real stack (push) Failing after 3m26s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Has been skipped
Build and deploy / Validate source (push) Successful in 6s
Some checks failed
Build and deploy / Integration suite on a real stack (push) Failing after 3m26s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Has been skipped
Build and deploy / Validate source (push) Successful in 6s
On an approved quote in Cotacoes, Administrador, Gestao and Vendedor pick the origin (Site, Dropflow, Atendimento) and how it was paid (Pix, cartao, dinheiro, credito do cliente), neither preselected, with an optional note. The price is the quote's, the Site's table price. The order is marked paid outside, counts in Numeros, and goes to Tiny like a Site order with the payment named in its internal note; a Dropflow order stays out of Tiny, status updates and cancelling included, until its revenue category exists. Auto-refresh waits while a register form on screen is half filled in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -166,6 +166,30 @@ def run():
|
||||
assert queued == 0 and jobs == 1, (queued, jobs)
|
||||
print('PASS: an operator test order reaches the board and the print queue, never Tiny')
|
||||
|
||||
# An order paid outside the system, registered by the team from its Site
|
||||
# quote (D-35): origin and payment are chosen, never assumed.
|
||||
_, counter_quote, counter_total = reviewed_quote()
|
||||
register = lambda qid, body, expected=200: board.call('/operator/quotes/' + qid + '/register', body,
|
||||
operator=True, expected=expected)
|
||||
for body in ({'method': 'pix'}, {'origin': 'atendimento'}, {'origin': 'whatsapp', 'method': 'pix'},
|
||||
{'origin': 'atendimento', 'method': 'boleto'}):
|
||||
register(counter_quote, body, expected=422)
|
||||
order = register(counter_quote, {'origin': 'atendimento', 'method': 'cash', 'note': 'Balcão'})
|
||||
assert (order['origin'], order['state'], order['payment']['provider'], order['payment']['method'],
|
||||
order['payment']['total_cents']) == ('atendimento', 'rec', 'manual', 'cash', counter_total), order
|
||||
register(counter_quote, {'origin': 'atendimento', 'method': 'cash'}, expected=409)
|
||||
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.
|
||||
_, 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')
|
||||
|
||||
# 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
|
||||
# that are gone.
|
||||
|
||||
@@ -370,6 +370,16 @@ class TinyStatusTests(FakeTinyCase):
|
||||
self.assertNotIn('transportador', plain)
|
||||
self.assertEqual(plain['pagamento'], {'categoria': {'id': CATEGORY}})
|
||||
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.
|
||||
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}})
|
||||
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']})
|
||||
|
||||
def test_the_order_is_tagged_kanbandtf_once(self):
|
||||
first = self.tiny.deliver('k1', PAID)
|
||||
|
||||
@@ -152,7 +152,10 @@ def run():
|
||||
seller.call(f'/operator/quotes/{uv_q}/discard', {}, expected=403)
|
||||
seller.call(f'/operator/orders/{textil_o}/machine', {'machine_id': None}, expected=403)
|
||||
seller.call(f'/operator/orders/{textil_o}/contact', {'waiting': True, 'note': 'Ligar'}, expected=403)
|
||||
assert seller.call('/operator/me')['can'] == ['view']
|
||||
# The seller registers orders paid outside (D-35); this quote already has
|
||||
# its order, so the answer is 409, past the permission.
|
||||
assert seller.call('/operator/me')['can'] == ['enter', 'view']
|
||||
seller.call(f'/operator/quotes/{uv_q}/register', {'origin': 'atendimento', 'method': 'pix'}, expected=409)
|
||||
# Only the Revisor releases to Finalizado: not even the administrator.
|
||||
admin.call(f'/operator/orders/{uv_o}/move', {'state': 'fin', 'version': printed['version'], 'reason': ''},
|
||||
expected=403)
|
||||
@@ -171,6 +174,7 @@ def run():
|
||||
assert next(u for u in admin.call('/operator/users')['users'] if u['email'] == emails['designer'])['machines'] == []
|
||||
designer = signed_in(emails['designer'])
|
||||
assert set(designer.call('/operator/me')['can']) == {'view', 'produce'}
|
||||
designer.call(f'/operator/quotes/{uv_q}/register', {'origin': 'atendimento', 'method': 'pix'}, expected=403)
|
||||
assert {str(uv_o), str(textil_o)} <= {o['id'] for o in designer.call('/operator/board')['orders']}
|
||||
version = next(o for o in designer.call('/operator/board')['orders'] if o['id'] == str(textil_o))['version']
|
||||
# A correction and back; Arte conferida only with the final approved.
|
||||
@@ -223,7 +227,7 @@ def run():
|
||||
c.execute('''INSERT INTO dtf_local.quotes(id,owner,request_key,request_hash,draft,approved,approved_at)
|
||||
VALUES(%s,%s,%s,'users-fixture',%s,%s,now())''', (asked, owner, uuid4(), Jsonb(content), Jsonb(content)))
|
||||
quote = c.execute('SELECT * FROM dtf_local.quotes WHERE id=%s', (asked,)).fetchone()
|
||||
order, created = payments.create_order(c, quote, {'provider': 'teste', 'id': f'proof-{tag}'})
|
||||
order, created = payments.create_order(c, quote, {'provider': 'teste', 'id': f'proof-{tag}'}, 'site')
|
||||
made.append((asked, order['id']))
|
||||
assert created and order['contact_since'] and order['contact_note'] == proof.CUSTOMER_NOTE, order
|
||||
|
||||
|
||||
Reference in New Issue
Block a user