19 KiB
Plan de Resolucion de GAPs - Mecanicas Diesel
Fecha: 2025-12-12 Proyecto: mecanicas-diesel Estado: Pre-desarrollo Responsable: Architecture-Analyst
Resumen Ejecutivo
Este documento detalla el plan para resolver los 12 GAPs identificados en el analisis arquitectonico antes de iniciar el desarrollo de backend/frontend del proyecto mecanicas-diesel.
Clasificacion de GAPs
| Criticidad | Cantidad | Descripcion |
|---|---|---|
| CRITICA (P0) | 3 | Bloquean desarrollo, deben resolverse primero |
| ALTA (P1) | 5 | Importantes para MVP completo |
| MEDIA (P2) | 3 | Mejoras significativas |
| BAJA (P3) | 1 | Opcionales/simplificadas |
GAPs Criticos (P0) - Semana 1
GAP-01: Sistema de Tracking de Cambios (mail.thread)
Problema: No existe sistema automatico de auditoria/tracking de cambios en documentos (ordenes, cotizaciones, diagnosticos).
Impacto:
- Pierde historial de modificaciones
- No hay trazabilidad de quien cambio que
- No cumple con auditorias
Solucion: Implementar patron mail.thread de Odoo adaptado
SPEC de Referencia: erp-core/docs/04-modelado/especificaciones-tecnicas/transversal/SPEC-MAIL-THREAD-TRACKING.md
Acciones:
- Crear schema
notificationsen mecanicas-diesel - Crear tablas:
notifications.messages- Mensajes y trackingnotifications.message_subtypes- Tipos de mensajenotifications.tracking_values- Valores trackeados
- Implementar decorator
@Trackedpara campos - Agregar tracking a tablas criticas:
service_management.service_ordersservice_management.quotesservice_management.diagnostics
DDL Requerido:
-- Schema de notificaciones
CREATE SCHEMA IF NOT EXISTS notifications;
-- Tabla de mensajes (chatter)
CREATE TABLE notifications.messages (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL,
res_model VARCHAR(100) NOT NULL,
res_id UUID NOT NULL,
message_type VARCHAR(20) NOT NULL DEFAULT 'notification',
subtype_code VARCHAR(50),
author_id UUID,
subject VARCHAR(500),
body TEXT,
tracking_values JSONB DEFAULT '[]',
is_internal BOOLEAN NOT NULL DEFAULT false,
parent_id UUID REFERENCES notifications.messages(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT chk_message_type CHECK (message_type IN ('comment', 'notification', 'note'))
);
-- Indices
CREATE INDEX idx_messages_resource ON notifications.messages(res_model, res_id);
CREATE INDEX idx_messages_tenant ON notifications.messages(tenant_id);
CREATE INDEX idx_messages_created ON notifications.messages(created_at DESC);
Esfuerzo: 8 horas Entregable: DDL + Documentacion
GAP-02: Sistema de Followers/Suscriptores
Problema: No hay manera de suscribirse a documentos para recibir notificaciones automaticas.
Impacto:
- Usuarios no se enteran de cambios importantes
- Comunicacion manual requerida
- Pierde eficiencia operativa
Solucion: Implementar sistema de followers
SPEC de Referencia: SPEC-MAIL-THREAD-TRACKING.md (seccion Followers)
Acciones:
- Crear tabla
notifications.followers - Crear tabla
notifications.follower_subtypes - Implementar auto-suscripcion:
- Mecanico asignado sigue su orden
- Cliente sigue sus cotizaciones
- Jefe de taller sigue ordenes de su bahia
DDL Requerido:
-- Seguidores de documentos
CREATE TABLE notifications.followers (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL,
res_model VARCHAR(100) NOT NULL,
res_id UUID NOT NULL,
partner_id UUID NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE(tenant_id, res_model, res_id, partner_id)
);
-- Suscripciones a tipos de mensaje
CREATE TABLE notifications.follower_subtypes (
follower_id UUID NOT NULL REFERENCES notifications.followers(id) ON DELETE CASCADE,
subtype_code VARCHAR(50) NOT NULL,
PRIMARY KEY (follower_id, subtype_code)
);
CREATE INDEX idx_followers_resource ON notifications.followers(res_model, res_id);
CREATE INDEX idx_followers_partner ON notifications.followers(partner_id);
Esfuerzo: 4 horas Entregable: DDL + Documentacion
GAP-03: Actividades Programadas
Problema: No hay sistema de recordatorios/actividades asociadas a documentos.
Impacto:
- No hay seguimiento de llamadas pendientes
- No hay recordatorios de mantenimientos
- Clientes olvidados
Solucion: Implementar sistema de actividades (mail.activity)
SPEC de Referencia: SPEC-MAIL-THREAD-TRACKING.md (seccion Activities)
Acciones:
- Crear tabla
notifications.activities - Crear tabla
notifications.activity_types - Configurar tipos predeterminados:
call- Llamar al clientemeeting- Cita de entregatodo- Tarea pendientereminder- Recordatorio de mantenimiento
DDL Requerido:
-- Tipos de actividad
CREATE TABLE notifications.activity_types (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
code VARCHAR(50) NOT NULL UNIQUE,
name VARCHAR(100) NOT NULL,
icon VARCHAR(50) DEFAULT 'fa-tasks',
default_days INTEGER DEFAULT 0,
is_active BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Actividades programadas
CREATE TABLE notifications.activities (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL,
res_model VARCHAR(100) NOT NULL,
res_id UUID NOT NULL,
activity_type_id UUID NOT NULL REFERENCES notifications.activity_types(id),
user_id UUID NOT NULL,
date_deadline DATE NOT NULL,
summary VARCHAR(500),
note TEXT,
state VARCHAR(20) NOT NULL DEFAULT 'planned',
date_done TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_by UUID NOT NULL,
CONSTRAINT chk_activity_state CHECK (state IN ('planned', 'today', 'overdue', 'done', 'canceled'))
);
-- Seed de tipos predeterminados
INSERT INTO notifications.activity_types (code, name, icon, default_days) VALUES
('call', 'Llamar cliente', 'fa-phone', 0),
('meeting', 'Cita de entrega', 'fa-calendar', 0),
('todo', 'Tarea pendiente', 'fa-tasks', 1),
('reminder', 'Recordatorio mantenimiento', 'fa-bell', 30),
('followup', 'Seguimiento cotizacion', 'fa-envelope', 3);
CREATE INDEX idx_activities_resource ON notifications.activities(res_model, res_id);
CREATE INDEX idx_activities_user ON notifications.activities(user_id);
CREATE INDEX idx_activities_deadline ON notifications.activities(date_deadline);
CREATE INDEX idx_activities_state ON notifications.activities(state) WHERE state NOT IN ('done', 'canceled');
Esfuerzo: 4 horas Entregable: DDL + Documentacion + Seed
GAPs Alta Prioridad (P1) - Semana 2-3
GAP-04: Facturacion Integrada (MMD-007)
Problema: No hay modulo de facturacion, no se generan asientos contables.
Impacto:
- No hay CFDI
- Proceso de facturacion manual
- Sin integracion contable
Solucion: Documentar e implementar MMD-007
SPEC de Referencia:
SPEC-FIRMA-ELECTRONICA-NOM151.md(para CFDI)erp-core/docs/02-definicion-modulos/ALCANCE-POR-MODULO.md(MGN-004)
Acciones:
- Crear documentacion de EPIC-MMD-007-facturacion.md
- Crear documentacion de modulo MMD-007
- Definir historias de usuario (8-10 US)
- Disenar schema
billing - Integrar con PAC para timbrado
Fases:
- Fase 2a: Pre-factura desde orden de servicio
- Fase 2b: Timbrado CFDI con PAC
- Fase 2c: Reportes de facturacion
Esfuerzo: 40 horas (distribuido en Fase 2) Entregable: Documentacion completa + DDL
GAP-05: Contabilidad Analitica
Problema: No hay P&L por orden de servicio, no se puede medir rentabilidad.
Impacto:
- No se sabe cuanto gana o pierde por orden
- No hay control de costos por servicio
- Decisiones sin datos financieros
Solucion: Implementar cuentas analiticas simplificadas
SPEC de Referencia: SPEC-CONTABILIDAD-ANALITICA-MULTIDIMENSIONAL.md
Acciones:
- Agregar
analytic_account_idaservice_orders - Crear tabla
analytics.accountssimplificada - Crear tabla
analytics.linespara costos/ingresos - Generar lineas automaticas al:
- Usar refacciones (costo)
- Facturar (ingreso)
- Registrar mano de obra (costo)
DDL Requerido:
CREATE SCHEMA IF NOT EXISTS analytics;
CREATE TABLE analytics.accounts (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL,
code VARCHAR(20) NOT NULL,
name VARCHAR(100) NOT NULL,
account_type VARCHAR(20) NOT NULL DEFAULT 'service_order',
service_order_id UUID,
is_active BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
UNIQUE(tenant_id, code)
);
CREATE TABLE analytics.lines (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL,
account_id UUID NOT NULL REFERENCES analytics.accounts(id),
date DATE NOT NULL,
name VARCHAR(256),
amount DECIMAL(20,6) NOT NULL,
unit_amount DECIMAL(20,6),
ref VARCHAR(100),
source_model VARCHAR(100),
source_id UUID,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_analytics_lines_account ON analytics.lines(account_id);
CREATE INDEX idx_analytics_lines_date ON analytics.lines(date);
Esfuerzo: 16 horas Entregable: DDL + Documentacion
GAP-06: Portal de Clientes
Problema: Cliente no puede ver el avance de su vehiculo en linea.
Impacto:
- Llamadas constantes preguntando estado
- Menor satisfaccion del cliente
- Proceso ineficiente
Solucion: Implementar portal basico para clientes
SPEC de Referencia: ALCANCE-POR-MODULO.md (MGN-013)
Acciones:
- Documentar MMD-Portal en Fase 2
- Crear rol
portal_cliente - Implementar vistas de solo lectura:
- Mis vehiculos
- Mis ordenes de servicio
- Estado actual
- Cotizaciones pendientes de aprobar
- Implementar aprobacion online de cotizaciones
Esfuerzo: 32 horas (Fase 2) Entregable: Documentacion + DDL permisos
GAP-09: Compras con RFQ Completo
Problema: Solo hay recepciones, no hay ordenes de compra ni solicitudes de cotizacion.
Impacto:
- No hay control de compras
- No hay historial de proveedores
- No hay aprobaciones de compra
Solucion: Implementar modulo de compras simplificado
SPEC de Referencia: ALCANCE-POR-MODULO.md (MGN-006)
Acciones:
- Crear schema
purchasing - Crear tablas:
purchasing.purchase_orderspurchasing.purchase_order_linespurchasing.suppliers(o usar partners existentes)
- Integrar con recepciones de inventario
DDL Requerido:
CREATE SCHEMA IF NOT EXISTS purchasing;
CREATE TABLE purchasing.purchase_orders (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL,
order_number VARCHAR(50) NOT NULL,
supplier_id UUID NOT NULL,
status VARCHAR(20) NOT NULL DEFAULT 'draft',
order_date DATE NOT NULL DEFAULT CURRENT_DATE,
expected_date DATE,
subtotal DECIMAL(20,6) NOT NULL DEFAULT 0,
tax_amount DECIMAL(20,6) NOT NULL DEFAULT 0,
total DECIMAL(20,6) NOT NULL DEFAULT 0,
notes TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_by UUID NOT NULL,
CONSTRAINT chk_po_status CHECK (status IN ('draft', 'sent', 'confirmed', 'received', 'cancelled'))
);
CREATE TABLE purchasing.purchase_order_lines (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
purchase_order_id UUID NOT NULL REFERENCES purchasing.purchase_orders(id) ON DELETE CASCADE,
part_id UUID NOT NULL,
quantity DECIMAL(20,6) NOT NULL,
unit_price DECIMAL(20,6) NOT NULL,
subtotal DECIMAL(20,6) NOT NULL,
received_quantity DECIMAL(20,6) NOT NULL DEFAULT 0,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_po_tenant ON purchasing.purchase_orders(tenant_id);
CREATE INDEX idx_po_supplier ON purchasing.purchase_orders(supplier_id);
CREATE INDEX idx_po_status ON purchasing.purchase_orders(status);
Esfuerzo: 24 horas Entregable: DDL + Documentacion
GAP-10: Reporte de Garantias
Problema: No hay tracking formal de garantias de refacciones usadas.
Impacto:
- No se sabe cuales piezas estan en garantia
- Perdida de dinero por no reclamar garantias
- Sin historial para cliente
Solucion: Agregar tracking de garantias
Acciones:
- Agregar campos de garantia a
parts_management.parts:warranty_monthswarranty_policy
- Crear tabla
parts_management.warranty_claims - Crear vista de piezas en garantia
DDL Requerido:
-- Ajuste a parts (si no existe)
ALTER TABLE parts_management.parts
ADD COLUMN IF NOT EXISTS warranty_months INTEGER DEFAULT 0;
-- Claims de garantia
CREATE TABLE parts_management.warranty_claims (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL,
part_id UUID NOT NULL,
service_order_id UUID,
serial_number VARCHAR(100),
installation_date DATE NOT NULL,
expiration_date DATE NOT NULL,
claim_date DATE,
claim_status VARCHAR(20) DEFAULT 'active',
claim_notes TEXT,
resolution TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT chk_warranty_status CHECK (claim_status IN ('active', 'claimed', 'approved', 'rejected', 'expired'))
);
-- Vista de garantias activas
CREATE VIEW parts_management.v_active_warranties AS
SELECT
wc.*,
p.sku,
p.name as part_name,
so.order_number,
c.name as customer_name
FROM parts_management.warranty_claims wc
JOIN parts_management.parts p ON p.id = wc.part_id
LEFT JOIN service_management.service_orders so ON so.id = wc.service_order_id
LEFT JOIN workshop_core.customers c ON c.id = so.customer_id
WHERE wc.claim_status = 'active'
AND wc.expiration_date >= CURRENT_DATE;
Esfuerzo: 8 horas Entregable: DDL + Vista
GAPs Media Prioridad (P2) - Semana 4+
GAP-07: Integracion Calendario
Problema: No hay agendamiento de citas de servicio.
Impacto:
- No se pueden programar citas
- Overbooking de bahias
- Sin vista de calendario
Solucion: Integrar con sistema de calendario (opcional)
SPEC de Referencia: SPEC-INTEGRACION-CALENDAR.md
Acciones:
- Evaluar necesidad real del taller
- Si se requiere:
- Crear tabla
scheduling.appointments - Integrar con bahias de trabajo
- Vista de calendario por bahia
- Crear tabla
Esfuerzo: 8 horas (si se requiere) Entregable: Evaluacion + DDL opcional
GAP-08: Pricing Rules Avanzado
Problema: No hay descuentos escalonados ni reglas de precios complejas.
Impacto:
- Precios manuales
- Sin descuentos por volumen
- Sin promociones
Solucion: Implementar pricing basico
SPEC de Referencia: SPEC-PRICING-RULES.md
Acciones:
- Evaluar necesidad (talleres normalmente tienen precios fijos)
- Si se requiere:
- Crear tabla
pricing.pricelists - Crear tabla
pricing.pricelist_items - Integrar con cotizaciones
- Crear tabla
Esfuerzo: 16 horas (si se requiere) Entregable: Evaluacion + DDL opcional
GAP-12: Firma Electronica
Problema: Aprobacion de cotizaciones sin firma legal.
Impacto:
- Sin respaldo legal
- Disputas de aprobacion
- Proceso informal
Solucion: Implementar firma basica
SPEC de Referencia: SPEC-FIRMA-ELECTRONICA-NOM151.md
Acciones:
- Para MVP: Firma canvas simple (HTML5)
- Agregar campos a cotizaciones:
signature_data(base64)signed_atsigned_by_ip
- Para Fase 2+: Evaluar NOM-151 completa
DDL Requerido:
-- Agregar campos de firma a cotizaciones
ALTER TABLE service_management.quotes
ADD COLUMN IF NOT EXISTS signature_data TEXT,
ADD COLUMN IF NOT EXISTS signed_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS signed_by_ip VARCHAR(45),
ADD COLUMN IF NOT EXISTS signed_by_name VARCHAR(256);
Esfuerzo: 8 horas (firma basica) Entregable: DDL + Documentacion
GAPs Baja Prioridad (P3) - Post-MVP
GAP-11: Contratos de Empleados
Problema: Empleados (mecanicos) sin gestion de contratos formal.
Impacto:
- Sin historial laboral
- Sin control de documentos
- Riesgo legal
Solucion: Simplificado para taller
Decision: Para MVP, mantener simplificado con campos basicos en users. Implementar HR completo en Fase 3 si el taller lo requiere.
Esfuerzo: 0 horas (mantener simplificado) Entregable: N/A
Cronograma de Implementacion
SEMANA 1 (Gaps Criticos P0)
├── Dia 1-2: GAP-01 Sistema de tracking (8h)
├── Dia 3: GAP-02 Followers (4h)
├── Dia 4: GAP-03 Actividades (4h)
└── Dia 5: Pruebas y documentacion
SEMANA 2 (Gaps P1 - Parte 1)
├── Dia 1-2: GAP-05 Contabilidad analitica (16h)
└── Dia 3-5: GAP-10 Garantias (8h) + Documentacion GAP-04
SEMANA 3 (Gaps P1 - Parte 2)
├── Dia 1-3: GAP-09 Compras basico (24h)
└── Dia 4-5: GAP-12 Firma basica (8h)
SEMANA 4+ (Evaluacion Gaps P2)
├── GAP-07 Calendario - Evaluar necesidad
├── GAP-08 Pricing - Evaluar necesidad
└── Documentacion GAP-04/GAP-06 para Fase 2
Entregables por Semana
Semana 1
database/init/07-notifications-schema.sqldocs/03-modelo-datos/SCHEMA-NOTIFICATIONS.md- Actualizacion de
PROJECT-STATUS.md
Semana 2
database/init/08-analytics-schema.sqldocs/03-modelo-datos/SCHEMA-ANALYTICS.mddocs/02-definicion-modulos/MMD-007-facturacion/README.md(estructura)
Semana 3
database/init/09-purchasing-schema.sqldocs/03-modelo-datos/SCHEMA-PURCHASING.md- Actualizacion DDL cotizaciones (firma)
Semana 4
- Evaluacion y decision de Gaps P2
- Documentacion completa para desarrollo
Metricas de Exito
| Metrica | Objetivo | Validacion |
|---|---|---|
| Gaps P0 resueltos | 3/3 | DDL ejecutable |
| Gaps P1 documentados | 5/5 | Documentacion completa |
| DDL sin errores | 100% | Scripts de validacion |
| Cobertura documentacion | 100% | Review |
Riesgos y Mitigaciones
| Riesgo | Probabilidad | Impacto | Mitigacion |
|---|---|---|---|
| Complejidad tracking | Media | Alto | Usar SPEC existente de erp-core |
| Integracion con existente | Baja | Medio | Probar incrementalmente |
| Cambios de alcance | Media | Medio | Documentar decisiones |
Aprobaciones
- Product Owner: Aprobacion de priorizacion
- Tech Lead: Revision tecnica de DDL
- QA: Plan de validacion
Estado de Implementacion
| GAP | DDL Creado | Fecha |
|---|---|---|
| GAP-01 | 07-notifications-schema.sql | 2025-12-12 |
| GAP-02 | 07-notifications-schema.sql | 2025-12-12 |
| GAP-03 | 07-notifications-schema.sql | 2025-12-12 |
| GAP-04 | Fase 2 (documentado) | - |
| GAP-05 | 08-analytics-schema.sql | 2025-12-12 |
| GAP-06 | Fase 2 (documentado) | - |
| GAP-07 | Evaluado - Opcional | - |
| GAP-08 | Evaluado - Opcional | - |
| GAP-09 | 09-purchasing-schema.sql | 2025-12-12 |
| GAP-10 | 10-warranty-claims.sql | 2025-12-12 |
| GAP-11 | Simplificado (Post-MVP) | - |
| GAP-12 | 11-quote-signature.sql | 2025-12-12 |
Documento creado por: Architecture-Analyst Fecha: 2025-12-12 Version: 1.1.0 Estado: IMPLEMENTADO - DDL creados