erp-retail/orchestration/planes/fase-1-analisis/ANALISIS-ERP-CORE-INVENTARIO.md

8.9 KiB

ANALISIS ERP-CORE - INVENTARIO COMPLETO

Fecha: 2025-12-18 Fase: 1 - Planeacion Objetivo: Inventario detallado del estado actual de erp-core


RESUMEN EJECUTIVO

Metrica Valor
Modulos Backend 16
Modulos Completados 0 (0%)
Modulos En Desarrollo 5 (31%)
Modulos Planificados 11 (69%)
Total Tablas DDL 144
Total Lineas DDL 9,752
Total Entidades TypeORM 30+
Total Documentacion 650+ archivos

1. MODULOS BACKEND

1.1 Modulos Foundation (MGN-001 a MGN-004)

Modulo Codigo Estado Progreso Archivos Dependencias
Auth MGN-001 En desarrollo 40% auth.service.ts, auth.controller.ts, auth.routes.ts, apiKeys.service.ts, 11 entities Ninguna
Users MGN-002 En desarrollo 30% users.service.ts, users.controller.ts, users.routes.ts MGN-001
Roles MGN-003 Planificado 0% roles.service.ts, permissions.service.ts MGN-001, MGN-002
Tenants MGN-004 Planificado 0% tenants/ (planificado) MGN-001

1.2 Modulos Core Business

Modulo Codigo Estado Progreso Archivos Principales
Catalogs MGN-005 Planificado 0% countries.service.ts, currencies.service.ts, uom.service.ts, product-categories.service.ts
Settings MGN-006 Planificado 0% (pendiente)
Audit MGN-007 Planificado 0% (pendiente)
Notifications MGN-008 Planificado 0% (pendiente)
Reports MGN-009 Planificado 0% (pendiente)
Financial MGN-010 En desarrollo 70% accounts.service.ts, journals.service.ts, taxes.service.ts, invoices.service.ts, payments.service.ts, 11 entities
Inventory MGN-011 En desarrollo 60% products.service.ts, warehouses.service.ts, locations.service.ts, lots.service.ts, pickings.service.ts, valuation.service.ts
Purchasing MGN-012 Planificado 0% rfqs.service.ts, purchases.service.ts
Sales MGN-013 En desarrollo 50% orders.service.ts, quotations.service.ts, pricelists.service.ts, customer-groups.service.ts
CRM MGN-014 Planificado 0% leads.service.ts, opportunities.service.ts, stages.service.ts
Projects MGN-015 Planificado 0% projects.service.ts, tasks.service.ts
HR MGN-016 Planificado 0% employees.service.ts, departments.service.ts, contracts.service.ts, leaves.service.ts

2. ESTRUCTURA DATABASE DDL

2.1 Archivos DDL

Archivo Lineas Schema Descripcion
00-prerequisites.sql 207 - Extensiones PostgreSQL
01-auth.sql 620 auth Autenticacion base
01-auth-extensions.sql 891 auth OAuth, MFA, API Keys
02-core.sql 755 core Partners, contactos
03-analytics.sql 510 analytics Contabilidad analitica
04-financial.sql 970 financial Contabilidad, facturas
05-inventory.sql 772 inventory Stock, productos
05-inventory-extensions.sql 966 inventory Valoracion, lotes
06-purchase.sql 583 purchasing Ordenes de compra
07-sales.sql 705 sales Ventas, cotizaciones
08-projects.sql 537 projects Proyectos, tareas
09-system.sql 853 system Auditoria, settings
10-billing.sql 638 billing SaaS (opcional)
11-crm.sql 366 crm Leads, oportunidades
12-hr.sql 379 hr Empleados, contratos
TOTAL 9,752 12 144 tablas

2.2 Schemas y Tablas

Schema Tablas Uso Principal
auth 26 Autenticacion, MFA, OAuth, API Keys, roles, permisos
core 12 Partners (clientes/proveedores), catalogos, UoM
financial 15 Contabilidad, facturas, pagos, asientos
inventory 20 Productos, stock, valoracion FIFO/AVCO, lotes
purchase 8 Ordenes de compra, proveedores
sales 10 Ventas, cotizaciones, equipos de venta
projects 10 Proyectos, tareas, dependencias
analytics 7 Contabilidad analitica, centros de costo
system 13 Mensajes, notificaciones, logs, auditoria
billing 11 SaaS/Suscripciones (opcional)
crm 6 Leads, oportunidades
hr 6 Empleados, contratos, ausencias

3. ENTIDADES TYPEORM

3.1 Entidades por Modulo

Auth Module (11 entities):

  • User, Tenant, Company, Session, Role, Permission
  • PasswordReset, OAuthUserLink, TrustedDevice
  • VerificationCode, MFAAuditLog

Financial Module (11 entities):

  • Account, AccountType, Journal, JournalEntry, JournalEntryLine
  • Invoice, InvoiceLine, Payment, Tax
  • FiscalYear, FiscalPeriod

