feat: rework register, opened by Gestao with a locked cause and authorized by an Administrador (Dropstar's rules D-02 to D-04)
All checks were successful
Build and deploy / Validate source (push) Successful in 10s
Build and deploy / Integration suite on a real stack (push) Successful in 3m27s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m2s
All checks were successful
Build and deploy / Validate source (push) Successful in 10s
Build and deploy / Integration suite on a real stack (push) Successful in 3m27s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m2s
Gestao opens a rework from the order panel with its cause (falha de impressao, perfil de cor, erro de tratamento, erro de pedido, or arte aprovada pelo cliente, outside the goal), the metres redone and a note; the cause never changes. An Administrador authorizes or declines it with a reason, never one they opened, and only an authorized rework counts. The order keeps who printed it. Numeros shows the metres redone per cause over the film printed, against 0,4% per cause and 1,6% for the house, by who printed, and the reworks waiting for authorization. Vendedor goes back to viewing only (D-30): registering orders paid outside is Administrador and Gestao. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -758,6 +758,8 @@ function card(order){
|
||||
? badge('✓ Prova OK','ok','Conferida por '+order.proof_ok_by+' em '+when(order.proof_ok_at))
|
||||
: badge('Prova','warn',order.snapshot.proof?'O cliente pediu uma prova antes de imprimir':'Pedido acima de 10 m: prova antes do resto'));
|
||||
}
|
||||
const redo=(order.reworks||[]).filter(r=>r.authorized!==false);
|
||||
if(!order.cancelled_at&&redo.length)flags.append(badge('Retrabalho','bad',redo.map(r=>REWORK_CAUSES[r.cause]+' · '+metres(r.metres)+(r.authorized?'':' · aguardando autorização')).join('\n')));
|
||||
// Arte tratada (Dropstar, 2026-10-27): the final is not the customer's art, someone prepared it.
|
||||
if(!order.cancelled_at&&order.treated)flags.append(badge('Arte tratada','info',TREATED_NOTE+' Aprovado por '+order.treated.by+'.'));
|
||||
c.append(artBox(s.items,'card-art'),top,buyerBlock(s,'cust'),meta,place(s.destination));
|
||||
@@ -886,7 +888,7 @@ function renderPanel(order){
|
||||
items.append(itemsList);
|
||||
const finals=node('section',undefined,'finals');finals.append(node('p','Arquivos finais','eyebrow'),node('p','Carregando…','faint'));
|
||||
const history=node('section');history.append(node('p','Histórico','eyebrow'),node('p','Carregando…','faint'));
|
||||
body.append(facts,items,finals,history);
|
||||
body.append(facts,items,finals,...(order.reworks?.length?[reworkSection(order)]:[]),history);
|
||||
panel.replaceChildren(head,body);
|
||||
|
||||
api('/orders/'+order.id+'/files').then(rows=>{if(token===openToken)finalsSection(order,rows,finals);}).catch(e=>say(e.message,true));
|
||||
@@ -1007,6 +1009,7 @@ function moves(order){
|
||||
await api('/orders/'+order.id+'/delete',{});closePanel();say('Pedido de teste #'+order.number+' excluído.');await load();
|
||||
},'menuitem bad'));
|
||||
}else{
|
||||
if(may('rework'))menu.append(button('Abrir retrabalho',()=>{menu.hidden=true;reworkForm(order);},'menuitem'));
|
||||
const b=node('button','Cancelar pedido','menuitem bad');b.type='button';
|
||||
b.onclick=()=>{menu.hidden=true;toggle(cancelForm);};menu.append(b);
|
||||
const why=node('input');why.placeholder='Motivo do cancelamento';why.setAttribute('aria-label','Motivo do cancelamento');why.required=true;why.minLength=3;why.maxLength=1000;
|
||||
@@ -1203,6 +1206,48 @@ function finalsSection(order,revisions,section){
|
||||
open.style.alignSelf='flex-start';open.onclick=()=>{form.hidden=!form.hidden;if(!form.hidden)form.querySelector('input:not([hidden])')?.focus();};
|
||||
section.append(open,form);
|
||||
}
|
||||
// Rework (Dropstar's rules D-02 to D-04). Gestão opens it with its cause,
|
||||
// which never changes after; an Administrador authorizes or declines it,
|
||||
// never one they opened. Bad art the customer approved is outside the goal.
|
||||
const REWORK_CAUSES={impressao:'Falha de impressão',perfil_cor:'Perfil de cor',tratamento:'Erro de tratamento',
|
||||
pedido:'Erro de pedido',arte_cliente:'Arte aprovada pelo cliente'};
|
||||
const REWORK_OUTSIDE='arte_cliente';
|
||||
function reworkForm(order){
|
||||
const cause=node('select');cause.required=true;
|
||||
const none=node('option','Escolha a causa');none.value='';cause.append(none);
|
||||
for(const [value,text] of Object.entries(REWORK_CAUSES)){const o=node('option',text+(value===REWORK_OUTSIDE?' (fora da meta)':''));o.value=value;cause.append(o);}
|
||||
const size=node('input');size.type='number';size.required=true;size.min='0.01';size.max='1000';size.step='0.01';
|
||||
size.value=order.snapshot.items.reduce((t,i)=>t+Number(i.metres??i.billed_metres),0).toFixed(2);
|
||||
const note=node('textarea');note.maxLength=1000;note.placeholder='O que aconteceu (opcional)';
|
||||
dialog('Abrir retrabalho · #'+order.number,[
|
||||
node('p','A causa não muda depois de aberta. O retrabalho conta na meta quando um administrador autoriza.','muted'),
|
||||
field('Causa',cause),field('Metros refeitos',size),field('Observação',note)],async()=>{
|
||||
await api('/orders/'+order.id+'/reworks',{cause:cause.value,metres:size.value,note:note.value});
|
||||
say('Retrabalho aberto no pedido #'+order.number+'. Aguarda a autorização de um administrador.');await load();
|
||||
});
|
||||
}
|
||||
function reworkSection(order){
|
||||
const section=node('section');section.append(node('p','Retrabalho','eyebrow'));
|
||||
for(const r of order.reworks){
|
||||
const box=node('div',undefined,'fcard');
|
||||
box.append(node('b',REWORK_CAUSES[r.cause]+(r.cause===REWORK_OUTSIDE?' · fora da meta':'')+' · '+metres(r.metres)),
|
||||
node('span','Aberto por '+r.opened_name+' em '+when(r.opened_at)+(r.printed_name?' · impresso por '+r.printed_name:''),'line'));
|
||||
if(r.note)box.append(node('span',r.note,'line'));
|
||||
if(r.decided_at)box.append(node('span',(r.authorized?'Autorizado por ':'Não autorizado por ')+r.decided_name+' em '+when(r.decided_at)+
|
||||
(r.decline_reason?': '+r.decline_reason:''),'line'));
|
||||
else if(may('authorize')&&r.opened_by!==ME.email){
|
||||
const why=node('input');why.placeholder='Motivo, se não autorizar';why.setAttribute('aria-label','Motivo, se não autorizar');why.maxLength=1000;
|
||||
const decide=authorized=>async()=>{
|
||||
await api('/reworks/'+r.id+'/decision',{authorized,reason:why.value});
|
||||
say(authorized?'Retrabalho autorizado.':'Retrabalho não autorizado.');await load();};
|
||||
const row=node('div',undefined,'buttons');
|
||||
row.append(button('Autorizar',decide(true),'btn primary'),why,button('Não autorizar',decide(false),'btn ghost'));
|
||||
box.append(row);
|
||||
}else box.append(node('span','Aguardando a autorização de um administrador','line'));
|
||||
section.append(box);
|
||||
}
|
||||
return section;
|
||||
}
|
||||
function historySection(order,rows,section){
|
||||
const list=node('ol',undefined,'timeline');
|
||||
const entry=(color,title,who,at,reason)=>{
|
||||
@@ -1435,6 +1480,26 @@ async function loadStats(){
|
||||
tr.append(node('td',t.who),node('td',t.orders+(t.orders>1?' pedidos':' pedido')));return tr;});
|
||||
if(!treatedRows.length){const tr=node('tr');const td=node('td','Nenhuma arte tratada no período.','faint');td.colSpan=2;tr.append(td);treatedRows.push(tr);}
|
||||
$('stats-treated').replaceChildren(...treatedRows);
|
||||
// Rework (D-02 to D-04): authorized metres redone over the film printed, against the goal.
|
||||
const rw=data.rework, share=v=>v==null?'—':String(v).replace('.',',')+'%';
|
||||
const goal=String(rw.goal_percent).replace('.',',')+'%';
|
||||
const reworkRows=rw.causes.map(r=>{const tr=node('tr'),outside=r.cause===REWORK_OUTSIDE;
|
||||
const over=!outside&&r.percent!=null&&r.percent>rw.goal_percent;
|
||||
tr.append(node('td',REWORK_CAUSES[r.cause]),node('td',metres(r.metres)+(r.orders?' · '+r.orders+(r.orders>1?' pedidos':' pedido'):'')),
|
||||
node('td',share(r.percent),over?'late':''),node('td',outside?'fora da meta':goal,'faint'));
|
||||
if(!r.metres)tr.classList.add('off');return tr;});
|
||||
const house=node('tr');house.append(node('td','Total da casa'),node('td',metres(rw.house.metres)),
|
||||
node('td',share(rw.house.percent),rw.house.percent>rw.house.goal_percent?'late':''),node('td',String(rw.house.goal_percent).replace('.',',')+'%','faint'));
|
||||
house.querySelectorAll('td').forEach(td=>td.style.fontWeight='700');
|
||||
$('stats-rework').replaceChildren(...reworkRows,house);
|
||||
$('stats-rework-film').textContent=metres(rw.film_metres)+' impressos no período.';
|
||||
const printerRows=rw.by_printer.map(p=>{const tr=node('tr');tr.append(node('td',p.who),node('td',metres(p.metres)));return tr;});
|
||||
if(!printerRows.length){const tr=node('tr');const td=node('td','Nenhum retrabalho da casa autorizado no período.','faint');td.colSpan=2;tr.append(td);printerRows.push(tr);}
|
||||
$('stats-rework-printers').replaceChildren(...printerRows);
|
||||
const waiting=rw.pending.map(p=>{const li=node('li');const open=node('button','#'+p.number,'linkbtn');open.type='button';
|
||||
open.onclick=()=>openPanel(p.order_id);
|
||||
li.append(open,' · '+REWORK_CAUSES[p.cause]+' · '+metres(p.metres)+' · aberto por '+p.opened_by+' em '+when(p.opened_at));return li;});
|
||||
$('stats-rework-pending').replaceChildren(...(waiting.length?waiting:[node('li','Nenhum.','faint')]));
|
||||
// Each way in apart (D-21): its orders, metres, money and time to Finalizado.
|
||||
$('stats-origins').replaceChildren(...data.origins.map(o=>{const tr=node('tr');
|
||||
tr.append(node('td',ORIGINS[o.origin]),node('td',String(o.orders)),node('td',metres(o.metres)),node('td',money(o.cents)),
|
||||
|
||||
Reference in New Issue
Block a user