feat: the proof card, a child order the seller answers (Dropstar, 30/10 and 03/11)
Some checks failed
Build and deploy / Validate source (push) Successful in 1m8s
Build and deploy / Integration suite on a real stack (push) Failing after 3m14s
Build and deploy / Publish images (push) Has been skipped
Build and deploy / Secret scan and release gate (push) Successful in 9s
Some checks failed
Build and deploy / Validate source (push) Successful in 1m8s
Build and deploy / Integration suite on a real stack (push) Failing after 3m14s
Build and deploy / Publish images (push) Has been skipped
Build and deploy / Secret scan and release gate (push) Successful in 9s
An order with a proof (asked for at checkout, or above 10 m) gets a child
card "Prova": an order of its own (orders.parent_id), no sale, with the
film's first 30 cm as DTF-N-item-1-prova.png ("Prova do pedido DTF-N" in its
footer), which follows the flow up to Revisão like any card, hot folder
included. The order waits outside the queue, "Aguardando prova": it is not
pulled to Imprimindo, nor counted in the queue's places.
In Revisão the card is answered by the Vendedor, Gestão or the
Administrador (capability "proof"): Prova OK records who and when and puts
the order in Arte conferida when its finals are approved; Prova reprovada,
with its reason, sends the order back to Arte recebida, its final to be
approved again, and offers "Nova prova". Either way the card closes and
leaves the board. An order from before the cards keeps the old Prova OK.
The card is kept out of Tiny, e-mails, Números, the search, Finalizado and
the customer's account. Deleting an order takes its cards and their rows:
movements, order files and print files now cascade with their order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -686,7 +686,21 @@ const contactWho=order=>(order.contact_by||'')+' em '+when(order.contact_since);
|
||||
const PROOF_ABOVE_METRES=10;
|
||||
const PROOF_RULE='Até 30 cm, do trecho de traço mais fino, um pedaço de cada arte diferente; no máximo 3 provas por pedido, sem cobrança.';
|
||||
const needsProof=order=>!!order.snapshot.proof||order.snapshot.items.reduce((t,i)=>t+Number(i.billed_metres),0)>PROOF_ABOVE_METRES;
|
||||
const proofPending=order=>needsProof(order)&&!order.proof_ok_at&&order.state!=='fin'&&!order.cancelled_at;
|
||||
const proofPending=order=>needsProof(order)&&!order.proof_ok_at&&order.state!=='fin'&&!order.cancelled_at&&!order.proof_parent;
|
||||
// The proof card (app/proof.py): the order's own card waits outside the queue
|
||||
// for its answer; an order from before the cards has none.
|
||||
const waitingProof=order=>!!order.proof_card&&!order.proof_card.proof_result&&!order.proof_ok_at;
|
||||
const proofRejected=order=>order.proof_card?.proof_result==='rejected'&&!order.proof_ok_at;
|
||||
async function proofAnswer(order,result,reason=''){
|
||||
await api('/orders/'+order.id+'/proof-answer',{result,reason});await load();
|
||||
say(result==='ok'?'Prova OK: o pedido #'+order.proof_parent.number+' entra na fila.':'Prova reprovada: o pedido #'+order.proof_parent.number+' voltou para Arte recebida.');
|
||||
}
|
||||
function proofReject(order){
|
||||
const reason=node('textarea');reason.required=true;reason.minLength=3;reason.maxLength=500;reason.rows=3;
|
||||
formDialog('Prova reprovada',{host:$('drawer'),label:'Reprovar a prova',tone:'red',
|
||||
text:'O pedido #'+order.proof_parent.number+' volta para Arte recebida com o motivo, e este card de prova encerra.',
|
||||
fields:[field('Motivo',reason)],onsave:async()=>{await proofAnswer(order,'rejected',reason.value);}});
|
||||
}
|
||||
const TREATED_NOTE='O arquivo final foi preparado pela equipe, não é a arte que o cliente mandou.';
|
||||
// Mirrored by the customer (UV only, web/site-pdf.js): the room checks it before printing.
|
||||
const mirroredItem=item=>!!item.production?.sources?.some(source=>source.mirrored);
|
||||
@@ -942,7 +956,8 @@ function markLane(column,id){
|
||||
// A card's place in the print queue, among the orders of its product (a
|
||||
// textile machine pulls the next textile order).
|
||||
const uvOrder=o=>o.snapshot.items.some(i=>i.mode.startsWith('uv'));
|
||||
const queuePlace=(order,queue)=>queue.filter(o=>uvOrder(o)===uvOrder(order)).indexOf(order)+1;
|
||||
// An order waiting for its proof is not in the queue yet (app/proof.py).
|
||||
const queuePlace=(order,queue)=>queue.filter(o=>uvOrder(o)===uvOrder(order)&&!waitingProof(o)).indexOf(order)+1;
|
||||
// An operator's test order: no payment, no Tiny.
|
||||
const isTest=order=>order.payment?.provider==='teste';
|
||||
const shortAgo=value=>ago(value).replace(/^há /,'');
|
||||
@@ -952,6 +967,9 @@ const shortAgo=value=>ago(value).replace(/^há /,'');
|
||||
function nextStep(order,place){
|
||||
if(order.cancelled_at)return ['Cancelado','wait'];
|
||||
if(order.state==='cor')return ['Esperando o cliente','wait'];
|
||||
// The proof card waits for its answer; its order, outside the queue, for that.
|
||||
if(order.proof_parent&&order.state==='rev')return ['Responder a prova','act'];
|
||||
if(order.state==='tra'&&waitingProof(order))return ['Aguardando prova','wait'];
|
||||
if(order.state==='rev')return ['Conferir a folha','act'];
|
||||
if(order.state==='imp')return partsStep(order)||(order.printing?PRINTING[order.printing].slice(0,2):['Na máquina','wait']);
|
||||
if(order.state==='tra'){
|
||||
@@ -979,7 +997,10 @@ function cardFlags(order){
|
||||
if(redo.length)out.push(['bad','Retrabalho',redo.map(r=>'Retrabalho · '+REWORK_CAUSES[r.cause]+' · '+metres(r.metres)+(r.authorized?'':' · aguardando autorização')).join(' · ')]);
|
||||
if(live&&s.items.some(mirroredItem))out.push(['warn','Espelhada',MIRROR_NOTE]);
|
||||
if(waitingContact(order))out.push(['warn','Contato','Aguardando contato: '+order.contact_note+' · '+contactWho(order)]);
|
||||
if(live&&proofPending(order))out.push(['warn','Prova',order.snapshot.proof?'O cliente pediu uma prova antes de imprimir':'Pedido acima de 10 m: prova antes do resto']);
|
||||
if(order.proof_parent)out.push(['warn','Prova do #'+order.proof_parent.number,'Card da prova do pedido #'+order.proof_parent.number]);
|
||||
if(live&&waitingProof(order)&&order.state!=='tra')out.push(['warn','Aguardando prova','Entra na fila com Prova OK no card #'+order.proof_card.number]);
|
||||
if(live&&proofRejected(order))out.push(['bad','Prova reprovada',order.proof_card.proof_reason+' · '+order.proof_card.proof_decided_by]);
|
||||
if(live&&proofPending(order)&&!order.proof_card)out.push(['warn','Prova',order.snapshot.proof?'O cliente pediu uma prova antes de imprimir':'Pedido acima de 10 m: prova antes do resto']);
|
||||
if(live&&s.items.some(i=>i.quality_status==='warning'))out.push(['warn','Nota '+(lowestGrade(s.items)??'baixa'),'Nota da arte baixa: o cliente aceitou a ressalva de resolução']);
|
||||
const dots=s.items.reduce((t,i)=>t+(i.residue_accepted||0),0);
|
||||
if(live&&dots)out.push(['warn','Resíduo','O cliente aceitou imprimir com '+residueNote({residue_accepted:dots})]);
|
||||
@@ -1308,7 +1329,10 @@ function renderPanel(order){
|
||||
// What was paid and when, where it came from, and the codes: DTF-23 is the
|
||||
// room's, in the file names, the footer and Tiny; the customer knows the other.
|
||||
const sub=node('div',undefined,'dsub');
|
||||
const paid=node('span');paid.append(node('b',money(s.total_cents)),isTest(order)?' sem pagamento, '+when(order.created_at):
|
||||
const paid=node('span');
|
||||
// A proof card is no sale (app/proof.py): it says whose proof it is.
|
||||
if(order.proof_parent)paid.append(node('b','Prova do pedido #'+order.proof_parent.number),', sem custo, criada em '+when(order.created_at));
|
||||
else paid.append(node('b',money(s.total_cents)),isTest(order)?' sem pagamento, '+when(order.created_at):
|
||||
paidOutside(order)?' pago fora do site ('+PAID_OUTSIDE[order.payment.method]+'), registrado em '+when(order.created_at):' pago em '+when(order.created_at));
|
||||
const code=node('span',undefined,'chip');
|
||||
code.append(node('span','DTF-'+order.number,'code'),copyButton(fileCode(order),'Copiar “'+fileCode(order)+'”, o começo do nome dos arquivos deste pedido'));
|
||||
@@ -1494,6 +1518,15 @@ function nextBox(order){
|
||||
const note=text=>body.push(node('p',text,'nnote'));
|
||||
const can=to=>mayMove(st,to)&&mayAct(order);
|
||||
const moveBtn=(to,label,className='btn pri lg')=>{const b=button(label||'Mover para '+board.states[to],()=>move(order,to),className);b.dataset.move=to;return b;};
|
||||
// A proof card in Revisão waits for its answer (Dropstar, 2026-11-03).
|
||||
if(order.proof_parent&&st==='rev'){
|
||||
title='Responder a prova';
|
||||
note('Prova do pedido #'+order.proof_parent.number+'. Com a prova impressa conferida'+(order.snapshot.proof?' e o aceite do cliente':'')+', responda aqui.');
|
||||
if(may('proof')){main.push(button('Prova OK',()=>proofAnswer(order,'ok'),'btn pri lg'));
|
||||
more.push(button('Prova reprovada',()=>proofReject(order),'btn quiet lg'));}
|
||||
else note('Quem responde é o Vendedor, a Gestão ou o Administrador.');
|
||||
return composeNext(title,body,main,more);
|
||||
}
|
||||
const readOnly=!may('produce')&&!ME?.moves?.length;
|
||||
const fixed=(order.corrections||[]).length>0;
|
||||
if(st==='cor'){
|
||||
@@ -1509,10 +1542,15 @@ function nextBox(order){
|
||||
}
|
||||
const fixBtn=()=>{if(!trans.includes('cor')||!can('cor'))return;
|
||||
const b=node('button','Pedir correção','btn quiet lg');b.type='button';b.dataset.move='cor';b.onclick=()=>correctionDialog(order);more.push(b);};
|
||||
const proofBtn=(className='btn lg')=>{if(!proofPending(order)||!may('print'))return null;
|
||||
const proofBtn=(className='btn lg')=>{if(!proofPending(order)||order.proof_card||!may('print'))return null;
|
||||
const b=button('Prova OK',()=>proofOk(order),className);b.dataset.proof='';b.title='A prova foi impressa e conferida';return b;};
|
||||
const cannot=()=>note(!mayAct(order)?'Pedido da '+(order.machine?.name||'outra máquina')+': só quem está nela move o card.'
|
||||
:st==='rev'?'A folha impressa é conferida e liberada pelo Revisor.':'Daqui em diante, com a produção.');
|
||||
// The proof was rejected: its reason, and a new proof card when the art is fixed.
|
||||
if(st==='rec'&&proofRejected(order)){
|
||||
const p=node('p',undefined,'nnote');p.append(node('b','Prova reprovada: '),order.proof_card.proof_reason);body.push(p);
|
||||
if(may('produce'))more.push(button('Nova prova',async()=>{await api('/orders/'+order.id+'/proof-card',{});await load();say('Nova prova criada.');},'btn lg'));
|
||||
}
|
||||
if(st==='rec'||st==='cor'){
|
||||
if(!finalDone(order)&&trans.includes('tra')){
|
||||
if(st==='rec')title='Aprovar o arquivo final';
|
||||
@@ -1537,6 +1575,10 @@ function nextBox(order){
|
||||
if(can(to))(to==='tra'&&finalDone(order)?main:more).push(moveBtn(to,null,to==='tra'&&finalDone(order)?'btn pri lg':'btn lg'));
|
||||
}
|
||||
if(st==='rec')fixBtn();
|
||||
}else if(st==='tra'&&waitingProof(order)){
|
||||
title='Aguardando prova';
|
||||
note('O pedido entra na fila com Prova OK no card da prova #'+order.proof_card.number+'.');
|
||||
fixBtn();
|
||||
}else if(st==='tra'){
|
||||
title='Puxar para a máquina';
|
||||
note(order.machine?'Vai para a '+order.machine.name+'. O arquivo final já está aprovado.':'O arquivo final já está aprovado.');
|
||||
@@ -2155,7 +2197,7 @@ function avatar(u,className='ava'){
|
||||
const ROLE_COLUMNS=['admin','gestao','designer','operador','revisor','vendedor','financeiro'];
|
||||
const ROLE_MATRIX=[['Aprovar o arquivo final','YYYNNNN'],['Pedir correção','YYYNNNN'],['Puxar da fila e imprimir','YNNYNNN'],
|
||||
['Liberar para Finalizado','YNNNYNN'],['Voltar uma etapa, com motivo','YYYYYNN'],['Marcar retirado','YYYYYNN'],
|
||||
['Cotações e Números','YYNNNVV'],['Pagamentos','YYNNNNV'],['Pedido pago fora do site','YYNNNNN'],['Cancelar pedido','YYNNNNY'],
|
||||
['Cotações e Números','YYNNNVV'],['Pagamentos','YYNNNNV'],['Pedido pago fora do site','YYNNNNN'],['Prova OK ou reprovada','YYNNNYN'],['Cancelar pedido','YYNNNNY'],
|
||||
['Abrir retrabalho','NYNNNNN'],['Autorizar retrabalho','YNNNNNN'],['Usuários e máquinas','YNNNNNN']];
|
||||
let usersData=null;
|
||||
async function loadUsers(){
|
||||
|
||||
Reference in New Issue
Block a user