# PLAN DE CORRECCION: Integracion Documentacion-Desarrollo **Proyecto:** MiChangarrito **Fecha:** 2026-01-10 **Fase:** FASE 2 - Planeacion **Estado:** EN PROGRESO **Version:** 1.0.0 --- ## RESUMEN DEL PLAN ### Alcance Total | Metrica | Cantidad | |---------|----------| | Documentos a actualizar | 4 | | Schemas a documentar | 2 | | Tablas a documentar | 20 | | Funciones a documentar | 10 | | Modulos a documentar | 8 | | Endpoints a documentar | ~70 | | Paginas a documentar | 4 | | Integraciones a documentar | 2 | | Epicas a actualizar | 5 | ### Orden de Ejecucion | Orden | Documento | Prioridad | Dependencias | |-------|-----------|-----------|--------------| | 1 | ARQUITECTURA-DATABASE.md | P0 | Ninguna | | 2 | INTEGRACIONES-EXTERNAS.md | P0 | ARQUITECTURA-DATABASE | | 3 | ESPECIFICACION-COMPONENTES.md | P0 | ARQUITECTURA-DATABASE | | 4 | CONTEXT-MAP.yml | P1 | Todos los anteriores | --- ## TAREA 1: Actualizar ARQUITECTURA-DATABASE.md ### T1.1 Agregar Schema billing **Ubicacion en documento:** Despues de Schema messaging (linea ~1066) **Contenido a agregar:** ```markdown ## Schema: billing ### tax_configs Configuracion fiscal por tenant (RFC, CSD, PAC). | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Referencia tenant | | rfc | VARCHAR(13) | RFC del negocio | | razon_social | VARCHAR(200) | Razon social | | regimen_fiscal | VARCHAR(10) | Codigo regimen SAT | | codigo_postal | VARCHAR(5) | CP fiscal | | csd_cer | TEXT | Certificado CSD (base64) | | csd_key | TEXT | Llave privada CSD (encriptada) | | csd_password | TEXT | Password CSD (encriptada) | | pac_provider | VARCHAR(50) | Proveedor PAC | | pac_credentials | JSONB | Credenciales PAC | | is_active | BOOLEAN | Configuracion activa | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ### invoices Facturas CFDI emitidas. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Referencia tenant | | sale_id | UUID FK | Venta relacionada (opcional) | | folio | VARCHAR(20) | Folio interno | | serie | VARCHAR(10) | Serie de factura | | uuid_fiscal | VARCHAR(36) | UUID del SAT | | tipo_comprobante | VARCHAR(1) | I=Ingreso, E=Egreso, T=Traslado | | receptor_rfc | VARCHAR(13) | RFC receptor | | receptor_nombre | VARCHAR(200) | Nombre receptor | | receptor_regimen | VARCHAR(10) | Regimen receptor | | receptor_uso_cfdi | VARCHAR(10) | Uso CFDI (G03, etc) | | subtotal | DECIMAL(12,2) | Subtotal | | total_impuestos | DECIMAL(12,2) | Total impuestos | | total | DECIMAL(12,2) | Total factura | | moneda | VARCHAR(3) | MXN | | tipo_cambio | DECIMAL(10,4) | Tipo de cambio | | forma_pago | VARCHAR(2) | Forma de pago SAT | | metodo_pago | VARCHAR(3) | PUE o PPD | | xml_content | TEXT | XML timbrado | | pdf_url | TEXT | URL del PDF | | status | VARCHAR(20) | draft, stamped, cancelled | | cancelled_at | TIMESTAMPTZ | Fecha cancelacion | | cancellation_reason | VARCHAR(2) | Motivo cancelacion SAT | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ### invoice_items Items de factura. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | invoice_id | UUID FK | Referencia factura | | clave_prod_serv | VARCHAR(8) | Clave SAT producto | | clave_unidad | VARCHAR(3) | Clave SAT unidad | | descripcion | VARCHAR(500) | Descripcion | | cantidad | DECIMAL(10,3) | Cantidad | | valor_unitario | DECIMAL(12,4) | Precio unitario | | importe | DECIMAL(12,2) | Importe | ### invoice_item_taxes Impuestos por item de factura. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | invoice_item_id | UUID FK | Referencia item | | tipo | VARCHAR(10) | traslado o retencion | | impuesto | VARCHAR(3) | 002=IVA, 003=IEPS | | tipo_factor | VARCHAR(10) | Tasa, Cuota, Exento | | tasa_o_cuota | DECIMAL(6,4) | Tasa (0.16 para IVA 16%) | | importe | DECIMAL(12,2) | Importe del impuesto | ### invoice_history Historial de cambios en facturas (auditoria). | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | invoice_id | UUID FK | Referencia factura | | action | VARCHAR(20) | created, stamped, cancelled, sent | | details | JSONB | Detalles del cambio | | performed_by | UUID FK | Usuario que realizo | | created_at | TIMESTAMPTZ | Fecha | ``` ### T1.2 Agregar Schema marketplace **Ubicacion en documento:** Despues de Schema billing **Contenido a agregar:** ```markdown ## Schema: marketplace ### suppliers Proveedores/distribuidores del marketplace B2B. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | name | VARCHAR(200) | Nombre del proveedor | | slug | VARCHAR(100) | Slug unico | | description | TEXT | Descripcion | | logo_url | TEXT | Logo | | contact_phone | VARCHAR(20) | Telefono | | contact_email | VARCHAR(100) | Email | | address | TEXT | Direccion | | city | VARCHAR(50) | Ciudad | | state | VARCHAR(50) | Estado | | zip_codes_served | TEXT[] | CPs atendidos | | min_order_amount | DECIMAL(10,2) | Pedido minimo | | delivery_days | INTEGER | Dias de entrega | | rating | DECIMAL(3,2) | Rating promedio | | total_orders | INTEGER | Total pedidos | | is_verified | BOOLEAN | Verificado | | is_active | BOOLEAN | Activo | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ### supplier_products Catalogo de productos de proveedores. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | supplier_id | UUID FK | Referencia proveedor | | name | VARCHAR(200) | Nombre producto | | description | TEXT | Descripcion | | sku | VARCHAR(50) | SKU proveedor | | barcode | VARCHAR(50) | Codigo de barras | | price | DECIMAL(10,2) | Precio mayoreo | | suggested_retail_price | DECIMAL(10,2) | Precio sugerido venta | | unit | VARCHAR(20) | Unidad | | min_quantity | INTEGER | Cantidad minima | | category | VARCHAR(50) | Categoria | | image_url | TEXT | Imagen | | is_available | BOOLEAN | Disponible | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ### supplier_orders Pedidos a proveedores. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Tenant que ordena | | supplier_id | UUID FK | Proveedor | | order_number | VARCHAR(20) | Numero de orden | | subtotal | DECIMAL(12,2) | Subtotal | | delivery_fee | DECIMAL(10,2) | Costo envio | | total | DECIMAL(12,2) | Total | | status | VARCHAR(20) | pending, confirmed, shipped, delivered, cancelled | | shipping_address | TEXT | Direccion entrega | | estimated_delivery | DATE | Fecha estimada | | delivered_at | TIMESTAMPTZ | Fecha entrega real | | notes | TEXT | Notas | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ### supplier_order_items Items de pedidos a proveedores. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | order_id | UUID FK | Referencia orden | | product_id | UUID FK | Producto proveedor | | product_name | VARCHAR(200) | Nombre (snapshot) | | quantity | INTEGER | Cantidad | | unit_price | DECIMAL(10,2) | Precio unitario | | subtotal | DECIMAL(12,2) | Subtotal | ### supplier_reviews Resenas de proveedores. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Tenant que califica | | supplier_id | UUID FK | Proveedor | | order_id | UUID FK | Orden relacionada | | rating | INTEGER | 1-5 estrellas | | comment | TEXT | Comentario | | created_at | TIMESTAMPTZ | Fecha | ### supplier_favorites Proveedores favoritos por tenant. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Tenant | | supplier_id | UUID FK | Proveedor favorito | | created_at | TIMESTAMPTZ | Fecha | ``` ### T1.3 Agregar Tablas CoDi/SPEI a Schema sales **Ubicacion:** Despues de daily_closures en Schema sales **Contenido:** ```markdown ### virtual_accounts Cuentas CLABE virtuales para recibir SPEI. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Referencia tenant | | clabe | VARCHAR(18) | CLABE virtual | | bank_name | VARCHAR(50) | Banco emisor | | holder_name | VARCHAR(100) | Titular | | provider | VARCHAR(50) | STP, Arcus, etc | | is_active | BOOLEAN | Activa | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ### codi_transactions Transacciones CoDi. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Referencia tenant | | sale_id | UUID FK | Venta relacionada | | reference | VARCHAR(50) | Referencia CoDi | | amount | DECIMAL(10,2) | Monto | | qr_data | TEXT | Datos del QR | | status | VARCHAR(20) | pending, completed, expired, failed | | completed_at | TIMESTAMPTZ | Fecha completado | | expires_at | TIMESTAMPTZ | Fecha expiracion | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ### spei_transactions Transacciones SPEI recibidas. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Referencia tenant | | virtual_account_id | UUID FK | Cuenta CLABE | | sale_id | UUID FK | Venta relacionada | | clave_rastreo | VARCHAR(30) | Clave rastreo SPEI | | sender_clabe | VARCHAR(18) | CLABE origen | | sender_name | VARCHAR(100) | Nombre ordenante | | sender_rfc | VARCHAR(13) | RFC ordenante | | amount | DECIMAL(10,2) | Monto | | concept | VARCHAR(100) | Concepto | | status | VARCHAR(20) | received, processed, returned | | received_at | TIMESTAMPTZ | Fecha recepcion | | created_at | TIMESTAMPTZ | Fecha creacion | ### payment_config Configuracion de pagos CoDi/SPEI por tenant. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Referencia tenant | | codi_enabled | BOOLEAN | CoDi habilitado | | spei_enabled | BOOLEAN | SPEI habilitado | | provider | VARCHAR(50) | Proveedor (STP, Arcus) | | credentials | JSONB | Credenciales encriptadas | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ``` ### T1.4 Agregar Tablas Referrals a Schema subscriptions **Ubicacion:** Despues de tenant_token_balance **Contenido:** ```markdown ### referral_codes Codigos de referido. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Tenant dueno del codigo | | code | VARCHAR(10) | Codigo unico | | discount_percent | INTEGER | % descuento para referido | | reward_months | INTEGER | Meses gratis para referidor | | max_uses | INTEGER | Usos maximos | | current_uses | INTEGER | Usos actuales | | is_active | BOOLEAN | Activo | | expires_at | TIMESTAMPTZ | Fecha expiracion | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ### referrals Registro de referidos. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | referrer_tenant_id | UUID FK | Tenant que refirio | | referred_tenant_id | UUID FK | Tenant referido | | code_id | UUID FK | Codigo usado | | status | VARCHAR(20) | pending, active, expired, rewarded | | referred_at | TIMESTAMPTZ | Fecha de referido | | activated_at | TIMESTAMPTZ | Fecha activacion | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ### referral_rewards Recompensas de referidos. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | referral_id | UUID FK | Referencia referral | | tenant_id | UUID FK | Tenant beneficiario | | reward_type | VARCHAR(20) | free_month, discount | | value | DECIMAL(10,2) | Valor | | status | VARCHAR(20) | pending, applied, expired | | applied_at | TIMESTAMPTZ | Fecha aplicacion | | expires_at | TIMESTAMPTZ | Fecha expiracion | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ``` ### T1.5 Agregar Tablas public adicionales **Ubicacion:** Despues de tenant_configs **Contenido:** ```markdown ### tenant_integration_credentials Credenciales de integraciones por tenant. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Referencia tenant | | integration_type | VARCHAR(20) | whatsapp, llm, stripe, etc | | provider | VARCHAR(50) | meta, openai, openrouter, etc | | credentials | JSONB | Credenciales encriptadas | | is_active | BOOLEAN | Activo | | last_validated_at | TIMESTAMPTZ | Ultima validacion | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ### tenant_whatsapp_numbers Numeros WhatsApp por tenant. | Columna | Tipo | Descripcion | |---------|------|-------------| | id | UUID PK | Identificador | | tenant_id | UUID FK | Referencia tenant | | phone_number | VARCHAR(20) | Numero WhatsApp | | phone_number_id | VARCHAR(50) | ID de Meta | | display_name | VARCHAR(100) | Nombre mostrado | | quality_rating | VARCHAR(20) | green, yellow, red | | is_verified | BOOLEAN | Verificado | | is_primary | BOOLEAN | Numero principal | | created_at | TIMESTAMPTZ | Fecha creacion | | updated_at | TIMESTAMPTZ | Fecha actualizacion | ``` ### T1.6 Agregar Funciones Faltantes **Ubicacion:** Despues de la seccion actual de Funciones **Contenido:** ```markdown ### Funciones de Referidos #### generate_referral_code() Genera codigo unico de referido. #### get_referral_stats(p_tenant_id UUID) Obtiene estadisticas de referidos por tenant. ### Funciones CoDi/SPEI #### generate_codi_reference() Genera referencia unica de CoDi. #### get_codi_spei_summary(p_tenant_id UUID, p_date DATE) Resumen de pagos CoDi/SPEI del dia. ### Funciones de Facturacion #### get_next_invoice_folio(p_tenant_id UUID, p_serie VARCHAR) Obtiene siguiente folio para factura. #### get_invoice_summary(p_tenant_id UUID, p_month INTEGER, p_year INTEGER) Resumen de facturacion por mes. ### Funciones del Marketplace #### marketplace.update_supplier_rating(p_supplier_id UUID) Actualiza rating promedio de proveedor tras nueva resena. #### marketplace.update_supplier_orders_count(p_supplier_id UUID) Actualiza conteo de ordenes del proveedor. #### marketplace.find_suppliers_by_zone(p_zip_code VARCHAR) Busca proveedores que atienden un codigo postal. #### marketplace.get_marketplace_stats() Estadisticas globales del marketplace. ``` ### T1.7 Actualizar Tabla de Schemas **Ubicacion:** Linea 13-26 (tabla inicial) **Cambiar de:** ```markdown | Schema | Proposito | Tablas Principales | |--------|-----------|-------------------| ... (9 schemas) ``` **A:** ```markdown | Schema | Proposito | Tablas Principales | |--------|-----------|-------------------| | `public` | Tenants y configuracion global | tenants, tenant_configs, tenant_integration_credentials | | `auth` | Autenticacion y usuarios | users, sessions, otp_codes | | `catalog` | Productos y categorias | products, categories, product_templates | | `sales` | Ventas, pagos y CoDi/SPEI | sales, sale_items, payments, daily_closures, codi_transactions | | `inventory` | Stock y movimientos | inventory_movements, stock_alerts | | `customers` | Clientes y fiados | customers, fiados, fiado_payments | | `orders` | Pedidos de clientes | orders, order_items | | `subscriptions` | Planes, tokens y referidos | plans, subscriptions, token_usage, referral_codes | | `messaging` | WhatsApp y notificaciones | conversations, messages, notifications | | `billing` | Facturacion electronica SAT | tax_configs, invoices, invoice_items | | `marketplace` | Marketplace B2B proveedores | suppliers, supplier_products, supplier_orders | ``` --- ## TAREA 2: Actualizar INTEGRACIONES-EXTERNAS.md ### T2.1 Agregar Seccion SPEI **Ubicacion:** Despues de seccion CoDi **Contenido:** ```markdown ## 10. SPEI (Transferencias Bancarias) ### 10.1 Proposito - Recibir pagos via transferencia bancaria - CLABE virtual por tenant - Conciliacion automatica ### 10.2 Proveedores Soportados | Proveedor | Caracteristicas | |-----------|-----------------| | STP | CLABE en segundos, webhooks | | Arcus | Integracion con CoDi | | Openpay | CLABE + CoDi integrado | ### 10.3 Flujo 1. Generar CLABE virtual para tenant 2. Cliente realiza transferencia 3. Webhook notifica recepcion 4. Sistema concilia con venta ### 10.4 Configuracion - CLABE: 18 digitos - Banco virtual: Segun proveedor - Webhook: POST /v1/spei/webhook ``` ### T2.2 Agregar Seccion SAT/CFDI **Ubicacion:** Despues de SPEI **Contenido:** ```markdown ## 11. Facturacion Electronica (SAT/CFDI) ### 11.1 Proposito - Emision de facturas CFDI 4.0 - Timbrado fiscal - Cancelacion ante SAT - Almacenamiento de XML ### 11.2 Requisitos - RFC del negocio - Certificado de Sello Digital (CSD) - Cuenta con PAC autorizado ### 11.3 PAC Soportados | PAC | Caracteristicas | |-----|-----------------| | FacturaAPI | API REST sencilla | | Facturapi | Sandbox gratuito | | SW Sapien | Masivo | ### 11.4 Flujo de Timbrado 1. Generar XML pre-timbrado 2. Enviar a PAC 3. Recibir UUID fiscal 4. Almacenar XML timbrado 5. Generar PDF ### 11.5 Configuracion por Tenant ```typescript interface TaxConfig { rfc: string; razonSocial: string; regimenFiscal: string; // Codigo SAT codigoPostal: string; csdCer: string; // Base64 csdKey: string; // Encriptado csdPassword: string; // Encriptado pacProvider: string; pacCredentials: object; } ``` ### 11.6 Tipos de Comprobante | Tipo | Codigo | Uso | |------|--------|-----| | Ingreso | I | Venta | | Egreso | E | Nota de credito | | Traslado | T | Envio de mercancia | ### 11.7 Uso de CFDI Comunes | Codigo | Descripcion | |--------|-------------| | G01 | Adquisicion de mercancias | | G03 | Gastos en general | | P01 | Por definir | ``` ### T2.3 Actualizar Seccion LLM **Agregar a proveedores:** ```markdown ### Proveedores Adicionales #### Azure OpenAI ```typescript { provider: 'azure_openai', baseUrl: 'https://{resource}.openai.azure.com', model: 'gpt-4', apiVersion: '2024-02-15-preview' } ``` ### Multi-tenant LLM Credentials Cada tenant puede configurar sus propias credenciales LLM en `tenant_integration_credentials`. ``` --- ## TAREA 3: Actualizar ESPECIFICACION-COMPONENTES.md ### T3.1 Agregar Modulos Backend Faltantes **Ubicacion:** Despues de tabla de Modulos **Contenido:** ```markdown | CategoriesModule | Categorias de productos | `/categories/*` | | PaymentsModule | Metodos de pago | `/payment-methods/*` | | BillingModule | Stripe y facturacion | `/billing/*` | | IntegrationsModule | Credenciales integraciones | `/integrations/*` | | ReferralsModule | Sistema de referidos | `/referrals/*` | | CodiSpeiModule | Pagos CoDi y SPEI | `/codi/*`, `/spei/*` | | WidgetsModule | Datos para widgets | `/widget/*` | | MarketplaceModule | Marketplace B2B | `/marketplace/*` | | InvoicesModule | Facturacion CFDI | `/invoices/*` | ``` ### T3.2 Agregar Endpoints Detallados **(Ver ANALISIS-DETALLADO para lista completa de ~70 endpoints)** ### T3.3 Agregar Paginas Frontend Faltantes **Actualizar tabla de Paginas:** ```markdown | Ruta | Pagina | Descripcion | |------|--------|-------------| | `/dashboard` | Dashboard | Resumen y estadisticas | | `/products` | Products | Catalogo de productos | | `/orders` | Orders | Gestion de pedidos | | `/customers` | Customers | Lista de clientes | | `/fiado` | Fiado | Gestion de credito | | `/inventory` | Inventory | Control de stock | | `/invoices` | Invoices | Facturacion CFDI | | `/marketplace` | Marketplace | Compras a proveedores | | `/referrals` | Referrals | Programa de referidos | | `/settings` | Settings | Configuracion | | `/login` | Login | Autenticacion | | `/register` | Register | Registro de negocio | ``` ### T3.4 Actualizar Versiones ```markdown | Componente | Puerto | Framework | Estado | |------------|--------|-----------|--------| | Frontend Web | 3140 | React 19.2.0 + Vite 7.2.4 | Implementado | | Backend API | 3141 | NestJS 10.x | Implementado | | MCP Server | stdio | MCP SDK | Implementado | | WhatsApp Service | 3143 | NestJS 10.x | Implementado | | Mobile App | - | React Native + Expo | Implementado | ``` ### T3.5 Remover UsersModule Obsoleto Eliminar referencia a UsersModule (merged en AuthModule). --- ## TAREA 4: Actualizar CONTEXT-MAP.yml ### T4.1 Actualizar Estados de Epicas **Cambiar de Pendiente a Completado:** ```yaml MCH-023-referidos: estado: completado implementacion: backend: ReferralsModule frontend: Referrals.tsx database: referral_codes, referrals, referral_rewards MCH-024-codi-spei: estado: completado implementacion: backend: CodiSpeiModule frontend: ClabeDisplay.tsx, CodiQR.tsx database: codi_transactions, spei_transactions, virtual_accounts MCH-025-facturacion: estado: completado implementacion: backend: InvoicesModule frontend: Invoices.tsx database: billing.* MCH-027-sat: estado: completado implementacion: backend: InvoicesModule (timbrado) database: tax_configs, invoice_history MCH-028-marketplace: estado: completado implementacion: backend: MarketplaceModule frontend: Marketplace.tsx database: marketplace.* ``` --- ## RESUMEN DE CAMBIOS POR ARCHIVO ### ARQUITECTURA-DATABASE.md | Seccion | Lineas Aprox | Accion | |---------|--------------|--------| | Tabla schemas | 13-26 | Actualizar (11 schemas) | | Schema public | 29-123 | Agregar 2 tablas | | Schema sales | 340-519 | Agregar 4 tablas CoDi/SPEI | | Schema subscriptions | 789-953 | Agregar 3 tablas referrals | | Schema billing | (nuevo) | Agregar completo (5 tablas) | | Schema marketplace | (nuevo) | Agregar completo (6 tablas) | | Funciones | 1069-1139 | Agregar 10 funciones | | Orden ejecucion | 1249-1262 | Agregar archivos 13-16 | **Lineas a agregar:** ~400 ### INTEGRACIONES-EXTERNAS.md | Seccion | Accion | |---------|--------| | Seccion 10: SPEI | Agregar nueva | | Seccion 11: SAT/CFDI | Agregar nueva | | Seccion 3: LLM | Actualizar proveedores | **Lineas a agregar:** ~150 ### ESPECIFICACION-COMPONENTES.md | Seccion | Accion | |---------|--------| | Tabla modulos | Agregar 9 modulos | | Endpoints por modulo | Agregar ~70 endpoints | | Tabla paginas | Agregar 5 paginas | | Versiones | Actualizar React, Vite, Router | | UsersModule | Eliminar | **Lineas a agregar:** ~200 ### CONTEXT-MAP.yml | Seccion | Accion | |---------|--------| | Epicas 23-28 | Actualizar estados | | Detalles implementacion | Agregar referencias | **Lineas a modificar:** ~30 --- ## RIESGOS Y MITIGACIONES | Riesgo | Probabilidad | Impacto | Mitigacion | |--------|--------------|---------|------------| | Inconsistencia entre documentos | Media | Alto | Validar referencias cruzadas | | Informacion incompleta del codigo | Baja | Medio | Verificar contra archivos SQL | | Perdida de contenido existente | Baja | Alto | Backup antes de editar | | Referencias rotas | Media | Medio | Validar links despues de cambios | --- ## ORDEN DE EJECUCION DETALLADO 1. **Backup** de todos los documentos 2. **ARQUITECTURA-DATABASE.md** - Es la base para otros 3. **Validar** que los schemas coincidan con SQL 4. **INTEGRACIONES-EXTERNAS.md** - Depende de BD 5. **ESPECIFICACION-COMPONENTES.md** - Depende de BD e integraciones 6. **CONTEXT-MAP.yml** - Depende de todos 7. **Validacion final** de coherencia --- **Ultima actualizacion:** 2026-01-10 **Version:** 1.0.0