From f4cd1842ca3878877648d8985072cf1d6d679fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Fri, 6 Nov 2026 13:15:30 -0300 Subject: [PATCH] fix: Atrasados lists production stages and real orders only (front 11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A delivery is done when it leaves and a test card is not production. Only pickup orders waiting in Finalizado can be late, and the top strip now shows working columns; the finished pickup keeps its card colour and its place in Números. --- app/api/operator.py | 9 +++++++-- tests/stage_limits_test.py | 4 +++- web/kanban.html | 2 +- web/kanban.js | 7 ++++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/api/operator.py b/app/api/operator.py index 69f8390..12bce5b 100644 --- a/app/api/operator.py +++ b/app/api/operator.py @@ -245,10 +245,15 @@ def assign_late(c, orders, limits): entered[(str(row['order_id']), row['to_state'])] = row['created_at'] now = datetime.now(timezone.utc) for order in orders: - if order.get('cancelled_at'): + if order.get('cancelled_at') or payments.is_test(order): continue limit = limits.get(order['state']) - if not limit or (order['state'] == 'fin' and order.get('picked_up_at')): + if not limit: + continue + # Finalizado only has a pickup deadline; a delivery is done when it + # leaves, and a collected order is not waiting for anyone. + if order['state'] == 'fin' and (order.get('picked_up_at') or + not receipt.is_pickup(order['snapshot'])): continue since = entered.get((str(order['id']), order['state'])) if not since and order['state'] == 'fin': diff --git a/tests/stage_limits_test.py b/tests/stage_limits_test.py index 99a5b6d..88d75a0 100644 --- a/tests/stage_limits_test.py +++ b/tests/stage_limits_test.py @@ -22,7 +22,9 @@ def run(): owner = uuid4() with db.connect() as c: quote, order = order_fixture(c, owner, 'file') - c.execute("UPDATE dtf_local.orders SET created_at=now()-interval '3 hours' WHERE id=%s", (order,)) + c.execute("""UPDATE dtf_local.orders SET created_at=now()-interval '3 hours', + payment=%s WHERE id=%s""", + (Jsonb({'provider': 'mercadopago', 'id': str(order)}), order)) try: board = client.call('/operator/board', operator=True) mine = next(o for o in board['orders'] if o['id'] == str(order)) diff --git a/web/kanban.html b/web/kanban.html index 786484a..94683ce 100644 --- a/web/kanban.html +++ b/web/kanban.html @@ -140,7 +140,7 @@

Da casa, por quem imprimiu

Aguardando autorização

-

Tempo em cada etapa

+

Tempo em cada etapa

EtapaMedianaAceitávelEstourosAgora

Velocidade do site e do Prumo

diff --git a/web/kanban.js b/web/kanban.js index 94623fc..3f289a7 100644 --- a/web/kanban.js +++ b/web/kanban.js @@ -846,7 +846,10 @@ let phoneCol='rec'; // responsible for that column, above the board. function renderLatebar(){ const bar=$('latebar'); - const late=board.orders.filter(o=>!o.cancelled_at&&o.late) + // The top strip is for production delays. A pickup waiting in Finalizado + // keeps its yellow/red card and is counted in Números; it does not push + // every historical finished order across the top of the board. + const late=board.orders.filter(o=>!o.cancelled_at&&!isTest(o)&&o.late&&o.state!=='fin') .sort((a,b)=>(b.state_hours||0)-(a.state_hours||0)); if(!late.length){bar.hidden=true;bar.replaceChildren();return;} bar.hidden=false; @@ -2545,6 +2548,8 @@ function calendar(){ } async function loadStats(){ const data=await api('/stats?'+(statsRange?'start='+statsRange.start+'&end='+statsRange.end:'days='+statsDays)); + const editLimits=$('edit-stage-limits'); + if(editLimits){editLimits.hidden=!may('manage');editLimits.onclick=()=>stageLimitsDialog();} statsData=data;statsPeriod(); $('stats-note').textContent='Pedidos pagos de '+dayLabel(data.start)+' a '+dayLabel(data.end)+', sem testes e cancelados'; const hk=(label,value,unit,note)=>{const k=node('div',undefined,'hk');const b=node('b',value);if(unit)b.append(node('small',unit));