feat(billing): rating engine, fechamento de periodo, dashboard platform (fase 22)
Fecha a orquestracao de Billing (agente.md secao 120-139) sobre o schema/ RatingEngine puro ja existentes: escritores do ledger UsageEvent (CALL_SECONDS no CDR, ACTIVE_DAY via sweep diario), closeBillingPeriod/ reopenBillingPeriod (fechamento imutavel com audit trail), e os controllers de price books/rate decks/plan versions/subscriptions/ periods/statements. Corrige 2 bugs reais de RLS achados no teste ponta a ponta (reopen sem tenant context, subscriptions sem withTenantContext) e adiciona teste unitario do RatingEngine (17 casos). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EWHKmcVJtstQFErbZ1AanY
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Req, UseGuards } from "@nestjs/common";
|
||||
import { Body, Controller, Get, HttpCode, HttpStatus, NotFoundException, Post, Req, UseGuards } from "@nestjs/common";
|
||||
import type { FastifyRequest } from "fastify";
|
||||
import { getPrismaClient } from "@b2bcall/database";
|
||||
import {
|
||||
changePassword,
|
||||
isPlatformUser,
|
||||
listUserTenants,
|
||||
login,
|
||||
logout,
|
||||
@@ -44,6 +46,18 @@ export class AuthController {
|
||||
await logout(user.sessionId);
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get("me")
|
||||
async me(@CurrentUser() user: AccessTokenClaims) {
|
||||
const prisma = getPrismaClient();
|
||||
const dbUser = await prisma.user.findUnique({
|
||||
where: { id: user.sub },
|
||||
select: { id: true, email: true, name: true },
|
||||
});
|
||||
if (!dbUser) throw new NotFoundException();
|
||||
return { ...dbUser, isPlatformUser: await isPlatformUser(user.sub) };
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get("tenants")
|
||||
async tenants(@CurrentUser() user: AccessTokenClaims) {
|
||||
|
||||
Reference in New Issue
Block a user