feat: restringe soloAdmin (Bucefalo CRM) a agentes, default WhatsApp+fallbackEmail y archivado reversible
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
-- Migracion aditiva: soloAdmin en ServicioCatalogo (oculto para bots) y archivo reversible en Cliente y Cotizacion
|
||||
|
||||
ALTER TABLE "ServicioCatalogo"
|
||||
ADD COLUMN IF NOT EXISTS "soloAdmin" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- Marcar planes/servicios de Bucefalo CRM como soloAdmin = true (visibles solo en web admin, ocultos a agentes)
|
||||
UPDATE "ServicioCatalogo"
|
||||
SET "soloAdmin" = true
|
||||
WHERE id IN ('configuracion-y-puesta-en-marc-12', 'plan-mensual-crm-bucefalo-18')
|
||||
OR LOWER(nombre) LIKE '%bucefalo%'
|
||||
OR LOWER(nombre) LIKE '%bucéfalo%';
|
||||
|
||||
ALTER TABLE "Cliente"
|
||||
ADD COLUMN IF NOT EXISTS "archivado" BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN IF NOT EXISTS "archivadoAt" TIMESTAMP(3);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "Cliente_archivado_idx" ON "Cliente"("archivado");
|
||||
|
||||
ALTER TABLE "Cotizacion"
|
||||
ADD COLUMN IF NOT EXISTS "archivado" BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN IF NOT EXISTS "archivadoAt" TIMESTAMP(3);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "Cotizacion_archivado_idx" ON "Cotizacion"("archivado");
|
||||
+20
-11
@@ -25,16 +25,18 @@ model User {
|
||||
}
|
||||
|
||||
model Cliente {
|
||||
id String @id @default(cuid())
|
||||
nombre String
|
||||
empresa String?
|
||||
id String @id @default(cuid())
|
||||
nombre String
|
||||
empresa String?
|
||||
// Cargo de la persona de contacto (ej. "Director"). Solo informativo.
|
||||
puesto String?
|
||||
email String?
|
||||
telefono String?
|
||||
rfc String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
puesto String?
|
||||
email String?
|
||||
telefono String?
|
||||
rfc String?
|
||||
archivado Boolean @default(false)
|
||||
archivadoAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
cotizaciones Cotizacion[]
|
||||
// Cuenta de acceso al panel de cliente (role="cliente"). Una por cliente.
|
||||
@@ -42,6 +44,7 @@ model Cliente {
|
||||
programasPago ProgramaPago[]
|
||||
|
||||
@@index([nombre, empresa])
|
||||
@@index([archivado])
|
||||
}
|
||||
|
||||
model Cotizacion {
|
||||
@@ -79,8 +82,10 @@ model Cotizacion {
|
||||
rechazadaAt DateTime?
|
||||
vencidaAt DateTime?
|
||||
creadaPorAgente String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
archivado Boolean @default(false)
|
||||
archivadoAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
cliente Cliente @relation(fields: [clienteId], references: [id])
|
||||
asesor User @relation("AsesorCotizaciones", fields: [asesorId], references: [id])
|
||||
@@ -94,6 +99,7 @@ model Cotizacion {
|
||||
@@index([clienteId])
|
||||
@@index([asesorId])
|
||||
@@index([estado])
|
||||
@@index([archivado])
|
||||
@@index([createdAt])
|
||||
}
|
||||
|
||||
@@ -148,6 +154,9 @@ model ServicioCatalogo {
|
||||
variante String?
|
||||
nivel String?
|
||||
activo Boolean @default(true)
|
||||
// Si es true, queda oculto para todas las claves de agentes/bots y solo puede
|
||||
// agregarlo un administrador humano desde la web (p. ej. planes de Bucefalo CRM).
|
||||
soloAdmin Boolean @default(false)
|
||||
orden Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -362,6 +362,7 @@ async function main() {
|
||||
{
|
||||
nombre: "Configuracion y Puesta en Marcha del CRM Bucefalo",
|
||||
descripcion: "Configuracion inicial de cuenta CRM Bucefalo",
|
||||
soloAdmin: true,
|
||||
fase: 1,
|
||||
tipoPago: "unico",
|
||||
precioBase: 3900,
|
||||
@@ -470,6 +471,7 @@ async function main() {
|
||||
{
|
||||
nombre: "Plan Mensual CRM Bucefalo",
|
||||
descripcion: "Suscripcion mensual al CRM Bucefalo",
|
||||
soloAdmin: true,
|
||||
fase: 2,
|
||||
tipoPago: "mensual",
|
||||
precioBase: 3900,
|
||||
|
||||
Reference in New Issue
Block a user