# ROADMAP DE SPRINTS - RETAIL

**Fecha:** 2025-12-18
**Fase:** 3 - Plan de Implementaciones
**Metodologia:** Sprints de 1 semana
**Total Story Points:** 353 SP

---

## 1. RESUMEN EJECUTIVO

### 1.1 Distribucion de Esfuerzo

| Modulo | SP | % del Total | Prioridad |
|--------|----|-----------:|-----------|
| RT-001 Fundamentos | 0* | 0% | P0 |
| RT-002 POS | 55 | 15.6% | P0 |
| RT-003 Inventario | 42 | 11.9% | P0 |
| RT-004 Compras | 38 | 10.8% | P1 |
| RT-005 Clientes | 34 | 9.6% | P1 |
| RT-006 Precios | 36 | 10.2% | P0 |
| RT-007 Caja | 28 | 7.9% | P0 |
| RT-008 Reportes | 30 | 8.5% | P1 |
| RT-009 E-commerce | 55 | 15.6% | P2 |
| RT-010 Facturacion | 35 | 9.9% | P0 |
| **TOTAL** | **353** | **100%** | |

*RT-001 hereda 100% del core

### 1.2 Prerrequisitos Core (Bloqueadores)

Antes de iniciar retail, se deben completar estos modulos del core:

| Modulo Core | Estado Actual | Requerido | Gap |
|-------------|---------------|-----------|-----|
| MGN-001 Auth | 40% | 100% | 60% |
| MGN-005 Catalogs | 0% | 100% | 100% |
| MGN-010 Financial | 70% | 90% | 20% |
| MGN-011 Inventory | 60% | 80% | 20% |
| MGN-013 Sales | 50% | 70% | 20% |

**Estimacion prerrequisitos:** 3-4 sprints

---

## 2. FASES DE IMPLEMENTACION

### 2.1 Vision General

```
┌─────────────────────────────────────────────────────────────────────────────┐
│                        ROADMAP RETAIL - 20 SPRINTS                          │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  FASE 0: PRERREQUISITOS CORE (Sprints 1-4)                                 │
│  ├── S1-S2: Auth + Catalogs                                                │
│  └── S3-S4: Financial + Inventory + Sales                                  │
│                                                                             │
│  FASE 1: FUNDAMENTOS RETAIL (Sprints 5-7)                                  │
│  ├── S5: Database retail + RT-001 Fundamentos                              │
│  ├── S6: RT-006 Motor de Precios                                           │
│  └── S7: RT-003 Inventario Multi-sucursal                                  │
│                                                                             │
│  FASE 2: POS MVP (Sprints 8-11)                                            │
│  ├── S8-S9: RT-002 POS Backend + Frontend                                  │
│  ├── S10: RT-007 Caja                                                      │
│  └── S11: PWA + Offline                                                    │
│                                                                             │
│  FASE 3: FACTURACION + CLIENTES (Sprints 12-14)                            │
│  ├── S12: RT-010 CFDI Backend                                              │
│  ├── S13: RT-010 CFDI Frontend + Autofactura                               │
│  └── S14: RT-005 Clientes + Lealtad                                        │
│                                                                             │
│  FASE 4: COMPRAS + REPORTES (Sprints 15-16)                                │
│  ├── S15: RT-004 Compras                                                   │
│  └── S16: RT-008 Reportes + Dashboard                                      │
│                                                                             │
│  FASE 5: E-COMMERCE (Sprints 17-20)                                        │
│  ├── S17-S18: RT-009 Backend + Integraciones                               │
│  └── S19-S20: RT-009 Storefront                                            │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘
```

---

## 3. DETALLE POR SPRINT

### FASE 0: PRERREQUISITOS CORE

#### Sprint 1: Auth + Catalogs (Parte 1)
**Objetivo:** Completar autenticacion y catalogos base

| Tarea | Capa | SP |
|-------|------|---:|
| Completar entities User, Role, Permission | Backend | 3 |
| Completar AuthService con JWT | Backend | 3 |
| Implementar middleware de autenticacion | Backend | 2 |
| Crear tablas core.countries, currencies | Database | 2 |
| Implementar CountriesService, CurrenciesService | Backend | 2 |
| **Total Sprint 1** | | **12** |

#### Sprint 2: Catalogs (Parte 2)
**Objetivo:** Completar catalogos y UoM

