From 7f2327aea9d7c88ec6fda0ce00cdd1ebbb044814 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cau=C3=AA=20Faleiros?=
Date: Thu, 29 Oct 2026 17:10:28 -0300
Subject: [PATCH] feat: the customer may accept printing a ready sheet's
residue dots (Dropstar's third round, item 5)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
A sheet with dots under 2 mm still stops the order, now with a box under
the warning: "Esta arte tem N pontos menores que 2 mm. Estou ciente e
aceito imprimir assim — eles podem se perder no recorte." Ticked, the
sheet goes on, and the item carries how many dots were accepted
(residue_accepted), kept through the review and shown on the Kanban card,
order panel and quote. A solid background still stops it, with no box.
Co-Authored-By: Claude Opus 5.5
---
app/core/models.py | 3 +++
app/quote_review.py | 5 +++--
tests/artwork_browser_test.mjs | 7 +++++++
tests/smoke_test.py | 9 +++++++++
web/checkout.js | 4 +++-
web/kanban.js | 8 ++++++++
web/site-cart.js | 2 ++
web/site-pdf.js | 24 ++++++++++++++++++------
web/site-quality.js | 15 ++++++++++-----
web/site-v2.css | 5 +++++
10 files changed, 68 insertions(+), 14 deletions(-)
diff --git a/app/core/models.py b/app/core/models.py
index 3f39e76..7be0ced 100644
--- a/app/core/models.py
+++ b/app/core/models.py
@@ -158,6 +158,9 @@ class Item(StrictModel):
production: ProductionSpec
quality_status: Literal['ok', 'warning', 'unverified']
quality_acknowledged: bool
+ # Residue dots under 2 mm the customer accepted printing on a ready sheet,
+ # rather than erasing them (Dropstar, 2026-10-29): 0 when none.
+ residue_accepted: int = Field(default=0, ge=0, le=1000000, strict=True)
@model_validator(mode='after')
def production_matches_uploads(self):
diff --git a/app/quote_review.py b/app/quote_review.py
index 235fb6a..a1fc2c2 100644
--- a/app/quote_review.py
+++ b/app/quote_review.py
@@ -64,7 +64,7 @@ def approve(c, row, items, reviewer):
for item, original in zip(items, draft['items']):
if item.mode != original['mode'] or list(map(str, item.uploads)) != original['uploads']:
raise HTTPException(422, 'O produto e os arquivos não podem mudar na revisão.')
- if item.production.model_dump(mode='json') != original['production'] or item.quality_status != original['quality_status'] or item.quality_acknowledged != original['quality_acknowledged']:
+ if item.production.model_dump(mode='json') != original['production'] or item.quality_status != original['quality_status'] or item.quality_acknowledged != original['quality_acknowledged'] or item.residue_accepted != original.get('residue_accepted', 0):
raise HTTPException(422, 'A montagem e a confirmação do cliente não podem mudar na revisão.')
names = {}
for upload_id in item.uploads:
@@ -75,7 +75,8 @@ def approve(c, row, items, reviewer):
priced.append({**price(item.mode, str(item.metres), item.grade, extra),
'uploads': original['uploads'], 'production': original['production'],
'quality_status': original['quality_status'],
- 'quality_acknowledged': original['quality_acknowledged']})
+ 'quality_acknowledged': original['quality_acknowledged'],
+ 'residue_accepted': original.get('residue_accepted', 0)})
metres = sum(Decimal(i['billed_metres']) for i in priced)
try:
quoted_freight = freight.quote(draft['freight']['service'], draft['freight'].get('postal_code', ''),
diff --git a/tests/artwork_browser_test.mjs b/tests/artwork_browser_test.mjs
index d0a8417..fbfad0e 100644
--- a/tests/artwork_browser_test.mjs
+++ b/tests/artwork_browser_test.mjs
@@ -334,6 +334,13 @@ try{
await waitFor(()=>evaluate(`$('aoVivo').textContent.includes('ponto de recorte') && itemAtual===null`),'residue stops the order');
assert.equal(await evaluate(`$('lista').textContent.includes('Sobrou 1 ponto de recorte na sua folha')`),true);
await waitFor(()=>evaluate(`folhas[0].previewSrc.startsWith('data:image/webp')`),'residue circled on the preview');
+ // Unless the customer accepts printing the dot (Dropstar, 2026-10-29): ticked,
+ // the sheet goes on and the item says how many dots were accepted.
+ assert.equal(await evaluate(`$('lista').textContent.includes('Esta arte tem 1 ponto menor que 2 mm. Estou ciente e aceito imprimir assim')`),true);
+ await click('[data-residuo="0"]');
+ await waitFor(()=>evaluate(`itemAtual?.residueAccepted===1 && !$('lista').textContent.includes('Sobrou 1 ponto')`),'accepted residue lets the sheet go on');
+ await click('[data-residuo="0"]');
+ await waitFor(()=>evaluate(`itemAtual===null && $('aoVivo').textContent.includes('ponto de recorte')`),'unticked, the residue stops it again');
await evaluate(`folhas=[];pintaFolha()`);
await evaluate('sendSheet({fundo:true})');
await waitFor(()=>evaluate(`folhas[0]?.an?.fundoChapado===true && itemAtual===null && $('aoVivo').textContent.includes('fundo transparente')`),'solid background stops the order');
diff --git a/tests/smoke_test.py b/tests/smoke_test.py
index fa0d3b6..381bf19 100644
--- a/tests/smoke_test.py
+++ b/tests/smoke_test.py
@@ -181,6 +181,9 @@ def run():
altered={**items[0],'production':{**items[0]['production'],
'sources':[{**items[0]['production']['sources'][0],'measurement':'file'}]}}
client.call('/operator/quotes/'+qid+'/approve',{'items':[altered,*items[1:]]},operator=True,expected=422)
+ # Nor does the review change the residue the customer accepted (Dropstar, 2026-10-29).
+ client.call('/operator/quotes/'+qid+'/approve',{'items':[{**items[0],'residue_accepted':2},*items[1:]]},
+ operator=True,expected=422)
# Reviewer corrects a browser-supplied grade and length. Browser values are proposals.
# One price per product (2026-10-23): the grade is kept, the price ignores it.
corrected=[{**items[0],'metres':'1.01','grade':0},*items[1:]]
@@ -205,6 +208,12 @@ def run():
assert seen['approved']['total_cents']==6132+int(os.environ.get('MOCK_FREIGHT_CENTS','1500'))
assert client.call('/quotes',small)['status']=='approved'
client.call('/operator/quotes/'+auto['id']+'/approve',{'items':small['items']},operator=True,expected=409)
+ # The residue dots the customer accepted printing stay with the item.
+ accepted={**small,'request_key':str(uuid4()),'items':[{**item_spec('avulsa','2.75',90,graded),'residue_accepted':3}]}
+ client.call('/quotes',{**accepted,'items':[{**accepted['items'][0],'residue_accepted':-1}]},expected=422)
+ kept=client.call('/quotes',accepted)
+ assert kept['status']=='approved'
+ assert client.call('/quotes/'+kept['id'])['approved']['items'][0]['residue_accepted']==3
# The Site grades only art it analysed. A grade on art it did not analyse
# is checked against the file like any other, and this one cannot be.
claimed={**item_spec('avulsa','2.75',0,uid),'grade':90}
diff --git a/web/checkout.js b/web/checkout.js
index 3a3f18f..328771b 100644
--- a/web/checkout.js
+++ b/web/checkout.js
@@ -20,6 +20,7 @@
mode:item.modo,metres:item.metros,grade:item.nota,production:item.production,
quality:item.qualityStatus,
acknowledged:item.qualityAcknowledged,
+ residue:item.residueAccepted||0,
files:(item.localFiles||[]).map(file=>({name:file.name,size:file.size,lastModified:file.lastModified}))
}))});
}
@@ -323,7 +324,8 @@
items.push({mode:item.modo, metres:String(item.metros), grade:item.nota, uploads,
production:{...item.production,sources:item.production.sources.map((source,index)=>({
upload_id:uploads[index],...source}))},
- quality_status:item.qualityStatus,quality_acknowledged:item.qualityAcknowledged});
+ quality_status:item.qualityStatus,quality_acknowledged:item.qualityAcknowledged,
+ residue_accepted:item.residueAccepted||0});
}
const service = entrega.tipo==='retira' ? 'pickup' : entrega.servico;
if (!service) throw new Error('A entrega ainda não está disponível. Escolha a retirada em Franca.');
diff --git a/web/kanban.js b/web/kanban.js
index 54992ad..51995cd 100644
--- a/web/kanban.js
+++ b/web/kanban.js
@@ -593,6 +593,10 @@ const TREATED_NOTE='O arquivo final foi preparado pela equipe, não é a arte qu
// 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);
const MIRROR_NOTE='O cliente espelhou a arte: confira antes de imprimir';
+// Residue dots under 2 mm the customer accepted printing (Dropstar, 2026-10-29).
+const residueNote=item=>{const many=item.residue_accepted>1;
+ return item.residue_accepted+(many?' pontos menores':' ponto menor')+' que 2 mm, que '+(many?'podem':'pode')+' se perder no recorte';};
+const residueBadge=item=>badge('! Resíduo aceito','warn','O cliente aceitou imprimir com '+residueNote(item));
// Two places per machine in Imprimindo (app/machines.py): the first to come
// in is printing, the next is being ripped meanwhile.
const PRINTING={imprimindo:['Imprimindo','ok','Já ripou, está rodando'],
@@ -771,6 +775,8 @@ function card(order){
if(order.printing)flags.append(badge(...PRINTING[order.printing]));
if(s.items.some(i=>i.quality_status==='warning'))flags.append(badge('! Ressalva','warn','O cliente aceitou a ressalva de resolução'));
if(s.items.some(mirroredItem))flags.append(badge('Espelhado','bad',MIRROR_NOTE));
+ const dots=s.items.reduce((t,i)=>t+(i.residue_accepted||0),0);
+ if(dots)flags.append(residueBadge({residue_accepted:dots}));
if(stalled(order))flags.append(badge('⏱ Parado '+hoursSince(order.updated_at)+' h','bad','Sem mudar de etapa desde '+when(order.updated_at)));
if(waitingContact(order))flags.append(badge('☎ Aguardando contato','warn',order.contact_note+' · '+contactWho(order)));
if(needsProof(order))flags.append(order.proof_ok_at
@@ -1154,6 +1160,7 @@ function itemCard(order,item,index){
body.append(title,facts([['Folha',sheetSize(spec)],['Peças',spec?String(spec.placements.length):null],
['Metro',item.unit_cents?money(item.unit_cents)+manualExtra(item):null],['Arquivos',spec&&spec.sources.length>1?String(spec.sources.length):null]]));
if(item.quality_status==='warning')body.append(badge('! Ressalva de resolução aceita','warn'));
+ if(item.residue_accepted){const r=node('div',undefined,'file');r.append(icon(ICON_WARN),node('span','Resíduo aceito pelo cliente: '+residueNote(item)+'.','warn'));body.append(r);}
// After a customer correction, that file is the artwork: the generated
// print file, or the reason it could not be made, no longer applies.
const fix=(order.corrections||[]).find(f=>f.item_index===index);
@@ -1766,6 +1773,7 @@ function quoteItem(item,fields,priced){
const chips=node('div',undefined,'flags');
chips.append(item.quality_status==='ok'?badge('✓ Qualidade conferida','ok'):item.quality_status==='warning'?
badge(item.quality_acknowledged?'! Ressalva aceita pelo cliente':'! Ressalva não aceita','warn'):badge('Qualidade não conferida',''));
+ if(item.residue_accepted)chips.append(residueBadge(item));
body.append(chips);
if(fields){
const grid=node('div',undefined,'fields');
diff --git a/web/site-cart.js b/web/site-cart.js
index 930078c..44f93e5 100644
--- a/web/site-cart.js
+++ b/web/site-cart.js
@@ -129,6 +129,8 @@ function carrinho(){
qualityStatus:$('ciente').classList.contains('recusa')?'rejected':
$('ciente').classList.contains('on')?'warning':nota===0?'unverified':'ok',
qualityAcknowledged:false,
+ // The residue dots the customer accepted printing (Dropstar, 2026-10-29).
+ residueAccepted:ehFolha()?residuosAceitos():0,
desc:fmtM(cob)+' m · '+rs(unit)+'/m · nota '+nota};
pintaPedido();
previa();
diff --git a/web/site-pdf.js b/web/site-pdf.js
index 4bf751c..12d7027 100644
--- a/web/site-pdf.js
+++ b/web/site-pdf.js
@@ -439,7 +439,7 @@ function pintaProgressoFolha(x){
}
// What the check found, as chips: ok (verde), av (atenção), er (resolva você),
// fix (arrumamos de graça), nt (a equipe confere). Details stay one click away.
-function chipsDaFolha(a){
+function chipsDaFolha(a,aceito){
const chip=(k,t)=>'
'+t+'
';
const dpi = a.vetor ? chip('ok','Arte vetorial')
: chip(a.dpi>=DPI_AVISA?'ok':a.dpi>=DPI_RECUSA?'av':'er', a.dpi+' DPI');
@@ -447,12 +447,15 @@ function chipsDaFolha(a){
// Sem transparência a folha inteira é uma peça só: não há resíduo a contar.
if(a.fundoChapado) return dpi+chip('er','Fundo chapado');
return dpi+chip('ok','Fundo transparente')+
- (a.residuos? chip('er',a.residuos+' resíduo'+(a.residuos>1?'s':'')) : chip('ok','Sem resíduos'))+
+ (a.residuos? chip(aceito?'av':'er',a.residuos+' resíduo'+(a.residuos>1?'s':'')+(aceito?' aceito'+(a.residuos>1?'s':''):''))
+ : chip('ok','Sem resíduos'))+
(a.encostadas? chip('fix',a.encostadas+' peças coladas · separamos grátis') : chip('ok','Peças separadas'));
}
// Resíduo e fundo chapado barram o pedido (Dropstar, 21/10/2026): o texto diz
-// quantos pontos, onde estão e o que fazer, sem "arquivo com problema".
-function avisosDaFolha(a,nome){
+// quantos pontos, onde estão e o que fazer, sem "arquivo com problema". O
+// resíduo o cliente pode aceitar imprimir (29/10/2026); marcado, o aviso sai
+// e fica só o aceite.
+function avisosDaFolha(a,nome,i,aceito){
if(a.grande) return '';
if(a.fundoChapado) return /\.jpe?g$/i.test(nome||'')
? '
JPG não tem fundo transparente. O que parece branco na tela sai branco '+
@@ -461,10 +464,15 @@ function avisosDaFolha(a,nome){
'branco no filme. Exporte a folha com fundo transparente, em PNG ou PDF, e envie de novo.
'+(varios?'Sobraram ':'Sobrou ')+n+(varios?' pontos':' ponto')+
' de recorte na sua folha. São restos da remoção de fundo: não aparecem na sua tela, mas a '+
'impressora enxerga e imprime. Apague '+(varios?'os pontos':'o ponto')+' na ferramenta que você '+
- 'usou e envie de novo. '+(varios?'Os círculos vermelhos na prévia mostram onde estão.':'O círculo vermelho na prévia mostra onde está.')+'
';
+ 'usou e envie de novo. '+(varios?'Os círculos vermelhos na prévia mostram onde estão.':'O círculo vermelho na prévia mostra onde está.')+
+ ' Se '+(varios?'os pontos são':'o ponto é')+' da própria arte, marque abaixo.
'+aceite;
}
function detalhesDaFolha(a,i,aberto){
const linhas = a.grande
@@ -496,7 +504,8 @@ function pintaFolha(){
if(lido){
medida='
'+avisosDaFolha(a,x.f.name,i,residuoAceito(x))+
+ detalhesDaFolha(a,i,x.detAberto) : '')+
// Over 150 MB the browser cannot check a PDF: said before payment, as
// for a file opened by hand (Dropstar, 2026-10-23).
(x.pdfGrande? 'Conferência manual · sem conferência no site'+
@@ -567,6 +576,9 @@ function pintaFolha(){
$('lista').querySelectorAll('[data-rmf]').forEach(b=>b.addEventListener('click',()=>{
folhas.splice(+b.dataset.rmf,1); pintaFolha();
}));
+ $('lista').querySelectorAll('[data-residuo]').forEach(el=>el.addEventListener('change',()=>{
+ folhas[+el.dataset.residuo].residuoAceito=el.checked; pintaFolha();
+ }));
$('lista').querySelectorAll('[data-det]').forEach(d=>d.addEventListener('toggle',()=>{
folhas[+d.dataset.det].detAberto=d.open;
}));
diff --git a/web/site-quality.js b/web/site-quality.js
index 4825048..02a461f 100644
--- a/web/site-quality.js
+++ b/web/site-quality.js
@@ -4,8 +4,13 @@
scope and run top to bottom, exactly as the original did. */
// ── enviar
// Folha que a impressora estragaria: com resíduo de recorte ou sem fundo
-// transparente. Só vale para o que o navegador conferiu.
-const folhaBarrada=x=>!!(x.an && !x.an.grande && (x.an.fundoChapado || x.an.residuos));
+// transparente. Só vale para o que o navegador conferiu. O resíduo que o
+// cliente aceita imprimir (Dropstar, 29/10/2026: às vezes os pontos são da
+// arte) não barra; o fundo chapado barra sempre.
+const residuoAceito=x=>!!(x.residuoAceito && x.an && x.an.residuos);
+const folhaBarrada=x=>!!(x.an && !x.an.grande && (x.an.fundoChapado || (x.an.residuos && !residuoAceito(x))));
+// Quantos pontos o cliente aceitou imprimir, somadas as folhas: vai no item.
+const residuosAceitos=()=>folhas.filter(residuoAceito).reduce((t,x)=>t+x.an.residuos,0);
// Avalia sozinho conforme o cliente sobe e preenche. Devolve o que ainda falta,
// para a fila dizer em texto em vez de travar num botão.
function avaliar(){
@@ -27,7 +32,7 @@ function avaliar(){
if(barrada) return {pronto:false, falta:barrada.an.fundoChapado
? barrada.f.name+' está sem fundo transparente. Exporte a folha com fundo transparente, em PNG ou PDF, e envie de novo.'
: barrada.f.name+' tem '+barrada.an.residuos+' ponto'+(barrada.an.residuos>1?'s':'')+
- ' de recorte. Apague e envie de novo.'};
+ ' de recorte. Apague e envie de novo, ou marque que aceita imprimir assim.'};
metros=folhaTotalM();
reencaixado=false;
const ans=folhas.map(x=>x.an).filter(Boolean);
@@ -58,8 +63,8 @@ function avaliar(){
ans.some(a=>a.grande) ? ['ok','Arquivo grande','peças, resíduos e fundo conferidos pela equipe'] : null,
ans.some(a=>a.grande) ? null : ['ok', soma('artes')+' peças na folha',
Math.round(soma('aproveitamento')/ans.length)+'% da folha virou arte'],
- ans.some(a=>a.grande) ? null : soma('residuos') ? ['er','Resíduo de recorte',
- soma('residuos')+' ponto'+(soma('residuos')>1?'s':'')+' abaixo de 2 mm · a impressora imprime']
+ ans.some(a=>a.grande) ? null : soma('residuos') ? ['av','Resíduo aceito',
+ soma('residuos')+' ponto'+(soma('residuos')>1?'s':'')+' abaixo de 2 mm · você aceitou imprimir assim']
: ['ok','Sem resíduo de recorte','nada solto na folha'],
ans.some(a=>a.grande) ? null : soma('encostadas') ? ['fix', soma('encostadas')+' peças a menos de 5 mm',
'se forem artes diferentes, separamos com 5 mm sem custo']
diff --git a/web/site-v2.css b/web/site-v2.css
index 01b9240..6840a58 100644
--- a/web/site-v2.css
+++ b/web/site-v2.css
@@ -183,6 +183,11 @@ section+section{border-top:0}
.chipSo{align-self:flex-start;padding:5px 10px;border-radius:999px;background:#F1F1F1;color:var(--texto2);font-size:15px;font-weight:600}
.avisoF{margin:4px 0 0;padding:10px 12px;border-radius:10px;background:#FDE8E6;font-size:15px;line-height:1.5;color:var(--preto)}
.avisoF b{color:#B3261E}
+/* Aceite do resíduo (Dropstar, 29/10/2026): no lugar de barrar a folha. */
+/* .rep label (index.html) styles the small field labels: this one is a sentence. */
+.rep .aceiteRes{display:flex;gap:10px;align-items:flex-start;margin:6px 0 0;padding:10px 12px;border-radius:10px;
+ background:#FFF1DB;font-size:15px;line-height:1.5;color:var(--preto);cursor:pointer}
+.rep .aceiteRes input{width:18px;height:18px;margin:2px 0 0;flex:none;accent-color:#8A4B00;cursor:pointer}
.repTxt{margin:2px 0 0;font-size:15.5px;line-height:1.5;color:var(--texto2)}
.repTxt b{color:var(--preto)}
.confDet{font-size:15px}