fix: the choice of items to reprint ends with the print, a new final or "Gerar de novo", so a later correction always goes to the machine (#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 7m54s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m27s

Kept until Finalizado, an old choice would leave out an item corrected after
it (an order back from Revisão, or a second correction). It is now cleared
when the pass to Revisão records it, when a final changes and when the files
are generated again; the next entry to the queue works it out anew. An
integration test follows the whole reprint: first print, one item corrected,
the queue, the hot folder with that item only, Revisão.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-27 14:19:37 -03:00
parent b2876487bd
commit 742ea5f5bd
3 changed files with 73 additions and 4 deletions

View File

@@ -519,8 +519,10 @@ def move(uid: UUID, body: Move, request: Request, user=Depends(operator)):
default = hotfolder.reprint_default(finals, taken, len(row['snapshot']['items']))
if default:
c.execute('UPDATE dtf_local.orders SET print_items=%s WHERE id=%s', (default, uid))
# Finished: the next time it goes back, the choice starts over.
if body.state == 'fin' and not back:
# Printed (its items kept on the movement above) or finished: the
# choice is done with, and the next pass to the queue works it out
# again from what changed since.
if printed_items is not None or (body.state == 'fin' and not back):
c.execute('UPDATE dtf_local.orders SET print_items=NULL WHERE id=%s', (uid,))
# Pulled to Imprimindo, its files go to its machine's hot folder; out
# of it, what Flexi did not take leaves (item 10).
@@ -632,8 +634,10 @@ def regenerate_ready(uid: UUID, user=Depends(can('produce'))):
EXISTS (SELECT 1 FROM dtf_local.print_parts p WHERE p.order_id=f.order_id AND p.upload_id=f.upload_id)
OR EXISTS (SELECT 1 FROM dtf_local.print_files p WHERE p.order_id=f.order_id AND p.upload_id=f.upload_id))''',
(uid,))
# The new version tells the board and the folders the files changed.
c.execute("UPDATE dtf_local.orders SET state='rec', version=version+1, updated_at=now() WHERE id=%s", (uid,))
# The new version tells the board and the folders the files changed;
# every file is new, so any choice of items to reprint is over.
c.execute('''UPDATE dtf_local.orders SET state='rec', print_items=NULL, version=version+1, updated_at=now()
WHERE id=%s''', (uid,))
if row['state'] == 'imp':
hotfolder.stop(c, uid)
if row['state'] != 'rec':