| Tarea | Capa | SP |
|-------|------|---:|
| Crear tablas core.uom_categories, uom | Database | 2 |
| Implementar UoMService | Backend | 2 |
| Crear core.sequences | Database | 1 |
| Implementar SequencesService | Backend | 2 |
| Crear tablas core.partners | Database | 2 |
| Implementar PartnersService | Backend | 3 |
| **Total Sprint 2** | | **12** |

#### Sprint 3: Financial
**Objetivo:** Completar modulo financiero base

| Tarea | Capa | SP |
|-------|------|---:|
| Migrar financial.taxes a TypeORM | Backend | 3 |
| Migrar financial.accounts a TypeORM | Backend | 3 |
| Migrar financial.journals a TypeORM | Backend | 2 |
| Implementar payment_methods | Backend | 2 |
| Tests unitarios financial | Backend | 2 |
| **Total Sprint 3** | | **12** |

#### Sprint 4: Inventory + Sales
**Objetivo:** Completar inventario y ventas base

| Tarea | Capa | SP |
|-------|------|---:|
| Completar inventory.products con TypeORM | Backend | 3 |
| Completar inventory.warehouses | Backend | 2 |
| Completar inventory.stock_quants | Backend | 3 |
| Implementar sales.pricelists | Backend | 3 |
| Implementar sales.pricelist_items | Backend | 2 |
| **Total Sprint 4** | | **13** |

---

### FASE 1: FUNDAMENTOS RETAIL

#### Sprint 5: Database Retail + Fundamentos
**Objetivo:** Crear schema retail y tablas fundacionales

| Tarea | Capa | SP |
|-------|------|---:|
| Crear schema retail | Database | 1 |
| Crear retail.branches | Database | 2 |
| Crear retail.cash_registers | Database | 1 |
| Crear retail.branch_users | Database | 1 |
| BranchesService | Backend | 3 |
| CashRegistersService | Backend | 2 |
| BranchesController | Backend | 2 |
| **Total Sprint 5** | | **12** |

#### Sprint 6: Motor de Precios
**Objetivo:** RT-006 - Sistema de precios y promociones

| Tarea | Capa | SP |
|-------|------|---:|
| Crear retail.promotions, promotion_products | Database | 2 |
| Crear retail.coupons, coupon_redemptions | Database | 2 |
| PriceEngineService (core) | Backend | 8 |
| PromotionsService | Backend | 5 |
| CouponsService | Backend | 5 |
| PricingController | Backend | 3 |
| **Total Sprint 6** | | **25** |

*Nota: Este sprint tiene mas SP porque el motor de precios es critico*

#### Sprint 7: Inventario Multi-sucursal
**Objetivo:** RT-003 - Gestion de inventario por sucursal

| Tarea | Capa | SP |
|-------|------|---:|
| Crear retail.stock_transfers | Database | 2 |
| Crear retail.stock_adjustments | Database | 2 |
| RetailStockService (extiende core) | Backend | 5 |
| TransfersService | Backend | 5 |
| AdjustmentsService | Backend | 3 |
| InventoryController | Backend | 3 |
| **Total Sprint 7** | | **20** |

---

### FASE 2: POS MVP

#### Sprint 8: POS Backend
**Objetivo:** RT-002 - Backend del punto de venta

| Tarea | Capa | SP |
|-------|------|---:|
| Crear retail.pos_sessions | Database | 2 |
| Crear retail.pos_orders, pos_order_lines | Database | 3 |
| Crear retail.pos_payments | Database | 2 |
| POSSessionService | Backend | 5 |
| POSOrderService | Backend | 8 |
| POSPaymentService | Backend | 3 |
| POSController | Backend | 3 |
| **Total Sprint 8** | | **26** |

#### Sprint 9: POS Frontend
**Objetivo:** UI del punto de venta

| Tarea | Capa | SP |
|-------|------|---:|
| Layout POS | Frontend | 2 |
| Pagina Login + Seleccion Caja | Frontend | 2 |
| Pantalla de Ventas | Frontend | 8 |
| Pantalla de Cobro | Frontend | 5 |
| Componente ProductGrid | Frontend | 3 |
| Componente OrderLines | Frontend | 2 |
| Componente PaymentMethods | Frontend | 3 |
| **Total Sprint 9** | | **25** |

#### Sprint 10: Caja
**Objetivo:** RT-007 - Arqueos y cortes de caja

