fix: a final that stopped counting is approved again, and a pull onto a machine that does not print the product is refused on the board (DTF-WEB-10, DTF-WEB-12)
All checks were successful
Build and deploy / Validate source (push) Successful in 1m49s
Build and deploy / Integration suite on a real stack (push) Successful in 8m41s
Build and deploy / Secret scan and release gate (push) Successful in 14s
Build and deploy / Publish images (push) Successful in 2m5s

- A generated file, or the customer's correction, that was this item's
  final and stopped counting (Correção, a step back) is turned back on
  when approved again, instead of "Este arquivo já está no pedido";
  other files keep that rule.
- A lane drop, or a machine chosen before, that does not print the
  order's product says "A <máquina> não imprime este produto." on the
  board and the card stays in Arte conferida, as the chooser filters.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-19 09:27:10 -03:00
parent 29187e6c9f
commit 662d6f9c41
3 changed files with 41 additions and 5 deletions

View File

@@ -77,19 +77,28 @@ def submit_files(c, order, body, identity, kind, actor):
kept = {ref.upload_id for ref in body.files if (ref.upload_id, ref.item_index) in current}
if kept and len(kept) == len(body.files):
raise HTTPException(409, 'Estes já são os arquivos finais. Envie o arquivo novo.')
revived = set()
for ref in body.files:
if ref.upload_id in kept:
continue
corrected = correction_owner(c, order, ref, kind)
upload = upload_row(c, ref.upload_id, corrected or generated_owner(c, order, ref, kind) or identity, lock=True)
generated = None if corrected else generated_owner(c, order, ref, kind)
upload = upload_row(c, ref.upload_id, corrected or generated or identity, lock=True)
if not upload['complete']:
raise HTTPException(409, 'Espere o envio de todos os arquivos terminar.')
require_clean(upload)
if kind == 'final':
require_final_png(storage, upload)
# Attached once, except a correction approved as its own final.
if c.execute('SELECT id FROM dtf_local.order_files WHERE upload_id=%s'+(" AND kind<>'correction'" if corrected else ''),
(ref.upload_id,)).fetchone():
# Attached once, except a correction approved as its own final, and a
# generated file or a correction that was this item's final and
# stopped counting (a step back, Correção): it is turned back on
# (Sentry DTF-WEB-10).
rows = c.execute('SELECT order_id,item_index,kind FROM dtf_local.order_files WHERE upload_id=%s'
+ (" AND kind<>'correction'" if corrected else ''), (ref.upload_id,)).fetchall()
if rows and (corrected or generated) and all(
r['order_id'] == order['id'] and r['kind'] == 'final' and r['item_index'] == ref.item_index for r in rows):
revived.add(ref.upload_id)
elif rows:
raise HTTPException(409, 'Este arquivo já está no pedido. Envie uma nova versão.')
# A new customer correction supersedes every final prepared from earlier
# artwork, including finals uploaded while this order was in correction.
@@ -98,7 +107,7 @@ def submit_files(c, order, body, identity, kind, actor):
else:
c.execute('UPDATE dtf_local.order_files SET active=false WHERE order_id=%s AND kind=%s', (order['id'],kind))
for ref in body.files:
if ref.upload_id in kept:
if ref.upload_id in kept or ref.upload_id in revived:
c.execute("UPDATE dtf_local.order_files SET active=true WHERE order_id=%s AND upload_id=%s AND kind='final'",
(order['id'], ref.upload_id))
continue

View File

@@ -221,6 +221,27 @@ def run():
assert str(remade['upload_id']) != str(made['upload_id']), (made, remade)
print('PASS: a ready file is generated again from Arte conferida, back in Arte recebida to approve')
# The generated file approved, sent to Correção (its final stops counting)
# and back: the same file is approved again, not refused as already in
# the order (Sentry DTF-WEB-10).
redo, redo_row = wait_print(client, paid_order(client, loose_item(upload_bytes(client, artwork(), name='LOCAL-REDO.png')))['id'], 'ready')
finals = [{'item_index': 0, 'upload_id': str(redo_row['upload_id'])}]
v = client.call('/operator/orders/' + redo['id'] + '/final-files',
{'version': redo['version'], 'files': finals, 'note': 'ok'}, operator=True)['version']
def version_of(oid):
with db.connect() as c:
return c.execute('SELECT version FROM dtf_local.orders WHERE id=%s', (oid,)).fetchone()['version']
client.call('/operator/orders/' + redo['id'] + '/move', {'state': 'cor', 'version': v, 'reason': 'Teste'}, operator=True)
client.call('/operator/orders/' + redo['id'] + '/move', {'state': 'rec', 'version': version_of(redo['id']),
'reason': 'Teste'}, operator=True)
client.call('/operator/orders/' + redo['id'] + '/final-files',
{'version': version_of(redo['id']), 'files': finals, 'note': 'de novo'}, operator=True)
with db.connect() as c:
rows = c.execute('''SELECT active FROM dtf_local.order_files WHERE order_id=%s AND kind='final' ''',
(redo['id'],)).fetchall()
assert [r['active'] for r in rows] == [True], rows
print('PASS: a generated final that stopped counting is approved again')
# Item 10: printing, the file goes once into its machine's hot folder for
# its class; Flexi taking it is reported; leaving Imprimindo withdraws
# what Flexi did not take.

View File

@@ -659,6 +659,12 @@ async function pullTo(order, machineId){
}
}
const machine=(board.machines||[]).find(row=>row.id===target);
// A lane drop, or a machine chosen before, may be one that does not print
// this product (by its first item, as app/machines.py product_family): said
// here, as the chooser filters, and the card stays put (Sentry DTF-WEB-12).
if(machine&&!(machine.products||[]).includes(/^uv/.test(order.snapshot.items[0]?.mode||'')?'uv':'textil')){
say('A '+machine.name+' não imprime este produto.');return;
}
const alert=(machine?.alerts||[]).find(row=>row.blocking);
if(alert&&!await machineAlertDialog(order,target,alert))return;
try{