feat: API Gateway (Express 5 + Prisma + Monday) y conexion de apps al API
- api-gateway: servicio Monday (retry 429/complejidad, paginacion cursor, column IDs por titulo), endpoints unidades/cotizaciones/clientes/planes, webhook con handshake challenge, Prisma SQLite dev, 55 tests - cotizador: inventario desde /api/unidades con fallback a seed - alta-clientes: POST /api/clientes + upload multipart de documentos - cobranza: persistencia via API con respaldo offline en localStorage - .env.example con board IDs del workspace Frasa-CAS
This commit is contained in:
123
api-gateway/prisma/schema.prisma
Normal file
123
api-gateway/prisma/schema.prisma
Normal file
@@ -0,0 +1,123 @@
|
||||
// FRASA API Gateway — persistencia local
|
||||
// Desarrollo: SQLite. Producción: Postgres 16 (cambiar provider y DATABASE_URL).
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite" // prod: "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Cotizacion {
|
||||
id String @id @default(uuid())
|
||||
unidadCodigo String
|
||||
clienteNombre String
|
||||
clienteEmail String?
|
||||
clienteTelefono String?
|
||||
tipoPropuesta String // BANCARIO | INFONAVIT | CONTADO | SEMI_CONTADO
|
||||
acabados Boolean
|
||||
apartado Float // TODO prod: Decimal en Postgres
|
||||
descuento Float // fracción (0.02 = 2%)
|
||||
precioLista Float // TODO prod: Decimal en Postgres
|
||||
precioFinal Float
|
||||
enganche Float
|
||||
numMensualidades Int
|
||||
mensualidad Float? // null => N/A (Contado)
|
||||
pagoFinal Float
|
||||
mondayItemId String?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([unidadCodigo])
|
||||
}
|
||||
|
||||
model Cliente {
|
||||
id String @id @default(uuid())
|
||||
nombreCompleto String
|
||||
curp String
|
||||
rfc String
|
||||
email String?
|
||||
celular String?
|
||||
proyecto String
|
||||
unidadCodigo String?
|
||||
// Payload completo del alta como JSON serializado (SQLite no tiene Json nativo;
|
||||
// en Postgres puede migrarse a la columna Json sin cambiar el contrato).
|
||||
payloadJson String
|
||||
firmaPng String? // base64 opcional
|
||||
mondayContactoId String?
|
||||
mondayApartadoId String?
|
||||
createdAt DateTime @default(now())
|
||||
documentos Documento[]
|
||||
|
||||
@@index([curp])
|
||||
}
|
||||
|
||||
model Documento {
|
||||
id String @id @default(uuid())
|
||||
clienteId String
|
||||
cliente Cliente @relation(fields: [clienteId], references: [id], onDelete: Cascade)
|
||||
tipo String // INE | CONSTANCIA_RFC | CURP | COMPROBANTE_DOMICILIO | ACTA_NACIMIENTO | OTRO
|
||||
nombreArchivo String
|
||||
ruta String
|
||||
mime String
|
||||
tamano Int
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([clienteId])
|
||||
}
|
||||
|
||||
model PlanPago {
|
||||
id String @id @default(uuid())
|
||||
ventaRef String?
|
||||
clienteNombre String
|
||||
clienteTelefono String?
|
||||
unidadCodigo String
|
||||
proyecto String
|
||||
fechaInicio DateTime // se normaliza a medianoche local
|
||||
engancheTotal Float // TODO prod: Decimal en Postgres
|
||||
numPagos Int
|
||||
mensualidad Float
|
||||
tasaMoraMensual Float @default(0)
|
||||
status String @default("ACTIVO") // ACTIVO | CANCELADO (LIQUIDADO se deriva)
|
||||
createdAt DateTime @default(now())
|
||||
notas NotaPlan[]
|
||||
pagos Pago[]
|
||||
|
||||
@@index([unidadCodigo])
|
||||
}
|
||||
|
||||
model Pago {
|
||||
id String @id @default(uuid())
|
||||
planId String
|
||||
plan PlanPago @relation(fields: [planId], references: [id], onDelete: Cascade)
|
||||
numPago Int
|
||||
fechaVencimiento DateTime
|
||||
monto Float
|
||||
montoPagado Float @default(0)
|
||||
aplicaciones AplicacionPago[]
|
||||
|
||||
@@index([planId])
|
||||
@@index([fechaVencimiento])
|
||||
}
|
||||
|
||||
model AplicacionPago {
|
||||
id String @id @default(uuid())
|
||||
pagoId String
|
||||
pago Pago @relation(fields: [pagoId], references: [id], onDelete: Cascade)
|
||||
fechaPago DateTime
|
||||
monto Float
|
||||
referencia String
|
||||
|
||||
@@index([pagoId])
|
||||
}
|
||||
|
||||
model NotaPlan {
|
||||
id String @id @default(uuid())
|
||||
planId String
|
||||
plan PlanPago @relation(fields: [planId], references: [id], onDelete: Cascade)
|
||||
fecha DateTime @default(now())
|
||||
texto String
|
||||
|
||||
@@index([planId])
|
||||
}
|
||||
Reference in New Issue
Block a user