fix: ajustar calculos do dashboard para faturamento usar apenas status RECEIVED
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 59s
Details
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 59s
Details
This commit is contained in:
parent
98c0228a25
commit
cbb0e8b6e7
|
|
@ -1086,7 +1086,7 @@ app.get('/api/admin/dashboard', authenticateToken, requireAdmin, async (req: Aut
|
|||
|
||||
// Total Revenue Calculation
|
||||
const totalRevenue = allPayments
|
||||
.filter(p => p.status === 'CONFIRMED' || p.status === 'RECEIVED')
|
||||
.filter(p => p.status === 'RECEIVED')
|
||||
.reduce((sum, p) => sum + Number(p.value), 0);
|
||||
|
||||
// Generate Revenue Data for Charts (Last 30 Days)
|
||||
|
|
@ -1094,7 +1094,7 @@ app.get('/api/admin/dashboard', authenticateToken, requireAdmin, async (req: Aut
|
|||
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
|
||||
|
||||
const recentConfirmedPayments = allPayments.filter(
|
||||
p => (p.status === 'CONFIRMED' || p.status === 'RECEIVED') && p.createdAt >= thirtyDaysAgo
|
||||
p => p.status === 'RECEIVED' && p.createdAt >= thirtyDaysAgo
|
||||
);
|
||||
|
||||
const revenueByDay: Record<string, number> = {};
|
||||
|
|
@ -1199,7 +1199,7 @@ app.get('/api/admin/students', authenticateToken, requireAdmin, async (req: Auth
|
|||
whatsapp: u.whatsapp,
|
||||
trialEndsAt: u.trialEndsAt,
|
||||
totalPaid: u.payments
|
||||
.filter(p => p.status === 'CONFIRMED' || p.status === 'RECEIVED')
|
||||
.filter(p => p.status === 'RECEIVED')
|
||||
.reduce((acc, curr) => acc + Number(curr.value), 0),
|
||||
unlockedCourses: u.unlockedCourses || [],
|
||||
moduleGrades: u.moduleGrades,
|
||||
|
|
@ -1748,7 +1748,8 @@ app.post('/api/webhooks/asaas', async (req: Request, res: Response) => {
|
|||
const isOverdue = event === 'PAYMENT_OVERDUE';
|
||||
const isRefunded = event === 'PAYMENT_REFUNDED' || event === 'PAYMENT_DELETED';
|
||||
|
||||
const newStatus = isPaid ? 'CONFIRMED' :
|
||||
const newStatus = event === 'PAYMENT_RECEIVED' ? 'RECEIVED' :
|
||||
event === 'PAYMENT_CONFIRMED' ? 'CONFIRMED' :
|
||||
isOverdue ? 'OVERDUE' :
|
||||
isRefunded ? 'REFUNDED' :
|
||||
event === 'PAYMENT_RESTORED' ? 'PENDING' : null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue