agenda: dialog pacote saldo realizada — 2 sub-questions claras
Antes (UX confusa): bloco "Gerar cobranca no pacote?" tinha so um Select "Como cobrar?" com options mixadas: - "Enviar link de pagamento (Asaas)" - "Ja recebi - PIX" - "Ja recebi - Dinheiro" - etc User selecionou "Ja recebi - PIX" pensando que era "cobrar via PIX" durante teste C11/A com Andre Green. Resultado: fatura virou paid sem o user ter recebido de verdade. Ambiguidade entre "como cobrar" (header) e "ja recebi" (options). Refactor: espelhar o padrao da avulsa (showRegistrarPagto): 1. Sub-question "A sessao ja foi paga?" radio Sim/Nao (default Nao) 2. Se Nao -> Select "Como vai cobrar?" [Apenas registrar pendente | Enviar link de pagamento (Asaas)] 3. Se Sim -> Select "Como recebeu?" [PIX | Dinheiro | Deposito | Maquininha] (sem prefixo "Ja recebi" — header ja deixa claro) Defaults safer: markPaid=false em ambos contextos (avulsa e pacote) pra evitar marcar paid sem querer. paymentMethod='pending' inicial. Handler em useMelissaAgenda._applyStatusDecisions: pos-processamento agora usa decision.markPaid explicito no caso pacote saldo: - markPaid=true -> record vira paid + payment_method=X - markPaid=false + paymentMethod='link' -> pending + payment_method='asaas' - markPaid=false + paymentMethod='pending' -> pending sem metodo Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1567,8 +1567,12 @@ function _buildHandlers(deps) {
|
||||
toast.add({ severity: 'success', summary: 'Status atualizado', detail: 'Decisões aplicadas.', life: 2500 });
|
||||
}
|
||||
|
||||
// Pós: se gerou cobrança via link Asaas, marcar payment_method='asaas'
|
||||
if (decision.generatePackageCharge && decision.paymentMethod === 'link' && eventoId) {
|
||||
// Pós-processamento do record gerado pelo pacote saldo. Agora o
|
||||
// decision tem markPaid explícito:
|
||||
// - markPaid=true → vira paid + payment_method=PIX/dinheiro/etc
|
||||
// - markPaid=false + paymentMethod='link' → pending + payment_method='asaas'
|
||||
// - markPaid=false + paymentMethod='pending' → pending sem método (default)
|
||||
if (decision.generatePackageCharge && eventoId) {
|
||||
try {
|
||||
const { data: newRec } = await supabase
|
||||
.from('financial_records')
|
||||
@@ -1578,29 +1582,24 @@ function _buildHandlers(deps) {
|
||||
.limit(1)
|
||||
.single();
|
||||
if (newRec?.id) {
|
||||
await supabase.from('financial_records').update({ payment_method: 'asaas', updated_at: new Date().toISOString() }).eq('id', newRec.id);
|
||||
}
|
||||
} catch { /* silencioso */ }
|
||||
} else if (decision.generatePackageCharge && decision.paymentMethod !== 'link' && eventoId) {
|
||||
// Já recebi → marca como paid
|
||||
try {
|
||||
const { data: newRec } = await supabase
|
||||
.from('financial_records')
|
||||
.select('id')
|
||||
.eq('agenda_evento_id', eventoId)
|
||||
.order('created_at', { ascending: false })
|
||||
.limit(1)
|
||||
.single();
|
||||
if (newRec?.id) {
|
||||
await supabase
|
||||
.from('financial_records')
|
||||
.update({
|
||||
status: 'paid',
|
||||
paid_at: new Date().toISOString(),
|
||||
payment_method: decision.paymentMethod,
|
||||
updated_at: new Date().toISOString()
|
||||
})
|
||||
.eq('id', newRec.id);
|
||||
if (decision.markPaid) {
|
||||
await supabase
|
||||
.from('financial_records')
|
||||
.update({
|
||||
status: 'paid',
|
||||
paid_at: new Date().toISOString(),
|
||||
payment_method: decision.paymentMethod,
|
||||
updated_at: new Date().toISOString()
|
||||
})
|
||||
.eq('id', newRec.id);
|
||||
} else if (decision.paymentMethod === 'link') {
|
||||
await supabase
|
||||
.from('financial_records')
|
||||
.update({ payment_method: 'asaas', updated_at: new Date().toISOString() })
|
||||
.eq('id', newRec.id);
|
||||
}
|
||||
// markPaid=false + paymentMethod='pending' → não faz nada
|
||||
// (record já criado como pending pelo RPC, sem payment_method)
|
||||
}
|
||||
} catch { /* silencioso */ }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user