feat: an approved order nobody paid expires in 24 h (front 9)
All checks were successful
Build and deploy / Validate source (push) Successful in 1m15s
Build and deploy / Integration suite on a real stack (push) Successful in 5m10s
Build and deploy / Secret scan and release gate (push) Successful in 11s
Build and deploy / Publish images (push) Successful in 1m29s
All checks were successful
Build and deploy / Validate source (push) Successful in 1m15s
Build and deploy / Integration suite on a real stack (push) Successful in 5m10s
Build and deploy / Secret scan and release gate (push) Successful in 11s
Build and deploy / Publish images (push) Successful in 1m29s
An approved quote with no payment expires on its own after 24 h, never while a Pix or card attempt is still live: the worker marks quotes.expired_at, frees its files and e-mails the customer that the order expired and can be sent again on the Site. The backlog from before this front expires silently. Kanban: Cotações › Aguardando pagamento shows when each one expires and the review gets an "Abrir conversa" WhatsApp button; Números gets "Pedidos sem pagamento" (made, paid, expired, waiting, abandonment rate). release_files moves to app/payments.py so the worker can use it; an expired quote no longer counts as open there. New tests/unpaid_test.py in the integration job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2609,6 +2609,13 @@ 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;}));
|
||||
// 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)],
|
||||
['Expirados sem pagamento',String(unpaid.expired)],['Aguardando pagamento',String(unpaid.waiting)],
|
||||
['Taxa de abandono',unpaid.abandon_pct==null?'—':unpaid.abandon_pct.toFixed(1).replace('.',',')+'%']];
|
||||
$('stats-unpaid').replaceChildren(...unpaidRows.map(([label,value])=>{const tr=node('tr');
|
||||
tr.append(node('td',label),node('td',value,'r'));return tr;}));
|
||||
// Who prepared the finals of the period's orders, for the designer's productivity.
|
||||
const most=Math.max(1,...data.treated.by.map(t=>t.orders));
|
||||
$('stats-treated').replaceChildren(...(data.treated.by.length?data.treated.by.map(t=>{
|
||||
@@ -2742,6 +2749,14 @@ function quoteWarning(q){
|
||||
if(items.some(i=>i.quality_status==='warning'))return ['warn','Ressalva de resolução aceita'];
|
||||
return null;
|
||||
}
|
||||
// How long an approved quote has left before the worker expires it.
|
||||
function quoteExpiry(q){
|
||||
if(!q.expires_at)return null;
|
||||
const left=new Date(q.expires_at).getTime()-Date.now();
|
||||
if(left<=0)return 'expirando';
|
||||
if(left<3600000)return 'expira em '+Math.max(1,Math.ceil(left/60000))+' min';
|
||||
return 'expira em '+Math.ceil(left/3600000)+'h';
|
||||
}
|
||||
function renderQuotes(){
|
||||
const kinds=[['pending','A revisar',board.pending_total],['approved','Aguardando pagamento',board.approved_total]];
|
||||
$('quote-filters').replaceChildren(...kinds.map(([key,label,count])=>{
|
||||
@@ -2775,7 +2790,7 @@ function renderQuotes(){
|
||||
first.append(name,node('span',q.approved?money(q.approved.total_cents):metres(quoteMetres(q)),'qm'));
|
||||
const second=node('span',undefined,'qline sub');
|
||||
const what=node('span');what.append(gradePill(lowestGrade(items)),' '+productLine(items)+', '+(q.draft.destination?q.draft.destination.city+'/'+q.draft.destination.state:'Retirada'));
|
||||
second.append(what,node('span',shortAgo(q.created_at)));
|
||||
second.append(what,node('span',(quoteKind==='approved'?quoteExpiry(q):null)||shortAgo(q.created_at)));
|
||||
main.append(first,second);
|
||||
const warn=quoteWarning(q);
|
||||
if(warn){const w=node('span',undefined,'qwarn'+(warn[0]==='bad'?' bad':''));w.append(svgIcon(IC.alert,'i s'),node('span',warn[1]));main.append(w);}
|
||||
@@ -2829,7 +2844,7 @@ function review(quote){
|
||||
words.append(title,meta);head.append(words);
|
||||
if(quote.approved){const total=node('div',undefined,'qbig');total.append(node('span','Total','lbl'),node('b',money(quote.approved.total_cents)));head.append(total);}
|
||||
const zap=whatsappLink(c.zap);
|
||||
if(zap){const a=node('a','WhatsApp','btn');a.href=zap;a.target='_blank';a.rel='noopener noreferrer';a.title=c.zap;a.prepend(svgIcon(IC.chat,'i m'));head.append(a);}
|
||||
if(zap){const a=node('a',quote.status==='approved'?'Abrir conversa':'WhatsApp','btn');a.href=zap;a.target='_blank';a.rel='noopener noreferrer';a.title=c.zap;a.prepend(svgIcon(IC.chat,'i m'));head.append(a);}
|
||||
const body=node('div',undefined,'rbody');
|
||||
const foot=node('div',undefined,'rfoot');
|
||||
if(quote.status==='pending_review'&"e.draft.items.some(item=>!LAYOUT_VERSIONS.includes(item.production?.version))){
|
||||
|
||||
Reference in New Issue
Block a user