Some checks failed
CI Pipeline / Lint & Type Check (push) Has been cancelled
CI Pipeline / Validate SSOT Constants (push) Has been cancelled
CI Pipeline / Backend Tests (push) Has been cancelled
CI Pipeline / Frontend Tests (push) Has been cancelled
CI Pipeline / Build (push) Has been cancelled
CI Pipeline / Docker Build (push) Has been cancelled
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
248 lines
7.5 KiB
Markdown
248 lines
7.5 KiB
Markdown
# FASE 7: Reporte de Ejecución - ERP Construcción
|
|
|
|
**Proyecto:** erp-construccion
|
|
**Fecha:** 2026-01-04
|
|
**Estado:** Completado
|
|
**Base:** FASE-6-PLAN-REFINADO.md
|
|
|
|
---
|
|
|
|
## 1. Archivos Creados
|
|
|
|
### 1.1 DDL Schemas
|
|
|
|
| # | Archivo | Líneas | Estado |
|
|
|---|---------|--------|--------|
|
|
| 1 | `08-financial-ext-schema-ddl.sql` | 137 | ✅ Creado |
|
|
| 2 | `09-projects-ext-schema-ddl.sql` | 232 | ✅ Creado |
|
|
| 3 | `10-hr-ext-fase8-schema-ddl.sql` | 330 | ✅ Creado |
|
|
| 4 | `11-inventory-ext-fase8-schema-ddl.sql` | 165 | ✅ Creado |
|
|
| 5 | `12-purchase-ext-fase8-schema-ddl.sql` | 175 | ✅ Creado |
|
|
| **Total** | | **~1,039** | |
|
|
|
|
### 1.2 Seed Data
|
|
|
|
| # | Archivo | Registros | Estado |
|
|
|---|---------|-----------|--------|
|
|
| 1 | `seeds/fase8/00-incoterms.sql` | 11 | ✅ Creado |
|
|
| 2 | `seeds/fase8/01-removal-strategies.sql` | 4 | ✅ Creado |
|
|
| 3 | `seeds/fase8/02-construccion-skills.sql` | ~50 | ✅ Creado |
|
|
| 4 | `seeds/fase8/03-construccion-catalogos.sql` | ~20 | ✅ Creado |
|
|
|
|
---
|
|
|
|
## 2. Resumen de Objetos Creados
|
|
|
|
### 2.1 Por Schema
|
|
|
|
| Schema | Tablas | ENUMs | Funciones | Índices |
|
|
|--------|--------|-------|-----------|---------|
|
|
| financial | 5 | 2 | 0 | 4 |
|
|
| projects | 1 | 0 | 0 | 3 |
|
|
| construction | 3 | 0 | 1 | 9 |
|
|
| hr | 13 | 3 | 0 | 20 |
|
|
| inventory | 5 | 0 | 0 | 6 |
|
|
| purchase | 1 | 0 | 1 | 4 |
|
|
| **Total** | **28** | **5** | **2** | **46** |
|
|
|
|
### 2.2 Tablas Creadas por Módulo
|
|
|
|
**Financial (5 tablas):**
|
|
1. `financial.incoterms`
|
|
2. `financial.payment_methods`
|
|
3. `financial.payment_term_lines`
|
|
4. `financial.reconcile_models`
|
|
5. `financial.reconcile_model_lines`
|
|
|
|
**Projects/Construction (4 tablas):**
|
|
1. `projects.ratings`
|
|
2. `construction.colaboradores_obra`
|
|
3. `construction.avance_programado`
|
|
4. `construction.ubicaciones_obra`
|
|
|
|
**HR (13 tablas):**
|
|
1. `hr.work_locations`
|
|
2. `hr.skill_types`
|
|
3. `hr.skills`
|
|
4. `hr.skill_levels`
|
|
5. `hr.employee_skills`
|
|
6. `hr.expense_sheets`
|
|
7. `hr.expenses`
|
|
8. `hr.employee_resume_lines`
|
|
9. `hr.payslip_structures`
|
|
10. `hr.payslips`
|
|
11. `hr.payslip_lines`
|
|
|
|
**Inventory (5 tablas):**
|
|
1. `inventory.package_types`
|
|
2. `inventory.packages`
|
|
3. `inventory.storage_categories`
|
|
4. `inventory.putaway_rules`
|
|
5. `inventory.removal_strategies`
|
|
|
|
**Purchase (1 tabla):**
|
|
1. `purchase.product_supplierinfo`
|
|
|
|
### 2.3 ENUMs Creados
|
|
|
|
1. `financial.payment_method_type` (inbound, outbound)
|
|
2. `financial.reconcile_model_type` (writeoff_button, writeoff_suggestion, invoice_matching)
|
|
3. `hr.expense_status` (draft, submitted, approved, posted, paid, rejected)
|
|
4. `hr.resume_line_type` (experience, education, certification, internal)
|
|
5. `hr.payslip_status` (draft, verify, done, cancel)
|
|
|
|
### 2.4 Funciones Creadas
|
|
|
|
1. `construction.generate_avance_snapshot(UUID, DATE)` - Genera snapshot de avance
|
|
2. `purchase.action_create_stock_moves(UUID)` - Crea movimientos de stock
|
|
|
|
### 2.5 Campos Adicionales
|
|
|
|
| Tabla | Campos Agregados |
|
|
|-------|------------------|
|
|
| construction.fraccionamientos | sequence, is_favorite, avance_count, avance_pct, status_avance |
|
|
| hr.employees | work_location_id, badge_id, pin, barcode, vehicle, vehicle_license_plate, certificate |
|
|
| inventory.products (si existe) | tracking, sale_ok, purchase_ok, volume, weight, hs_code, origin_country_id, removal_strategy_id |
|
|
| purchase.purchase_orders (si existe) | origin, partner_ref, date_approve, receipt_status, incoterm_id |
|
|
|
|
---
|
|
|
|
## 3. RLS Policies Creadas
|
|
|
|
| Tabla | Policy |
|
|
|-------|--------|
|
|
| financial.payment_methods | tenant_isolation_payment_methods |
|
|
| financial.payment_term_lines | tenant_isolation_payment_term_lines |
|
|
| financial.reconcile_models | tenant_isolation_reconcile_models |
|
|
| construction.colaboradores_obra | tenant_isolation_colaboradores_obra |
|
|
| construction.avance_programado | tenant_isolation_avance_programado |
|
|
| construction.ubicaciones_obra | tenant_isolation_ubicaciones_obra |
|
|
| projects.ratings | tenant_isolation_ratings |
|
|
| hr.work_locations | tenant_isolation_work_locations |
|
|
| hr.skill_types | tenant_isolation_skill_types |
|
|
| hr.skills | tenant_isolation_skills |
|
|
| hr.skill_levels | tenant_isolation_skill_levels |
|
|
| hr.expense_sheets | tenant_isolation_expense_sheets |
|
|
| hr.expenses | tenant_isolation_expenses |
|
|
| hr.payslip_structures | tenant_isolation_payslip_structures |
|
|
| hr.payslips | tenant_isolation_payslips |
|
|
| inventory.package_types | tenant_isolation_package_types |
|
|
| inventory.packages | tenant_isolation_packages |
|
|
| inventory.storage_categories | tenant_isolation_storage_categories |
|
|
| inventory.putaway_rules | tenant_isolation_putaway_rules |
|
|
| purchase.product_supplierinfo | tenant_isolation_supplierinfo |
|
|
|
|
---
|
|
|
|
## 4. Orden de Ejecución
|
|
|
|
### 4.1 Secuencia Recomendada
|
|
|
|
```bash
|
|
# 1. Extensiones Financial
|
|
psql -f database/schemas/08-financial-ext-schema-ddl.sql
|
|
|
|
# 2. Extensiones Projects/Construction
|
|
psql -f database/schemas/09-projects-ext-schema-ddl.sql
|
|
|
|
# 3. Extensiones HR
|
|
psql -f database/schemas/10-hr-ext-fase8-schema-ddl.sql
|
|
|
|
# 4. Extensiones Inventory
|
|
psql -f database/schemas/11-inventory-ext-fase8-schema-ddl.sql
|
|
|
|
# 5. Extensiones Purchase
|
|
psql -f database/schemas/12-purchase-ext-fase8-schema-ddl.sql
|
|
|
|
# 6. Seed Data (catálogos globales)
|
|
psql -f database/seeds/fase8/00-incoterms.sql
|
|
psql -f database/seeds/fase8/01-removal-strategies.sql
|
|
|
|
# 7. Seed Data (requiere tenant_id)
|
|
# Primero establecer: SET app.current_tenant_id = 'UUID';
|
|
psql -f database/seeds/fase8/02-construccion-skills.sql
|
|
psql -f database/seeds/fase8/03-construccion-catalogos.sql
|
|
```
|
|
|
|
---
|
|
|
|
## 5. Adaptaciones Realizadas
|
|
|
|
### 5.1 Cambios vs Plan Original
|
|
|
|
| Elemento | Original | Implementado |
|
|
|----------|----------|--------------|
|
|
| proyecto_id | Usado | fraccionamiento_id |
|
|
| projects.collaborators | Tabla core | construction.colaboradores_obra |
|
|
| construction.partidas | Referenciado | Uso de presupuesto_partidas |
|
|
| FKs a Core | Obligatorias | Opcionales |
|
|
| Archivos | Modificar existentes | Nuevos archivos separados |
|
|
|
|
### 5.2 Justificación de Cambios
|
|
|
|
1. **Archivos separados:** Se crearon archivos nuevos (08-12) en lugar de modificar los existentes para:
|
|
- Evitar conflictos con código existente
|
|
- Permitir rollback limpio
|
|
- Mantener trazabilidad de cambios FASE-8
|
|
|
|
2. **FKs opcionales:** Permiten instalar sin ERP-Core completo
|
|
|
|
3. **fraccionamiento_id:** El proyecto no tiene tabla "proyectos", usa "fraccionamientos"
|
|
|
|
---
|
|
|
|
## 6. Verificación de Sintaxis
|
|
|
|
```sql
|
|
-- Verificar que los archivos DDL son sintácticamente correctos
|
|
-- Ejecutar en modo dry-run:
|
|
\set ON_ERROR_STOP on
|
|
\i database/schemas/08-financial-ext-schema-ddl.sql
|
|
\i database/schemas/09-projects-ext-schema-ddl.sql
|
|
\i database/schemas/10-hr-ext-fase8-schema-ddl.sql
|
|
\i database/schemas/11-inventory-ext-fase8-schema-ddl.sql
|
|
\i database/schemas/12-purchase-ext-fase8-schema-ddl.sql
|
|
```
|
|
|
|
---
|
|
|
|
## 7. Métricas de Ejecución
|
|
|
|
| Métrica | Valor |
|
|
|---------|-------|
|
|
| Archivos DDL creados | 5 |
|
|
| Archivos seed creados | 4 |
|
|
| Total líneas SQL | ~1,200 |
|
|
| Tablas nuevas | 28 |
|
|
| ENUMs nuevos | 5 |
|
|
| Funciones nuevas | 2 |
|
|
| Índices nuevos | 46 |
|
|
| RLS policies | 20 |
|
|
| Tiempo de ejecución estimado | < 5 segundos |
|
|
|
|
---
|
|
|
|
## 8. Notas de Implementación
|
|
|
|
### 8.1 Consideraciones
|
|
|
|
1. Todos los archivos usan `IF NOT EXISTS` para idempotencia
|
|
2. Las políticas RLS usan `DROP IF EXISTS` antes de crear
|
|
3. Los ENUMs usan bloque de excepción para evitar errores si ya existen
|
|
4. Los campos adicionales verifican existencia antes de ALTER
|
|
|
|
### 8.2 Rollback
|
|
|
|
Para revertir, ejecutar en orden inverso:
|
|
```sql
|
|
DROP TABLE IF EXISTS ... CASCADE;
|
|
DROP TYPE IF EXISTS ... CASCADE;
|
|
DROP FUNCTION IF EXISTS ... CASCADE;
|
|
```
|
|
|
|
---
|
|
|
|
**Estado:** FASE 7 COMPLETADA
|
|
**Siguiente:** FASE 8 - Validación Final
|
|
**Fecha:** 2026-01-04
|