feat: a Números tab with the production numbers the board already records
Every paid order and every move is recorded, but nobody could see the totals. The new tab shows, for the last 7, 30 or 90 days: paid orders, metres sold, money received, the average ticket, how many orders needed a correction, and the median time from payment to Finalizado. A column per day charts the metres sold (with a table under it), and a table gives each stage's median time and what waits in it now, with the oldest order. Test and cancelled orders stay out. The header now has five tabs: the search box narrows first, the refresh picker keeps its width, and the operator's e-mail moves to Sair's tooltip on narrower screens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -624,6 +624,63 @@ def thumbnail(uid: UUID, user=Depends(operator)):
|
||||
return Response(bytes(row['data']), media_type=row['mime'],
|
||||
headers={'Cache-Control': 'private, max-age=86400', 'Content-Disposition': 'inline'})
|
||||
|
||||
# Real work only: an operator's test order and a cancelled one are not production.
|
||||
REAL_ORDER = "o.cancelled_at IS NULL AND COALESCE(o.payment->>'provider','') <> 'teste'"
|
||||
LOCAL_DAY = "(o.created_at AT TIME ZONE 'America/Sao_Paulo')::date"
|
||||
|
||||
|
||||
@router.get('/api/operator/stats')
|
||||
def production_stats(days: int = Query(default=30, ge=7, le=365), user=Depends(operator)):
|
||||
"""Production numbers from what the board already records: orders paid in
|
||||
the period, how long each stage holds an order, and what is waiting now."""
|
||||
# From the start of the first local day of the period.
|
||||
since = ("o.created_at >= (((now() AT TIME ZONE 'America/Sao_Paulo')::date - make_interval(days => %s - 1))"
|
||||
" AT TIME ZONE 'America/Sao_Paulo')")
|
||||
metres = "(SELECT COALESCE(sum((i->>'billed_metres')::numeric),0) FROM jsonb_array_elements(o.snapshot->'items') i)"
|
||||
with db.connect() as c:
|
||||
total = c.execute(f'''SELECT count(*) AS orders, COALESCE(sum((o.snapshot->>'total_cents')::bigint),0) AS cents,
|
||||
COALESCE(sum({metres}),0) AS metres,
|
||||
count(*) FILTER (WHERE EXISTS (SELECT 1 FROM dtf_local.movements m WHERE m.order_id=o.id
|
||||
AND m.to_state='cor' AND NOT m.back)) AS corrected
|
||||
FROM dtf_local.orders o WHERE {REAL_ORDER} AND {since}''', (days,)).fetchone()
|
||||
daily = {row['day']: row for row in c.execute(f'''SELECT {LOCAL_DAY} AS day, count(*) AS orders,
|
||||
COALESCE(sum({metres}),0) AS metres FROM dtf_local.orders o WHERE {REAL_ORDER} AND {since}
|
||||
GROUP BY 1''', (days,)).fetchall()}
|
||||
# Each order's stages as spans: from entering a stage to the next move.
|
||||
spans = f'''WITH events AS (
|
||||
SELECT o.id, 'rec' AS state, o.created_at AS at FROM dtf_local.orders o WHERE {REAL_ORDER} AND {since}
|
||||
UNION ALL
|
||||
SELECT m.order_id, m.to_state, m.created_at FROM dtf_local.movements m
|
||||
JOIN dtf_local.orders o ON o.id=m.order_id WHERE {REAL_ORDER} AND {since})
|
||||
SELECT id, state, at, LEAD(at) OVER (PARTITION BY id ORDER BY at) AS until FROM events'''
|
||||
stages = c.execute(f'''SELECT state, count(*) AS orders,
|
||||
percentile_cont(0.5) WITHIN GROUP (ORDER BY extract(epoch FROM until-at)) / 3600 AS median_hours
|
||||
FROM ({spans}) s WHERE until IS NOT NULL GROUP BY state''', (days, days)).fetchall()
|
||||
lead = c.execute(f'''SELECT count(*) AS orders, percentile_cont(0.5) WITHIN GROUP (ORDER BY extract(epoch FROM
|
||||
f.at - o.created_at)) / 3600 AS median_hours FROM dtf_local.orders o
|
||||
JOIN LATERAL (SELECT min(created_at) AS at FROM dtf_local.movements m WHERE m.order_id=o.id AND m.to_state='fin') f
|
||||
ON f.at IS NOT NULL
|
||||
WHERE {REAL_ORDER} AND {since}''', (days,)).fetchone()
|
||||
# What waits now, however old, and since when in its stage.
|
||||
waiting = c.execute(f'''SELECT o.state, count(*) AS orders, max(extract(epoch FROM now() - COALESCE(
|
||||
(SELECT max(m.created_at) FROM dtf_local.movements m WHERE m.order_id=o.id AND m.to_state=o.state),
|
||||
o.created_at))) / 3600 AS oldest_hours
|
||||
FROM dtf_local.orders o WHERE {REAL_ORDER} AND o.state<>'fin' GROUP BY o.state''').fetchall()
|
||||
today = datetime.now(timezone(timedelta(hours=-3))).date()
|
||||
series = []
|
||||
for offset in range(days - 1, -1, -1):
|
||||
day = today - timedelta(days=offset)
|
||||
row = daily.get(day)
|
||||
series.append({'day': day.isoformat(), 'orders': row['orders'] if row else 0,
|
||||
'metres': float(row['metres']) if row else 0.0})
|
||||
hours = lambda value: round(float(value), 1) if value is not None else None
|
||||
return {'days': days, 'orders': total['orders'], 'cents': int(total['cents']), 'metres': float(total['metres']),
|
||||
'corrected': total['corrected'], 'daily': series,
|
||||
'lead': {'orders': lead['orders'], 'median_hours': hours(lead['median_hours'])},
|
||||
'stages': {row['state']: {'orders': row['orders'], 'median_hours': hours(row['median_hours'])} for row in stages},
|
||||
'waiting': {row['state']: {'orders': row['orders'], 'oldest_hours': hours(row['oldest_hours'])} for row in waiting}}
|
||||
|
||||
|
||||
@router.get('/api/operator/queue/finals')
|
||||
def queue_finals(user=Depends(operator)):
|
||||
"""The approved final files of every order in the print queue, in queue
|
||||
|
||||
@@ -113,7 +113,20 @@ def run():
|
||||
|
||||
board = client.call('/operator/board', operator=True)
|
||||
assert str(uid) in board['thumbnails']
|
||||
print('PASS: artwork pictures (owner only, images only), quote filters and the order/quote search')
|
||||
|
||||
# Numbers count real paid orders only: this test order counts once it is not one.
|
||||
before = client.call('/operator/stats?days=7', operator=True)
|
||||
with db.connect() as c:
|
||||
c.execute("UPDATE dtf_local.orders SET payment=%s WHERE id=%s",
|
||||
(Jsonb({'provider': 'mercadopago', 'id': f'kanban-{tag}'}), order_id))
|
||||
after = client.call('/operator/stats?days=7', operator=True)
|
||||
assert len(after['daily']) == 7
|
||||
assert (after['orders'], after['cents']) == (before['orders'] + 1, before['cents'] + 1490), (before, after)
|
||||
assert after['daily'][-1]['orders'] == before['daily'][-1]['orders'] + 1
|
||||
assert after['waiting']['rec']['orders'] == before.get('waiting', {}).get('rec', {}).get('orders', 0) + 1
|
||||
client.call('/operator/stats?days=3', operator=True, expected=422)
|
||||
Client().call('/operator/stats', expected=401)
|
||||
print('PASS: artwork pictures (owner only, images only), quote filters, the order/quote search and the numbers')
|
||||
finally:
|
||||
with db.connect() as c:
|
||||
c.execute('DELETE FROM dtf_local.orders WHERE id=%s', (order_id,))
|
||||
|
||||
@@ -51,8 +51,8 @@ input[type=file]{font-size:14px;color:var(--muted);max-width:100%}
|
||||
.tabs button{display:flex;align-items:center;gap:8px;padding:0 14px;border:0;border-bottom:2px solid transparent;background:none;color:var(--muted);font-weight:600;font-size:14.5px}
|
||||
.tabs button[aria-selected=true]{color:var(--tx);font-weight:700;border-bottom-color:var(--accent)}
|
||||
.tabs .count{font-family:var(--mono);font-size:13.5px;color:var(--muted)}
|
||||
.searchbox{position:relative;margin-left:auto}
|
||||
.search{display:flex;align-items:center;gap:8px;width:380px;height:38px;padding:0 12px;border:1px solid var(--line2);border-radius:9px;background:var(--card);color:var(--faint)}
|
||||
.searchbox{position:relative;margin-left:auto;flex:0 1 380px;min-width:200px}
|
||||
.search{display:flex;align-items:center;gap:8px;width:100%;box-sizing:border-box;height:38px;padding:0 12px;border:1px solid var(--line2);border-radius:9px;background:var(--card);color:var(--faint)}
|
||||
.search:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px rgba(255,139,43,.18)}
|
||||
.search input{flex:1;min-width:0;border:0;background:transparent;height:auto;padding:0;outline:none}
|
||||
.search kbd{font:inherit;font-size:12px;padding:0 6px;border:1px solid var(--line3);border-radius:5px;color:var(--faint)}
|
||||
@@ -74,6 +74,8 @@ input[type=file]{font-size:14px;color:var(--muted);max-width:100%}
|
||||
.tinydot::before{content:"";width:8px;height:8px;border-radius:999px;background:var(--dot,#5B6168)}
|
||||
.tinydot:empty{display:none}
|
||||
.who{font-size:14px;color:var(--muted);white-space:nowrap;max-width:220px;overflow:hidden;text-overflow:ellipsis}
|
||||
/* With five tabs, the operator's e-mail is the first thing to give way; it stays on Sair's tooltip. */
|
||||
@media (max-width:1560px){.who{display:none}}
|
||||
#status{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:20;margin:0;max-width:min(640px,calc(100vw - 32px));padding:10px 16px;border-radius:10px;border:1px solid var(--line3);background:#1E2226;color:var(--tx);font-size:14px;box-shadow:0 10px 30px rgba(0,0,0,.45)}
|
||||
#status:empty,#login-status:empty{display:none}
|
||||
#status.error{border-color:var(--bad-line);color:var(--bad)}
|
||||
@@ -222,6 +224,28 @@ main{padding:0 24px 24px}
|
||||
.field select,.field input{height:38px;min-width:160px;padding:0 10px;border-radius:8px;border:1px solid var(--line3);background:var(--bg);color:var(--tx)}
|
||||
.field input{min-width:110px;width:110px}
|
||||
.issue input{width:320px}
|
||||
.pagehead{display:flex;align-items:center;gap:16px;flex-wrap:wrap}
|
||||
.statchips{display:flex;gap:8px;margin-left:auto}
|
||||
.stats-note{margin:-12px 0 0;font-size:13.5px}
|
||||
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}
|
||||
.kpi{display:flex;flex-direction:column;gap:4px;padding:14px 16px;border:1px solid var(--line2);border-radius:12px;background:var(--card)}
|
||||
.kpi span{font-size:13.5px;color:var(--muted)}
|
||||
.kpi b{font-size:24px;font-weight:700;letter-spacing:-.01em;font-variant-numeric:proportional-nums}
|
||||
.kpi small{font-size:13px;color:var(--faint)}
|
||||
.statbox{padding:16px 18px;border:1px solid var(--line2);border-radius:12px;background:var(--card)}
|
||||
.chart{position:relative}
|
||||
.chart svg{display:block;width:100%;height:auto}
|
||||
.chart .grid{stroke:var(--line);stroke-width:1}
|
||||
.chart .tick{fill:var(--faint);font-size:12px;font-family:var(--mono)}
|
||||
.chart .bar{fill:var(--accent)}
|
||||
.chart .hit{fill:transparent;cursor:default}
|
||||
.chart .hit:hover{fill:rgba(255,255,255,.03)}
|
||||
.chart .tip{position:absolute;transform:translate(-50%,calc(-100% - 8px));pointer-events:none;padding:6px 10px;border-radius:8px;
|
||||
background:var(--card2);border:1px solid var(--line3);font-size:13px;white-space:nowrap;color:var(--tx)}
|
||||
.charttable{margin-top:10px;font-size:13.5px;color:var(--muted)}
|
||||
.charttable summary{cursor:pointer}
|
||||
.charttable table{margin-top:8px}
|
||||
#stats-stages .swatch{display:inline-block;width:10px;height:10px;border-radius:3px;background:var(--c);margin-right:8px}
|
||||
.grid4{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px}
|
||||
.integration{display:flex;flex-direction:column;gap:10px;padding:16px;border-radius:12px;border:1px solid var(--line2);background:var(--card)}
|
||||
.integration .head{display:flex;align-items:center;gap:8px}
|
||||
@@ -237,7 +261,7 @@ table.log td{padding:10px 12px;border-bottom:1px solid #1E2226;vertical-align:to
|
||||
|
||||
@media (max-width:900px){
|
||||
.top{flex-wrap:wrap;height:auto;padding:10px 16px;gap:10px}
|
||||
.searchbox{order:5;width:100%;margin-left:0}
|
||||
.searchbox{order:5;width:100%;flex-basis:100%;margin-left:0}
|
||||
.search{width:100%}
|
||||
.results{width:100%}
|
||||
main{padding:0 16px 16px}
|
||||
@@ -393,7 +417,7 @@ a.zap{display:inline-flex;align-items:center;gap:4px;vertical-align:bottom}
|
||||
.card.drop-after{box-shadow:0 3px 0 0 var(--accent)}
|
||||
|
||||
/* "Atualizar" and how often it happens by itself, as one control. */
|
||||
.refresh{display:inline-flex;align-items:stretch;border:1px solid var(--line2);border-radius:8px;overflow:hidden}
|
||||
.refresh{flex-shrink:0;display:inline-flex;align-items:stretch;border:1px solid var(--line2);border-radius:8px;overflow:hidden}
|
||||
.refresh .btn{border:0;border-radius:0;display:inline-flex;align-items:center;gap:6px}
|
||||
.refresh select{height:36px;padding:0 28px 0 10px;border:0;border-left:1px solid var(--line2);background:transparent;color:var(--muted);font:inherit;font-size:13.5px;font-weight:600;cursor:pointer}
|
||||
.refresh select{width:88px;height:36px;padding:0 24px 0 10px;border:0;border-left:1px solid var(--line2);background:transparent;color:var(--muted);font:inherit;font-size:13.5px;font-weight:600;cursor:pointer}
|
||||
.refresh select option{background:var(--card);color:var(--tx)}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<button type="button" data-tab="board" aria-selected="true">Produção <span class="count" id="count-board"></span></button>
|
||||
<button type="button" data-tab="quotes" aria-selected="false">Cotações <span class="badge" id="badge-quotes"></span></button>
|
||||
<button type="button" data-tab="payments" aria-selected="false">Pagamentos <span class="badge warn" id="badge-payments"></span></button>
|
||||
<button type="button" data-tab="stats" aria-selected="false">Números</button>
|
||||
<button type="button" data-tab="integrations" aria-selected="false">Integrações</button>
|
||||
</nav>
|
||||
<div class="searchbox">
|
||||
@@ -67,6 +68,15 @@
|
||||
<h1>Pagamentos</h1>
|
||||
<section id="payments"></section>
|
||||
</section>
|
||||
<section id="tab-stats" class="page" hidden>
|
||||
<div class="pagehead"><h1>Números</h1><div class="statchips" id="stats-period"></div></div>
|
||||
<p class="faint stats-note">Pedidos pagos no período. Pedidos de teste e cancelados ficam de fora.</p>
|
||||
<div class="kpis" id="stats-kpis"></div>
|
||||
<section class="statbox"><h2>Metros por dia</h2><div class="chart" id="stats-chart"></div></section>
|
||||
<section class="statbox"><h2>Tempo em cada etapa</h2>
|
||||
<table class="log"><thead><tr><th scope="col">Etapa</th><th scope="col">Tempo mediano</th><th scope="col">Pedidos que passaram</th><th scope="col">Agora</th></tr></thead><tbody id="stats-stages"></tbody></table>
|
||||
</section>
|
||||
</section>
|
||||
<section id="tab-integrations" class="page" hidden>
|
||||
<h1>Integrações</h1>
|
||||
<section><div class="grid4" id="integrations"></div></section>
|
||||
|
||||
@@ -253,18 +253,18 @@ async function load(quiet=false){
|
||||
function showTab(name){
|
||||
tab=name;
|
||||
for(const b of document.querySelectorAll('[data-tab]'))b.setAttribute('aria-selected',String(b.dataset.tab===name));
|
||||
for(const id of ['board','quotes','payments','integrations'])$('tab-'+id).hidden=name!==id;
|
||||
const lists={quotes:loadQuotes,payments:loadIssues,integrations:loadEvents};
|
||||
for(const id of ['board','quotes','payments','stats','integrations'])$('tab-'+id).hidden=name!==id;
|
||||
const lists={quotes:loadQuotes,payments:loadIssues,stats:loadStats,integrations:loadEvents};
|
||||
if(board&&lists[name])lists[name]().catch(e=>say(e.message,true));
|
||||
}
|
||||
function render(){
|
||||
$('who').textContent=board.operator||'';
|
||||
$('who').textContent=board.operator||'';$('logout').title=board.operator?'Sair ('+board.operator+')':'Sair';
|
||||
$('count-board').textContent=String(board.orders.filter(o=>o.state!=='fin'&&!o.cancelled_at).length);
|
||||
$('badge-quotes').textContent=board.pending_total?String(board.pending_total):'';
|
||||
$('badge-payments').textContent=board.payment_issues_total?String(board.payment_issues_total):'';
|
||||
tinyHeader();renderBoard();renderIntegrations();
|
||||
// Lists live on their own pages of the API; refresh the one being looked at.
|
||||
const lists={quotes:loadQuotes,payments:loadIssues,integrations:loadEvents};
|
||||
const lists={quotes:loadQuotes,payments:loadIssues,stats:loadStats,integrations:loadEvents};
|
||||
if(lists[tab])lists[tab]().catch(e=>say(e.message,true));
|
||||
if(openOrder){const order=board.orders.find(o=>o.id===openOrder);if(order)renderPanel(order);else closePanel();}
|
||||
}
|
||||
@@ -759,6 +759,75 @@ function historySection(order,rows,section){
|
||||
section.replaceChildren(node('p','Histórico','eyebrow'),list);
|
||||
}
|
||||
|
||||
// ---- Numbers -------------------------------------------------------------
|
||||
|
||||
let statsDays=30;
|
||||
function duration(hours){
|
||||
if(hours===null||hours===undefined)return '—';
|
||||
if(hours<1)return Math.max(1,Math.round(hours*60))+' min';
|
||||
if(hours<48)return (hours<10?hours.toFixed(1):Math.round(hours).toString()).replace('.',',')+' h';
|
||||
return Math.round(hours/24)+' dias';
|
||||
}
|
||||
async function loadStats(){
|
||||
const data=await api('/stats?days='+statsDays);
|
||||
$('stats-period').replaceChildren(...[[7,'7 dias'],[30,'30 dias'],[90,'90 dias']].map(([days,label])=>{
|
||||
const b=node('button',label,'chip');b.type='button';b.setAttribute('aria-pressed',String(days===statsDays));
|
||||
b.onclick=()=>{statsDays=days;loadStats().catch(e=>say(e.message,true));};return b;}));
|
||||
const kpi=(label,value,note)=>{const k=node('div',undefined,'kpi');k.append(node('span',label),node('b',value));if(note)k.append(node('small',note));return k;};
|
||||
const pct=data.orders?Math.round(100*data.corrected/data.orders):0;
|
||||
$('stats-kpis').replaceChildren(
|
||||
kpi('Pedidos pagos',String(data.orders)),
|
||||
kpi('Metros vendidos',metres(data.metres)),
|
||||
kpi('Recebido',money(data.cents),'com frete'),
|
||||
kpi('Ticket médio',data.orders?money(Math.round(data.cents/data.orders)):'—'),
|
||||
kpi('Pedidos com correção',String(data.corrected),data.orders?pct+'% dos pedidos':null),
|
||||
kpi('Do pagamento ao Finalizado',duration(data.lead.median_hours),data.lead.orders?'mediana de '+data.lead.orders+' pedidos':'nenhum finalizado'));
|
||||
statsChart($('stats-chart'),data.daily);
|
||||
const rows=['rec','tra','fil','imp','cor'].map(state=>{
|
||||
const tr=node('tr'),name=node('td'),sw=node('span',undefined,'swatch');sw.style.setProperty('--c',STAGE_COLORS[state]);
|
||||
name.append(sw,board.states[state]);
|
||||
const st=data.stages[state], now=data.waiting[state];
|
||||
tr.append(name,node('td',st?duration(st.median_hours):'—'),node('td',st?String(st.orders):'0'),
|
||||
node('td',now?now.orders+(now.orders>1?' pedidos':' pedido')+' · o mais antigo há '+duration(now.oldest_hours):'nenhum'));
|
||||
return tr;});
|
||||
$('stats-stages').replaceChildren(...rows);
|
||||
}
|
||||
// Metres per day: one series, columns from one baseline, a tooltip per day
|
||||
// and the same numbers as a table under the chart.
|
||||
function statsChart(box,daily){
|
||||
const ns='http://www.w3.org/2000/svg', w=Math.max(320,box.clientWidth||800), h=220, left=44, bottom=26, top=10;
|
||||
const max=Math.max(...daily.map(d=>d.metres),0);
|
||||
const step=max<=0?1:(()=>{const raw=max/4, p=10**Math.floor(Math.log10(raw)), f=raw/p;return (f<=1?1:f<=2?2:f<=5?5:10)*p;})();
|
||||
const ceiling=step*Math.max(1,Math.ceil(max/step));
|
||||
const svg=document.createElementNS(ns,'svg');svg.setAttribute('viewBox','0 0 '+w+' '+h);svg.setAttribute('role','img');
|
||||
svg.setAttribute('aria-label','Metros vendidos por dia nos últimos '+daily.length+' dias');
|
||||
const el=(tag,attrs)=>{const e=document.createElementNS(ns,tag);for(const [k,v] of Object.entries(attrs))e.setAttribute(k,v);return e;};
|
||||
const y=v=>top+(h-top-bottom)*(1-v/ceiling);
|
||||
for(let v=0;v<=ceiling+1e-9;v+=step){
|
||||
svg.append(el('line',{x1:left,x2:w,y1:y(v),y2:y(v),class:'grid'}));
|
||||
const t=el('text',{x:left-8,y:y(v)+4,class:'tick','text-anchor':'end'});t.textContent=v.toLocaleString('pt-BR');svg.append(t);
|
||||
}
|
||||
const band=(w-left)/daily.length, bar=Math.min(24,Math.max(2,band-2));
|
||||
const tip=node('div',undefined,'tip');tip.hidden=true;
|
||||
const label=d=>new Date(d.day+'T12:00:00').toLocaleDateString('pt-BR',{day:'2-digit',month:'2-digit'});
|
||||
const every=Math.ceil(daily.length/8);
|
||||
daily.forEach((d,i)=>{
|
||||
const x=left+band*i+(band-bar)/2, top_=y(d.metres), base=y(0), r=Math.min(4,bar/2,base-top_);
|
||||
if(d.metres>0)svg.append(el('path',{class:'bar',d:`M${x},${base}V${top_+r}Q${x},${top_} ${x+r},${top_}H${x+bar-r}Q${x+bar},${top_} ${x+bar},${top_+r}V${base}Z`}));
|
||||
if((daily.length-1-i)%every===0){const t=el('text',{x:x+bar/2,y:h-8,class:'tick','text-anchor':'middle'});t.textContent=label(d);svg.append(t);}
|
||||
const hit=el('rect',{x:left+band*i,y:top,width:band,height:h-top-bottom,class:'hit'});
|
||||
hit.onmouseenter=()=>{tip.hidden=false;tip.textContent=label(d)+' · '+d.orders+(d.orders===1?' pedido':' pedidos')+' · '+metres(d.metres);
|
||||
tip.style.left=(100*(x+bar/2)/w)+'%';tip.style.top=(100*Math.min(top_,base-4)/h)+'%';};
|
||||
hit.onmouseleave=()=>{tip.hidden=true;};
|
||||
svg.append(hit);
|
||||
});
|
||||
const table=node('details',undefined,'charttable');table.append(node('summary','Ver em tabela'));
|
||||
const t=node('table',undefined,'log');const head=node('tr');head.append(node('th','Dia'),node('th','Pedidos'),node('th','Metros'));t.append(head);
|
||||
for(const d of [...daily].reverse()){const tr=node('tr');tr.append(node('td',label(d)),node('td',String(d.orders)),node('td',metres(d.metres)));t.append(tr);}
|
||||
table.append(t);
|
||||
box.replaceChildren(svg,tip,table);
|
||||
}
|
||||
|
||||
// ---- Quotes --------------------------------------------------------------
|
||||
|
||||
function quoteMetres(q){return (q.approved||q.draft).items.reduce((s,i)=>s+Number(i.billed_metres||i.metres),0);}
|
||||
|
||||
Reference in New Issue
Block a user