| Tarea | Capa | SP |
|-------|------|---:|
| Crear retail.cash_movements | Database | 1 |
| Crear retail.cash_closings | Database | 2 |
| Crear retail.cash_counts | Database | 1 |
| CashSessionService | Backend | 5 |
| CashMovementService | Backend | 3 |
| CashClosingService | Backend | 5 |
| CashController | Backend | 3 |
| UI Apertura Caja | Frontend | 2 |
| UI Movimientos | Frontend | 2 |
| UI Cierre con Denominaciones | Frontend | 3 |
| **Total Sprint 10** | | **27** |

#### Sprint 11: PWA + Offline
**Objetivo:** Soporte offline para POS

| Tarea | Capa | SP |
|-------|------|---:|
| Configurar Service Worker | Frontend | 3 |
| IndexedDB con Dexie | Frontend | 3 |
| Cola de sincronizacion | Frontend | 5 |
| POSSyncService | Backend | 5 |
| WebSocket Gateway | Backend | 3 |
| Tests de offline | Frontend | 2 |
| Indicadores de estado | Frontend | 2 |
| **Total Sprint 11** | | **23** |

---

### FASE 3: FACTURACION + CLIENTES

#### Sprint 12: CFDI Backend
**Objetivo:** RT-010 - Backend de facturacion CFDI 4.0

| Tarea | Capa | SP |
|-------|------|---:|
| Crear retail.cfdi_config | Database | 1 |
| Crear retail.cfdis | Database | 2 |
| CFDIService | Backend | 5 |
| CFDIBuilderService | Backend | 5 |
| XMLService | Backend | 3 |
| PACService (Finkok) | Backend | 5 |
| CFDIController | Backend | 3 |
| **Total Sprint 12** | | **24** |

#### Sprint 13: CFDI Frontend + Autofactura
**Objetivo:** UI de facturacion y portal autofactura

| Tarea | Capa | SP |
|-------|------|---:|
| PDFService | Backend | 2 |
| AutofacturaService | Backend | 3 |
| AutofacturaController | Backend | 2 |
| Modal Facturacion en POS | Frontend | 3 |
| Portal Autofactura (publico) | Frontend | 4 |
| Configuracion CFDI (backoffice) | Frontend | 2 |
| Lista de Facturas | Frontend | 2 |
| **Total Sprint 13** | | **18** |

#### Sprint 14: Clientes + Lealtad
**Objetivo:** RT-005 - Gestion de clientes y programa de lealtad

| Tarea | Capa | SP |
|-------|------|---:|
| Crear retail.loyalty_programs | Database | 1 |
| Crear retail.membership_levels | Database | 1 |
| Crear retail.loyalty_transactions | Database | 1 |
| Crear retail.customer_memberships | Database | 1 |
| RetailCustomersService | Backend | 3 |
| LoyaltyService | Backend | 8 |
| CustomersController | Backend | 3 |
| Lista Clientes (backoffice) | Frontend | 3 |
| Detalle Cliente con Membresia | Frontend | 3 |
| Config Programa Lealtad | Frontend | 2 |
| Widget Puntos en POS | Frontend | 2 |
| **Total Sprint 14** | | **28** |

---

### FASE 4: COMPRAS + REPORTES

#### Sprint 15: Compras
**Objetivo:** RT-004 - Gestion de compras y reabastecimiento

| Tarea | Capa | SP |
|-------|------|---:|
| Crear retail.purchase_suggestions | Database | 2 |
| Crear retail.supplier_orders | Database | 2 |
| Crear retail.goods_receipts | Database | 2 |
| RetailPurchaseService | Backend | 5 |
| PurchaseSuggestionsService | Backend | 5 |
| GoodsReceiptService | Backend | 3 |
| PurchaseController | Backend | 3 |
| Lista Sugerencias (backoffice) | Frontend | 3 |
| Nueva Orden Proveedor | Frontend | 4 |
| Recepcion de Mercancia | Frontend | 3 |
| **Total Sprint 15** | | **32** |

#### Sprint 16: Reportes + Dashboard
**Objetivo:** RT-008 - Dashboard y reportes

| Tarea | Capa | SP |
|-------|------|---:|
| Crear vistas materializadas | Database | 2 |
| DashboardService | Backend | 3 |
| SalesReportService | Backend | 3 |
| ProductReportService | Backend | 2 |
| CashReportService | Backend | 2 |
| ExportService (Excel/PDF) | Backend | 3 |
| ReportsController | Backend | 3 |
| Dashboard Principal | Frontend | 8 |
| Paginas de Reportes | Frontend | 3 |
| Componentes de Graficos | Frontend | 3 |
| **Total Sprint 16** | | **32** |

