fix: a reprint keeps an all-items choice, an undone pass to Revisão prints nothing again, and Prova OK tells Tiny (#105)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m56s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m26s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 7m56s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m26s
- Every item ticked was saved as NULL, which also means "not chosen", so the pass to the queue replaced it with the suggestion and only the changed item went to the machine; the panel showed the suggestion again. The choice is now the whole list. - Undoing a pass to Revisão (back to Imprimindo) started a new round with every file, so FlexiPRINT printed the order again. It now writes back only what Flexi had not taken, and the reprint choice of that pass returns. A pass undone this way no longer counts its film twice in the machine's metres (machine log and Números). - An order entering the queue by Prova OK never sent Tiny's "Preparando envio". The stage's Tiny event is now one function, used by the move and by the Prova OK. Integration test follows the real moves: suggestion, all items kept, pull onto a machine, two undone passes to Revisão, metres counted once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -77,6 +77,34 @@ def in_tiny(order):
|
||||
return not is_test(order) and not order.get('parent_id')
|
||||
|
||||
|
||||
# What a stage tells Tiny: entering the queue (Arte conferida) is its
|
||||
# "Preparando envio", Finalizado its "Pronto para envio" (Dropstar's flow,
|
||||
# 2026-10-23); a correction has no situação and is only recorded.
|
||||
STAGE_EVENTS = {'tra': 'production_started', 'cor': 'correction_needed', 'fin': 'ready'}
|
||||
|
||||
|
||||
def stage_event(c, order, state, reason, version):
|
||||
"""Queue Tiny's event for an order that entered `state` (not by a step
|
||||
back), whoever moved it: a card dragged, or the Prova OK that puts the
|
||||
order in the queue (app/proof.py). `order` is its row before the move,
|
||||
`version` its version after."""
|
||||
if state not in STAGE_EVENTS or not in_tiny(order):
|
||||
return
|
||||
# "Production started" and "ready" reach the customer once per order,
|
||||
# even if a mistaken move is undone and made again. Each correction is a
|
||||
# new request, so it keeps one message per movement.
|
||||
once = state in ('tra', 'fin')
|
||||
event = {'order_id': str(order['id']), 'number': order['number'], 'event': STAGE_EVENTS[state],
|
||||
'reason': reason, 'customer_path': f"/portal.html?order={order['id']}"}
|
||||
# Tiny needs the order (customer, pickup or delivery) and, once the sale
|
||||
# reached it, its id, to set the situação without a search.
|
||||
sale = c.execute("SELECT receipt FROM dtf_local.outbox WHERE event_key=%s AND delivered_at IS NOT NULL",
|
||||
(f"{order['id']}:paid:tiny",)).fetchone()
|
||||
tiny = {**event, 'order': order['snapshot'], 'tiny_id': ((sale or {}).get('receipt') or {}).get('tiny_id')}
|
||||
key = f"{order['id']}:{STAGE_EVENTS[state]}:tiny" if once else f"{order['id']}:{version}:tiny"
|
||||
enqueue(c, key, 'tiny', tiny)
|
||||
|
||||
|
||||
# How long a file is kept while nothing has been paid for it. A cart's files
|
||||
# are uploaded before payment, so the price and the security check are done on
|
||||
# the file itself; a cart that is never paid must not keep them for 30 days.
|
||||
|
||||
Reference in New Issue
Block a user