fix: Prova OK gives the parent its Prumo final and queues it (0.1)
The proof answer is the parent's check: every ready full print file Prumo generated becomes an active final, and the parent enters Arte conferida. Items that still need hand preparation stay in Arte recebida.
This commit is contained in:
@@ -6,7 +6,7 @@ import secrets
|
||||
from decimal import Decimal
|
||||
from datetime import date, datetime, timedelta, timezone
|
||||
from typing import Literal
|
||||
from uuid import UUID
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, Request, Response
|
||||
from fastapi.responses import RedirectResponse
|
||||
@@ -808,7 +808,23 @@ def proof_answer(uid: UUID, body: ProofAnswer, user=Depends(can('proof'))):
|
||||
c.execute('''INSERT INTO dtf_local.movements(order_id,from_state,to_state,operator,reason)
|
||||
VALUES(%s,'rev','fin',%s,%s)''', (uid, user, label))
|
||||
if body.result == 'ok':
|
||||
# The order enters the queue: Arte conferida, if its finals are approved.
|
||||
# A prova aprovada é a conferência do pai: os arquivos completos
|
||||
# que o Prumo gerou entram como finais, e o pai segue para a fila.
|
||||
# Itens que ainda dependem de preparo manual continuam em Arte
|
||||
# recebida, com o botão de final disponível.
|
||||
if parent['state'] == 'rec':
|
||||
generated = c.execute('''SELECT p.item_index,p.upload_id FROM dtf_local.print_files p
|
||||
WHERE p.order_id=%s AND p.status='ready' AND p.upload_id IS NOT NULL
|
||||
AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files f
|
||||
WHERE f.order_id=p.order_id AND f.item_index=p.item_index
|
||||
AND f.kind='final' AND f.active)
|
||||
ORDER BY p.item_index''', (parent['id'],)).fetchall()
|
||||
for row in generated:
|
||||
c.execute('''INSERT INTO dtf_local.order_files
|
||||
(id,order_id,upload_id,item_index,kind,note,created_by)
|
||||
VALUES(%s,%s,%s,%s,'final',%s,'Prumo')''',
|
||||
(uuid4(), parent['id'], row['upload_id'], row['item_index'],
|
||||
f'Aprovado pela prova do #{card["number"]}'))
|
||||
ready = parent['state'] == 'rec' and all(c.execute('''SELECT 1 FROM dtf_local.order_files
|
||||
WHERE order_id=%s AND kind='final' AND active AND item_index=%s LIMIT 1''', (parent['id'], i)).fetchone()
|
||||
for i in range(len(parent['snapshot']['items'])))
|
||||
|
||||
Reference in New Issue
Block a user