---

### FASE 5: E-COMMERCE

#### Sprint 17: E-commerce Backend (Parte 1)
**Objetivo:** RT-009 - Backend de tienda online

| Tarea | Capa | SP |
|-------|------|---:|
| Crear retail.carts, cart_items | Database | 2 |
| Crear retail.ecommerce_orders | Database | 2 |
| Crear retail.shipping_rates | Database | 1 |
| CatalogService | Backend | 3 |
| CartService | Backend | 5 |
| CheckoutService | Backend | 5 |
| EcommerceOrderService | Backend | 5 |
| **Total Sprint 17** | | **23** |

#### Sprint 18: E-commerce Backend (Parte 2) + Integraciones
**Objetivo:** Pasarelas de pago y envio

| Tarea | Capa | SP |
|-------|------|---:|
| PaymentGatewayService | Backend | 8 |
| Stripe/Conekta Provider | Backend | 5 |
| ShippingService | Backend | 5 |
| StorefrontController | Backend | 3 |
| EcommerceAdminController | Backend | 3 |
| **Total Sprint 18** | | **24** |

#### Sprint 19: Storefront (Parte 1)
**Objetivo:** UI de tienda online - Catalogo y Carrito

| Tarea | Capa | SP |
|-------|------|---:|
| Layout Storefront | Frontend | 2 |
| Home y navegacion | Frontend | 3 |
| Catalogo de Productos | Frontend | 5 |
| Detalle de Producto | Frontend | 4 |
| Busqueda de Productos | Frontend | 3 |
| Carrito (drawer) | Frontend | 3 |
| **Total Sprint 19** | | **20** |

#### Sprint 20: Storefront (Parte 2)
**Objetivo:** UI de tienda - Checkout y Area Cliente

| Tarea | Capa | SP |
|-------|------|---:|
| Checkout Flow completo | Frontend | 8 |
| Integracion Stripe/Conekta | Frontend | 5 |
| Area de Cliente | Frontend | 4 |
| Mis Pedidos | Frontend | 3 |
| Gestion Pedidos (backoffice) | Frontend | 4 |
| **Total Sprint 20** | | **24** |

---

## 4. RESUMEN DE SPRINTS

| Sprint | Fase | Enfoque | SP Total | SP Acumulados |
|--------|------|---------|----------|---------------|
| 1 | 0 | Auth + Catalogs P1 | 12 | 12 |
| 2 | 0 | Catalogs P2 | 12 | 24 |
| 3 | 0 | Financial | 12 | 36 |
| 4 | 0 | Inventory + Sales | 13 | 49 |
| 5 | 1 | DB Retail + Fundamentos | 12 | 61 |
| 6 | 1 | Motor de Precios | 25 | 86 |
| 7 | 1 | Inventario Multi-sucursal | 20 | 106 |
| 8 | 2 | POS Backend | 26 | 132 |
| 9 | 2 | POS Frontend | 25 | 157 |
| 10 | 2 | Caja | 27 | 184 |
| 11 | 2 | PWA + Offline | 23 | 207 |
| 12 | 3 | CFDI Backend | 24 | 231 |
| 13 | 3 | CFDI Frontend | 18 | 249 |
| 14 | 3 | Clientes + Lealtad | 28 | 277 |
| 15 | 4 | Compras | 32 | 309 |
| 16 | 4 | Reportes + Dashboard | 32 | 341 |
| 17 | 5 | E-commerce Backend P1 | 23 | 364 |
| 18 | 5 | E-commerce Backend P2 | 24 | 388 |
| 19 | 5 | Storefront P1 | 20 | 408 |
| 20 | 5 | Storefront P2 | 24 | 432 |

**Total Story Points:** 432 SP (incluye 49 SP de prerrequisitos core + 383 SP retail)

---

## 5. HITOS (MILESTONES)

### M1: Core Ready
**Sprint:** 4
**Criterio:** Modulos core completados para soportar retail
- [ ] Auth funcional con JWT
- [ ] Catalogos cargados
- [ ] Financial con TypeORM
- [ ] Inventory y Sales base

### M2: Retail Foundation
**Sprint:** 7
**Criterio:** Base de retail lista
- [ ] Schema retail creado
- [ ] Sucursales configurables
- [ ] Motor de precios funcionando
- [ ] Inventario multi-sucursal