Core Module (7 entities):

  • Country, Currency, UoM, UoMCategory
  • ProductCategory, Sequence, Partner

Inventory Module:

  • Product, ProductVariant, Warehouse, Location
  • Lot, StockQuant, Picking, StockMove
  • InventoryAdjustment, InventoryAdjustmentLine

4. DOCUMENTACION EXISTENTE

4.1 Estructura de Docs

docs/
├── 00-vision-general/           # Vision y objetivos
├── 01-analisis-referencias/     # Analisis Odoo, Gamilit
│   ├── odoo/                   # 9 analisis de modulos Odoo
│   ├── gamilit/                # Patrones de arquitectura
│   └── construccion/           # Analisis construccion
├── 01-fase-foundation/          # MGN-001 a MGN-004
│   ├── MGN-001-auth/
│   ├── MGN-002-users/
│   ├── MGN-003-roles/
│   └── MGN-004-tenants/
├── 02-definicion-modulos/       # Indice y alcance
│   └── gaps/                   # GAP-ANALYSIS por modulo
├── 02-fase-core-business/       # MGN-005 a MGN-010
└── 04-modelado/
    ├── domain-models/
    └── especificaciones-tecnicas/

4.2 Especificaciones Tecnicas Existentes

Especificacion Proposito
SPEC-PRICING-RULES.md Reglas de precios y promociones
SPEC-INVENTARIOS-CICLICOS.md Conteo de inventarios
SPEC-TRAZABILIDAD-LOTES-SERIES.md Lotes y numeros de serie
SPEC-VALORACION-INVENTARIO.md Costeo FIFO/LIFO/Promedio
SPEC-SISTEMA-SECUENCIAS.md Foliado automatico
SPEC-REPORTES-FINANCIEROS.md Balance, P&L

4.3 GAP Analysis Existentes

  • GAP-ANALYSIS-MGN-001.md (Auth)
  • GAP-ANALYSIS-MGN-003.md (Roles)
  • GAP-ANALYSIS-MGN-006.md (Settings)
  • GAP-ANALYSIS-MGN-009.md (Reports)
  • GAP-ANALYSIS-MGN-010.md (Financial)
  • Y otros 10+ documentos

5. ESTADO DE MIGRACION TYPEORM

5.1 Financial Module

Servicio Estado Notas
accounts.service.ts MIGRADO Completo con TypeORM
journals.service.ts EN PROGRESO Migrando
taxes.service.ts PENDIENTE Archivo .old.ts disponible
invoices.service.ts PENDIENTE
payments.service.ts PENDIENTE

5.2 Inventory Module

Servicio Estado
products.service.ts EN PROGRESO
warehouses.service.ts EN PROGRESO
locations.service.ts PENDIENTE
lots.service.ts PENDIENTE
valuation.service.ts PENDIENTE

6. SHARED CODE

6.1 Ubicacion: /src/shared/

Directorio Archivos Proposito
middleware/ auth.middleware.ts, apiKeyAuth.middleware.ts, fieldPermissions.middleware.ts Autenticacion y permisos
services/ base.service.ts CRUD generico
errors/ index.ts Errores customizados
types/ index.ts Tipos TypeScript
utils/ logger.ts Logging

7. BLOQUEADORES PARA RETAIL

7.1 Modulos Criticos (Deben completarse)

Modulo Estado Actual Accion Requerida
MGN-001 Auth 40% Completar al 100%
MGN-005 Catalogs 0% Implementar basico
MGN-010 Financial 70% Finalizar migracion TypeORM
MGN-011 Inventory 60% Completar con extensiones
MGN-013 Sales 50% Completar

7.2 Orden de Implementacion Recomendado

  1. Sprint 1-2: MGN-001 Auth (40% → 100%)
  2. Sprint 3-4: MGN-002 Users + MGN-005 Catalogs
  3. Sprint 5-8: MGN-010 Financial + MGN-011 Inventory
  4. Sprint 9-10: MGN-012 Purchasing + MGN-013 Sales

8. CONFIGURACION TECNICA

8.1 Stack

Capa Tecnologia Version
Backend Node.js + Express 20+, 4.x
ORM TypeORM 0.3.17
Database PostgreSQL 15+
Auth JWT + bcrypt
Cache Redis (planificado)

8.2 Variable RLS

current_setting('app.current_tenant_id', true)::UUID

9. REFERENCIAS

Recurso Ubicacion
README Principal apps/erp-core/README.md
Project Status apps/erp-core/PROJECT-STATUS.md
Backend Modules apps/erp-core/backend/src/modules/
DDL Files apps/erp-core/database/ddl/
Documentacion apps/erp-core/docs/
TypeORM Config apps/erp-core/backend/src/config/typeorm.ts

Documento generado: 2025-12-18 Fase: 1 - Planeacion - Analisis Detallado Estado: COMPLETO