feat(dashboard): painel Rafael — meta, comissão, inativos, pedidos recentes (C7)

GET /dashboard/rep retorna meta mensal, comissão (fixa + FLEX), clientes
inativos >30 dias e pedidos dos últimos 7 dias. RepTarget model com migration.
RafaelPainel conectado à API real via useRepDashboard().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 00:29:31 +00:00
parent 356c8e3c2c
commit 6028bf1ba9
12 changed files with 432 additions and 105 deletions

View File

@@ -171,6 +171,26 @@ model Product {
@@index([deletedAt])
}
// ─── RepTarget (C7) ──────────────────────────────────────────────────────────
//
// Meta mensal e taxas de comissão por rep. Uma linha por rep/mês.
// commissionRate: % aplicada sobre o total aprovado+faturado do mês.
// flexRate: % bônus adicional quando atingido >= targetAmount.
model RepTarget {
repId String
year Int
month Int // 112
targetAmount Decimal @db.Decimal(15, 2)
commissionRate Decimal @default(3) @db.Decimal(5, 2)
flexRate Decimal @default(1) @db.Decimal(5, 2)
updatedAt DateTime @updatedAt
@@id([repId, year, month])
@@index([repId])
}
// ─── RepDiscountLimit (C4) ───────────────────────────────────────────────────
//
// Alçada de desconto por rep e por linha de produto (OQ-2 resolvida 2026-05-27).