FASE 4: Validación del Plan - ERP Construcción
Proyecto: erp-construccion
Fecha: 2026-01-04
Estado: Completado
Base: FASE-3-PLAN-IMPLEMENTACION.md
1. Checklist de Validación vs Análisis
1.1 Correcciones FASE-8 vs Plan
| ID |
Elemento |
En Análisis |
En Plan |
Estado |
| COR-035 |
payment_term_lines |
FASE-2 §1.1 |
08-financial-ext |
✅ Cubierto |
| COR-036 |
incoterms |
FASE-2 §1.1 |
08-financial-ext |
✅ Cubierto |
| COR-037 |
payment_methods |
FASE-2 §1.1 |
08-financial-ext |
✅ Cubierto |
| COR-038 |
reconcile_models |
FASE-2 §1.1 |
08-financial-ext |
✅ Cubierto |
| COR-039 |
journal_entries fields |
FASE-2 §1.1 |
08-financial-ext |
✅ Cubierto |
| COR-040 |
packages |
FASE-2 §1.2 |
06-inventory-ext |
✅ Cubierto |
| COR-041 |
putaway_rules |
FASE-2 §1.2 |
06-inventory-ext |
✅ Cubierto |
| COR-042 |
storage_categories |
FASE-2 §1.2 |
06-inventory-ext |
✅ Cubierto |
| COR-043 |
product fields |
FASE-2 §1.2 |
06-inventory-ext |
✅ Cubierto |
| COR-044 |
removal_strategies |
FASE-2 §1.2 |
06-inventory-ext |
✅ Cubierto |
| COR-045 |
product_supplierinfo |
FASE-2 §1.3 |
07-purchase-ext |
✅ Cubierto |
| COR-046 |
PO fields |
FASE-2 §1.3 |
07-purchase-ext |
✅ Cubierto |
| COR-047 |
action_create_stock_moves |
FASE-2 §1.3 |
07-purchase-ext |
✅ Cubierto |
| COR-056 |
project_collaborators |
FASE-2 §1.4 |
09-projects-ext |
✅ Cubierto |
| COR-057 |
project fields |
FASE-2 §1.4 |
09-projects-ext |
✅ Cubierto |
| COR-058 |
task_count trigger |
FASE-2 §1.4 |
09-projects-ext |
✅ Cubierto |
| COR-059 |
project_ratings |
FASE-2 §1.4 |
09-projects-ext |
✅ Cubierto |
| COR-060 |
burndown_chart_data |
FASE-2 §1.4 |
09-projects-ext |
✅ Cubierto |
| COR-061 |
employee fields |
FASE-2 §1.5 |
02-hr-schema |
✅ Cubierto |
| COR-062 |
work_locations |
FASE-2 §1.5 |
02-hr-schema |
✅ Cubierto |
| COR-063 |
skills system |
FASE-2 §1.5 |
02-hr-schema |
✅ Cubierto |
| COR-064 |
expense system |
FASE-2 §1.5 |
02-hr-schema |
✅ Cubierto |
| COR-065 |
resume_lines |
FASE-2 §1.5 |
02-hr-schema |
✅ Cubierto |
| COR-066 |
payslip basics |
FASE-2 §1.5 |
02-hr-schema |
✅ Cubierto |
Resultado: 24/24 correcciones cubiertas (100%)
1.2 Correcciones No Aplicables (Confirmación)
| ID |
Elemento |
Razón |
Confirmado |
| COR-048 |
SO fields |
No hay módulo de ventas en construcción |
✅ |
| COR-049 |
action_confirm |
No aplica a construcción |
✅ |
| COR-050 |
get_pricelist_price |
No hay listas de precio de venta |
✅ |
| COR-051 |
convert_lead_to_opportunity |
No hay CRM de ventas |
✅ |
| COR-052 |
Lead/Opp fields |
No aplica |
✅ |
| COR-053 |
action_set_lost |
No aplica |
✅ |
| COR-054 |
action_set_won |
No aplica |
✅ |
| COR-055 |
CRM tags |
No aplica |
✅ |
Resultado: 8 correcciones correctamente excluidas
2. Validación de Tablas
2.1 Tablas Nuevas por Crear
| Schema |
Tabla |
En FASE-2 |
En FASE-3 |
RLS |
Índices |
| financial |
payment_term_lines |
✅ |
✅ |
✅ |
✅ |
| financial |
incoterms |
✅ |
✅ |
N/A |
✅ |
| financial |
payment_methods |
✅ |
✅ |
✅ |
✅ |
| financial |
reconcile_models |
✅ |
✅ |
✅ |
✅ |
| financial |
reconcile_model_lines |
✅ |
✅ |
N/A |
✅ |
| inventory |
package_types |
✅ |
✅ |
✅ |
N/A |
| inventory |
packages |
✅ |
✅ |
✅ |
N/A |
| inventory |
storage_categories |
✅ |
✅ |
✅ |
N/A |
| inventory |
putaway_rules |
✅ |
✅ |
✅ |
N/A |
| inventory |
removal_strategies |
✅ |
✅ |
N/A |
N/A |
| purchase |
product_supplierinfo |
✅ |
✅ |
✅ |
✅ |
| projects |
collaborators |
✅ |
✅ |
✅ |
✅ |
| projects |
ratings |
✅ |
✅ |
✅ |
✅ |
| construction |
avance_programado |
✅ |
✅ |
✅ |
✅ |
| construction |
ubicaciones_obra |
✅ |
✅ |
✅ |
N/A |
| hr |
work_locations |
✅ |
✅ |
✅ |
N/A |
| hr |
skill_types |
✅ |
✅ |
✅ |
N/A |
| hr |
skills |
✅ |
✅ |
✅ |
N/A |
| hr |
skill_levels |
✅ |
✅ |
✅ |
N/A |
| hr |
employee_skills |
✅ |
✅ |
N/A |
N/A |
| hr |
expense_sheets |
✅ |
✅ |
✅ |
N/A |
| hr |
expenses |
✅ |
✅ |
✅ |
N/A |
| hr |
employee_resume_lines |
✅ |
✅ |
N/A |
N/A |
| hr |
payslip_structures |
✅ |
✅ |
✅ |
N/A |
| hr |
payslips |
✅ |
✅ |
✅ |
N/A |
| hr |
payslip_lines |
✅ |
✅ |
N/A |
N/A |
Resultado: 26 tablas planificadas (24 del análisis + 2 extensiones construcción)
2.2 Campos Adicionales en Tablas Existentes
| Tabla |
Campo |
En FASE-2 |
En FASE-3 |
| financial.journal_entries |
payment_state |
✅ |
✅ |
| financial.journal_entries |
amount_residual |
✅ |
✅ |
| financial.journal_entries |
invoice_date_due |
✅ |
✅ |
| financial.journal_entries |
incoterm_id |
✅ |
✅ |
| financial.payments |
is_matched |
✅ |
✅ |
| financial.payments |
partner_bank_id |
✅ |
✅ |
| inventory.products |
tracking |
✅ |
✅ |
| inventory.products |
sale_ok |
✅ |
✅ |
| inventory.products |
purchase_ok |
✅ |
✅ |
| inventory.products |
volume |
✅ |
✅ |
| inventory.products |
weight |
✅ |
✅ |
| inventory.products |
hs_code |
✅ |
✅ |
| inventory.products |
origin_country_id |
✅ |
✅ |
| inventory.products |
removal_strategy_id |
✅ |
✅ |
| purchase.orders |
origin |
✅ |
✅ |
| purchase.orders |
partner_ref |
✅ |
✅ |
| purchase.orders |
date_approve |
✅ |
✅ |
| purchase.orders |
receipt_status |
✅ |
✅ |
| purchase.orders |
incoterm_id |
✅ |
✅ |
| construction.proyectos |
sequence |
✅ |
✅ |
| construction.proyectos |
is_favorite |
✅ |
✅ |
| construction.proyectos |
partida_count |
✅ |
✅ |
| construction.proyectos |
partida_pendiente_count |
✅ |
✅ |
| construction.proyectos |
partida_completada_count |
✅ |
✅ |
| construction.proyectos |
status_avance |
✅ |
✅ |
| hr.employees |
work_location_id |
✅ |
✅ |
| hr.employees |
badge_id |
✅ |
✅ |
| hr.employees |
pin |
✅ |
✅ |
| hr.employees |
barcode |
✅ |
✅ |
| hr.employees |
vehicle |
✅ |
✅ |
| hr.employees |
vehicle_license_plate |
✅ |
✅ |
| hr.employees |
certificate |
✅ |
✅ |
Resultado: 32 campos adicionales cubiertos
3. Validación de Funciones
| Función |
En FASE-2 |
En FASE-3 |
Propósito |
| construction.update_proyecto_partida_count() |
✅ |
✅ |
Trigger conteo partidas |
| construction.generate_avance_snapshot() |
✅ |
✅ |
Burndown de obra |
| purchase.action_create_stock_moves() |
✅ |
✅ |
Crear recepciones desde OC |
Resultado: 3/3 funciones cubiertas (la 4ta era opcional)
4. Validación de Seed Data
| Seed |
En FASE-2 |
En FASE-3 |
Registros |
| Incoterms |
✅ |
✅ |
11 |
| Removal strategies |
✅ |
✅ |
4 |
| Skill types (construcción) |
✅ |
✅ |
9 |
| Skill levels |
✅ |
✅ |
4 x 9 = 36 |
| Skills específicos |
✅ |
✅ |
~25 |
| Storage categories |
✅ |
✅ |
5 |
| Package types |
✅ |
✅ |
6 |
| Payment methods |
✅ |
✅ |
7 |
Resultado: 8/8 seeds planificados
5. Validación de Adaptaciones para Construcción
5.1 Extensiones Específicas del Giro
| Elemento |
Extensión |
Justificación |
| payment_term_lines.applies_to |
'anticipo', 'estimacion', 'retencion', 'finiquito' |
Términos de pago de obra |
| collaborators.rol |
'supervisor', 'perito', 'representante', 'infonavit' |
Roles de obra |
| collaborators.vigencia_desde/hasta |
DATE |
Vigencia de supervisores |
| ratings.proyecto_id |
UUID |
Calificación por proyecto |
| ratings.tipo_trabajo |
VARCHAR |
Tipo de trabajo evaluado |
| avance_programado |
Nueva tabla |
Burndown adaptado a obra |
| ubicaciones_obra |
Nueva tabla |
Geocercas de frentes |
| expense_sheets.proyecto_id |
UUID |
Gastos por proyecto |
| expense_sheets.centro_costo |
VARCHAR |
Centro de costo |
| product_supplierinfo.proyecto_id |
UUID |
Precio por proyecto |
| product_supplierinfo.aplica_iva |
BOOLEAN |
Indicador IVA |
| product_supplierinfo.flete_incluido |
BOOLEAN |
Indicador flete |
| payslips.proyecto_id |
UUID |
Nómina por proyecto |
| payslips.is_destajo |
BOOLEAN |
Pago a destajo |
| payslip_structures.tipo_pago |
'quincenal', 'semanal', 'destajo' |
Tipos de nómina |
Resultado: 15 extensiones específicas para construcción
6. Validación de Arquitectura
6.1 RLS (Row Level Security)
| Criterio |
Estado |
| Todas las tablas multi-tenant tienen RLS |
✅ |
Policy usa current_setting('app.current_tenant_id') |
✅ |
| Tablas catálogo sin RLS (incoterms, removal_strategies) |
✅ Correcto |
6.2 Foreign Keys
| FK |
Tabla Origen |
Tabla Destino |
Estado |
| payment_term_lines.payment_term_id |
payment_term_lines |
financial.payment_terms |
⚠️ Verificar existencia |
| reconcile_model_lines.account_id |
reconcile_model_lines |
financial.accounts |
⚠️ Verificar existencia |
| collaborators.project_id |
collaborators |
projects.projects |
⚠️ Verificar existencia |
| avance_programado.proyecto_id |
avance_programado |
construction.proyectos |
✅ Existe |
| ubicaciones_obra.proyecto_id |
ubicaciones_obra |
construction.proyectos |
✅ Existe |
| expense_sheets.employee_id |
expense_sheets |
hr.employees |
⚠️ Verificar existencia |
| payslips.contract_id |
payslips |
hr.contracts |
⚠️ Verificar existencia |
Acción Requerida: Validar existencia de tablas referenciadas en FASE-5
6.3 ENUMs
| ENUM |
Schema |
Valores |
| payment_method_type |
financial |
inbound, outbound |
| reconcile_model_type |
financial |
writeoff_button, writeoff_suggestion, invoice_matching |
| expense_status |
hr |
draft, submitted, approved, posted, paid, rejected |
| resume_line_type |
hr |
experience, education, certification, internal |
| payslip_status |
hr |
draft, verify, done, cancel |
Resultado: 5 ENUMs definidos correctamente
7. Matriz de Cobertura Final
| Categoría |
Análisis |
Plan |
Cobertura |
| Correcciones aplicables |
24 |
24 |
100% |
| Tablas nuevas |
24 |
26 |
108% (+2 extensiones) |
| Campos adicionales |
32 |
32 |
100% |
| Funciones |
3 |
3 |
100% |
| Seed data |
8 |
8 |
100% |
| Extensiones construcción |
15 |
15 |
100% |
8. Revisión de Conflictos Potenciales
8.1 Conflictos Identificados
| Conflicto |
Descripción |
Mitigación |
| Schema hr vs construction |
Posible confusión de tablas |
Prefijo claro en nombres |
| FK a tablas core |
payment_terms, accounts, projects.projects |
Verificar en FASE-5 |
| ENUM duplicados |
payment_method_type existe en core? |
Verificar en FASE-5 |
| Trigger en partidas |
Tabla puede tener estructura diferente |
Usar IF EXISTS |
8.2 Conflictos Resueltos
| Conflicto |
Solución |
| Nombre task_count vs partida_count |
Usar partida_count (más claro para construcción) |
| Burndown genérico vs avance_programado |
Crear avance_programado adaptado |
| work_locations genérico |
Crear ubicaciones_obra como extensión |
9. Sign-Off del Plan
9.1 Checklist de Aprobación
9.2 Riesgos Pendientes
| Riesgo |
Impacto |
Acción |
| Tablas referenciadas no existen |
Alto |
Validar en FASE-5 |
| Conflicto con ENUMs existentes |
Medio |
Validar en FASE-5 |
| Estructura de partidas diferente |
Medio |
Adaptar trigger |
9.3 Aprobación
Estado: ✅ PLAN APROBADO CON OBSERVACIONES
Observaciones: Requiere validación de dependencias (FASE-5)
Fecha: 2026-01-04
Revisor: Claude Code (Automatizado)
10. Resumen Ejecutivo
El plan de implementación para ERP Construcción cubre:
- 24 correcciones de ERP-Core FASE-8
- 26 tablas nuevas (24 + 2 extensiones)
- 32 campos adicionales en tablas existentes
- 3 funciones (trigger + snapshot + create_stock_moves)
- 8 archivos seed específicos de construcción
- 15 extensiones específicas del giro
El plan está APROBADO para continuar a FASE-5 (Análisis de Dependencias).
Estado: FASE 4 COMPLETADA
Siguiente: FASE 5 - Análisis de Dependencias
Fecha: 2026-01-04