All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 3m38s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 59s
A pickup order reaching Finalizado has its receipt due: a PDF for the 80 mm roll with the order number large at the top, the customer and CPF/CNPJ, each product and its metres, the amount and how it was paid, the date issued, and the "Retirado em" and "Assinatura" lines (app/receipt.py). The Kanban's folder saves it in Recibos/, where the counter's print queue sends it to the Bematech. One computer claims each receipt on the server before writing it, so it is never printed twice, and gives it back if it could not save it. Orders sent by carrier have none. "Retirado" on a pickup in Finalizado records when and who handed it over, with an optional photo of the signed receipt (kept 30 days). Anyone but the seller may mark it (new "deliver" capability); the order panel also opens the receipt to print it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
2.5 KiB
Python
56 lines
2.5 KiB
Python
"""Operator artwork handling: final files, and the uploads that carry them.
|
|
|
|
These reuse the customer upload routes with the operator's derived identity, so
|
|
one transport serves both and there is only one place where parts are signed.
|
|
"""
|
|
from uuid import UUID
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
|
|
from ..core import db
|
|
from ..artwork import submit_files
|
|
from ..core.auth import can, operator
|
|
from ..core.models import ArtworkSubmission, UploadStart
|
|
from ..runtime import file_rows, operator_identity
|
|
from .uploads import begin_upload, cancel_upload, complete_upload, part_url, upload_status
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post('/api/operator/orders/{oid}/uploads')
|
|
def begin_final(oid: UUID, body: UploadStart, user=Depends(can('produce'))):
|
|
with db.connect() as c:
|
|
row = c.execute('SELECT state FROM dtf_local.orders WHERE id=%s', (oid,)).fetchone()
|
|
if not row: raise HTTPException(404, 'Order not found')
|
|
if row['state'] not in ('rec','cor'): raise HTTPException(409, 'Order is not in artwork review')
|
|
return begin_upload(body, session_id=operator_identity(user))
|
|
|
|
@router.get('/api/operator/uploads/{uid}')
|
|
def final_status(uid: UUID, user=Depends(operator)):
|
|
return upload_status(uid,session_id=operator_identity(user))
|
|
|
|
# The parts of an upload its operator started: a final (produce) or the
|
|
# photo of a signed pickup receipt (deliver, which includes produce).
|
|
@router.post('/api/operator/uploads/{uid}/parts/{number}')
|
|
def final_part(uid: UUID, number: int, user=Depends(can('deliver'))):
|
|
return part_url(uid,number,session_id=operator_identity(user))
|
|
|
|
@router.post('/api/operator/uploads/{uid}/complete')
|
|
def final_complete(uid: UUID, user=Depends(can('deliver'))):
|
|
return complete_upload(uid,session_id=operator_identity(user))
|
|
|
|
@router.delete('/api/operator/uploads/{uid}')
|
|
def final_cancel(uid: UUID, user=Depends(can('deliver'))):
|
|
return cancel_upload(uid,session_id=operator_identity(user))
|
|
|
|
@router.get('/api/operator/orders/{oid}/files')
|
|
def operator_files(oid: UUID, user=Depends(operator)):
|
|
with db.connect() as c:
|
|
return file_rows(c,oid)
|
|
|
|
@router.post('/api/operator/orders/{oid}/final-files')
|
|
def final_files(oid: UUID, body: ArtworkSubmission, user=Depends(can('produce'))):
|
|
with db.connect() as c:
|
|
order = c.execute('SELECT * FROM dtf_local.orders WHERE id=%s FOR UPDATE', (oid,)).fetchone()
|
|
if not order: raise HTTPException(404, 'Order not found')
|
|
return submit_files(c,order,body,operator_identity(user),'final',user)
|