### M3: POS MVP
**Sprint:** 11
**Criterio:** POS operativo con offline
- [ ] Ventas en POS
- [ ] Multiples formas de pago
- [ ] Caja con arqueos/cortes
- [ ] Modo offline funcional
- [ ] Impresion de tickets

### M4: Facturacion Completa
**Sprint:** 13
**Criterio:** CFDI 4.0 operativo
- [ ] Emision de facturas
- [ ] Cancelacion
- [ ] Autofactura publica
- [ ] Generacion PDF

### M5: Retail Completo
**Sprint:** 16
**Criterio:** Retail 100% funcional (sin e-commerce)
- [ ] Programa de lealtad
- [ ] Gestion de compras
- [ ] Dashboard y reportes

### M6: E-commerce Live
**Sprint:** 20
**Criterio:** Tienda online operativa
- [ ] Catalogo publico
- [ ] Carrito y checkout
- [ ] Pagos online
- [ ] Area de cliente

---

## 6. DEPENDENCIAS CRITICAS

### Grafico de Dependencias

```
                    ┌─────────────┐
                    │ MGN-001     │
                    │ Auth        │
                    └──────┬──────┘
                           │
         ┌─────────────────┼─────────────────┐
         │                 │                 │
         v                 v                 v
┌────────────────┐ ┌──────────────┐ ┌──────────────┐
│ MGN-005        │ │ MGN-010      │ │ MGN-011      │
│ Catalogs       │ │ Financial    │ │ Inventory    │
└───────┬────────┘ └──────┬───────┘ └──────┬───────┘
        │                 │                │
        └────────┬────────┴────────┬───────┘
                 │                 │
                 v                 v
         ┌──────────────┐ ┌──────────────┐
         │ RT-001       │ │ MGN-013      │
         │ Fundamentos  │ │ Sales        │
         └──────┬───────┘ └──────┬───────┘
                │                │
    ┌───────────┼───────────┬────┘
    │           │           │
    v           v           v
┌────────┐ ┌────────┐ ┌────────┐
│ RT-006 │ │ RT-003 │ │ RT-005 │
│ Precios│ │ Invent.│ │ Client │
└───┬────┘ └───┬────┘ └───┬────┘
    │          │          │
    └──────────┼──────────┘
               │
               v
        ┌──────────────┐
        │   RT-002     │
        │    POS       │
        └──────┬───────┘
               │
    ┌──────────┼──────────┐
    │          │          │
    v          v          v
┌────────┐ ┌────────┐ ┌────────┐
│ RT-007 │ │ RT-010 │ │ RT-008 │
│ Caja   │ │ CFDI   │ │ Report │
└────────┘ └────────┘ └────────┘
                          │
                          v
                   ┌──────────────┐
                   │   RT-009     │
                   │  E-commerce  │
                   └──────────────┘
                          │
                          v
                   ┌──────────────┐
                   │   RT-004     │
                   │   Compras    │
                   └──────────────┘
```

### Camino Critico

1. **Auth** -> Fundamentos -> POS -> Caja
2. **Financial** -> CFDI
3. **Inventory** -> Stock Multi-sucursal -> POS
4. **Sales/Precios** -> POS -> E-commerce

---

## 7. RIESGOS Y MITIGACIONES

| Riesgo | Probabilidad | Impacto | Mitigacion |
|--------|--------------|---------|------------|
| Core no completo a tiempo | Alta | Critico | Priorizar gaps bloqueantes |
| Integracion PAC compleja | Media | Alto | Iniciar con sandbox temprano |
| PWA offline bugs | Media | Alto | Tests exhaustivos de sync |
| Pasarelas de pago | Media | Alto | Usar SDK oficiales |
| Performance reportes | Media | Medio | Vistas materializadas desde inicio |

---

## 8. EQUIPO SUGERIDO

| Rol | Cantidad | Responsabilidades |
|-----|----------|-------------------|
| Tech Lead | 1 | Arquitectura, code review |
| Backend Sr | 2 | Servicios core, integraciones |
| Backend Jr | 1 | Servicios auxiliares, tests |
| Frontend Sr | 2 | POS, Backoffice, E-commerce |
| Frontend Jr | 1 | Componentes, estilos |
| QA | 1 | Testing E2E, integracion |
| DevOps | 0.5 | CI/CD, infraestructura |

**Velocidad estimada:** 25-30 SP/semana con equipo completo

---

**Estado:** ROADMAP COMPLETO
**Sprints totales:** 20
**Duracion estimada:** 20 semanas (5 meses)
