feat: montador Interno and Venda, Tiny customers, brand per stamp (front 7a.3, Marcus 10/11)

Interno: the Expedição assembles the marketplace's own sales on the fixed
internal customer Gestão fills in once; no Tiny order, no paid e-mail,
marked interno, it stays in house. Venda: a Vendedor or Gestão picks the
customer from the Tiny base and the order goes to Tiny like an approved
quote, faturado (Boleto from TINY_RECEIPT_BOLETO when set), pickup or
'junto com o pedido de roupa nº X'. Números counts both at table price,
apart from cash (and the average ticket over cash orders only). Each stamp
can carry a brand and a public flag for the future catalogue.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-11 11:01:44 -03:00
parent e6197d6e40
commit b5a51137fb
15 changed files with 710 additions and 97 deletions

View File

@@ -181,14 +181,17 @@ async function loadStats(){
const mk=(label,value,unit)=>{const k=node('div',undefined,'mk');const b=node('b',value);if(unit)b.append(node('small',unit));k.append(node('span',label),b);return k;};
const pct=n=>data.orders?Math.round(100*n/data.orders)+'%':'';
const [reais,centavos]=money(data.cents).split(',');
// The ticket is the cash received over the cash orders only: an Interno or
// faturado order records the table price, not money received (front 7a.3).
const cashOrders=Math.max(0,Number(data.orders)-(data.price_table||[]).reduce((sum,row)=>sum+(row.orders||0),0));
const hero=node('div',undefined,'hero');
hero.append(hk('Metros vendidos',metres(data.metres).replace(' m',''),'m',plural(data.orders,'pedido pago','pedidos pagos')),
hk('Recebido, com frete',reais,','+centavos,data.orders?'ticket médio de '+money(Math.round(data.cents/data.orders)):''),
hk('Recebido, com frete',reais,','+centavos,cashOrders?'ticket médio de '+money(Math.round(data.cents/cashOrders)):''),
hk('Do pagamento ao Finalizado',duration(data.lead.median_hours),'',data.lead.orders?'mediana de '+plural(data.lead.orders,'pedido','pedidos')+', sem o tempo em Aguardando contato':'nenhum finalizado no período'));
const rw=data.rework, share=v=>v==null?'—':String(v).replace('.',',')+'%';
const minis=node('div',undefined,'minis');
minis.append(mk('Pedidos pagos',String(data.orders)),
mk('Ticket médio',data.orders?money(Math.round(data.cents/data.orders)):'—'),
mk('Ticket médio',cashOrders?money(Math.round(data.cents/cashOrders)):'—'),
mk('Com correção',String(data.corrected),pct(data.corrected)),
mk('Artes tratadas',String(data.treated.orders),pct(data.treated.orders)),
mk('Retrabalho da casa',share(rw.house.percent),'meta '+share(rw.house.goal_percent)),
@@ -211,6 +214,12 @@ async function loadStats(){
tr.append(node('td',ORIGINS[o.origin]),node('td',String(o.orders),'r'),node('td',metres(o.metres).replace(' m',''),'r'),node('td',money(o.cents),'r'),
node('td',o.finished?duration(o.median_hours):'—','r'));
if(!o.orders)tr.classList.add('off');return tr;}));
// The montador's table price, apart from the money received (front 7a.3).
const priceNames={faturado:'Faturado',interno:'Interno'};
$('stats-price-table').replaceChildren(...(data.price_table||[]).map(p=>{const tr=node('tr');
tr.append(node('td',priceNames[p.method]||p.method),node('td',String(p.orders),'r'),
node('td',metres(p.metres).replace(' m',''),'r'),node('td',money(p.cents),'r'));
if(!p.orders)tr.classList.add('off');return tr;}));
// Approved orders never paid: made, paid, expired and the abandonment rate.
const unpaid=data.unpaid;
const unpaidRows=[['Pedidos feitos',String(unpaid.made)],['Pagos',String(unpaid.paid)],