Validacion completa de documentacion tecnica contra codigo real: - ENTITIES-CATALOG.md: 35+ -> 38 entities (validado) - SERVICES-CATALOG.md: 30+ -> 18 services (validado) - MODULES-CATALOG.md: 24 -> 17 modulos (validado) - DATABASE-SCHEMA.md: Corregido - TypeORM genera tablas, no hay SQL separado - _INDEX.yml: Metricas actualizadas y marcadas como validadas - MASTER_INVENTORY.yml: Sincronizado con conteos reales Discrepancias corregidas: - La doc anterior incluia objetos planificados como implementados - Schemas 15 -> 1 (public, TypeORM) - Tablas ~65 -> 38 (1:1 con entities) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
272 lines
7.7 KiB
Markdown
272 lines
7.7 KiB
Markdown
---
|
|
id: DEF-MCH-ENTITIES
|
|
type: Definition
|
|
title: "Entities Catalog"
|
|
simco_version: "4.0.1"
|
|
updated_at: 2026-01-17
|
|
validated: true
|
|
---
|
|
|
|
# Entities Catalog - MiChangarrito
|
|
|
|
**Alias:** @MCH_DEF_ENTITIES
|
|
**Version:** 2.0.0
|
|
**Ultima actualizacion:** 2026-01-17
|
|
**Estado:** VALIDADO vs Codigo
|
|
|
|
---
|
|
|
|
## 1. RESUMEN
|
|
|
|
| Metrica | Valor |
|
|
|---------|-------|
|
|
| **Total Entities** | 38 |
|
|
| **Total Modulos con Entities** | 15 |
|
|
| **Modulos sin Entities** | 2 (billing, widgets) |
|
|
|
|
---
|
|
|
|
## 2. ENTITIES POR MODULO
|
|
|
|
### 2.1 Modulo: Auth (2 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Tenant | `tenant.entity.ts` | Tiendas/Changarritos (multi-tenant) |
|
|
| User | `user.entity.ts` | Usuarios del sistema |
|
|
|
|
### 2.2 Modulo: Categories (1 entity)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Category | `category.entity.ts` | Categorias de productos |
|
|
|
|
### 2.3 Modulo: CoDi-SPEI (3 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| CodiTransaction | `codi-transaction.entity.ts` | Transacciones CoDi |
|
|
| SpeiTransaction | `spei-transaction.entity.ts` | Transacciones SPEI |
|
|
| VirtualAccount | `virtual-account.entity.ts` | Cuentas virtuales para recepcion |
|
|
|
|
### 2.4 Modulo: Customers (3 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Customer | `customer.entity.ts` | Clientes del changarrito |
|
|
| Fiado | `fiado.entity.ts` | Creditos/fiados otorgados |
|
|
| FiadoPayment | `fiado-payment.entity.ts` | Pagos de fiados |
|
|
|
|
### 2.5 Modulo: Integrations (2 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| TenantIntegrationCredential | `tenant-integration-credential.entity.ts` | Credenciales por tenant |
|
|
| TenantWhatsappNumber | `tenant-whatsapp-number.entity.ts` | Numeros WhatsApp por tenant |
|
|
|
|
### 2.6 Modulo: Inventory (2 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| InventoryMovement | `inventory-movement.entity.ts` | Movimientos de inventario |
|
|
| StockAlert | `stock-alert.entity.ts` | Alertas de stock bajo |
|
|
|
|
### 2.7 Modulo: Invoices (3 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Invoice | `invoice.entity.ts` | Facturas CFDI |
|
|
| InvoiceItem | `invoice-item.entity.ts` | Items de factura |
|
|
| TaxConfig | `tax-config.entity.ts` | Configuracion fiscal |
|
|
|
|
### 2.8 Modulo: Marketplace (6 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Supplier | `supplier.entity.ts` | Proveedores B2B |
|
|
| SupplierProduct | `supplier-product.entity.ts` | Productos de proveedores |
|
|
| SupplierOrder | `supplier-order.entity.ts` | Ordenes a proveedores |
|
|
| SupplierOrderItem | `supplier-order-item.entity.ts` | Items de orden |
|
|
| SupplierReview | `supplier-review.entity.ts` | Resenas de proveedores |
|
|
| SupplierFavorites | `supplier-favorites.entity.ts` | Proveedores favoritos |
|
|
|
|
### 2.9 Modulo: Messaging (3 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Conversation | `conversation.entity.ts` | Conversaciones (WhatsApp/Chat) |
|
|
| Message | `message.entity.ts` | Mensajes de conversacion |
|
|
| Notification | `notification.entity.ts` | Notificaciones push/in-app |
|
|
|
|
### 2.10 Modulo: Orders (2 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Order | `order.entity.ts` | Pedidos de clientes |
|
|
| OrderItem | `order-item.entity.ts` | Items del pedido |
|
|
|
|
### 2.11 Modulo: Payments (1 entity)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| PaymentMethod | `payment-method.entity.ts` | Metodos de pago configurados |
|
|
|
|
### 2.12 Modulo: Products (1 entity)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Product | `product.entity.ts` | Productos del catalogo |
|
|
|
|
### 2.13 Modulo: Referrals (3 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Referral | `referral.entity.ts` | Referidos registrados |
|
|
| ReferralCode | `referral-code.entity.ts` | Codigos de referido |
|
|
| ReferralReward | `referral-reward.entity.ts` | Recompensas por referidos |
|
|
|
|
### 2.14 Modulo: Sales (2 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Sale | `sale.entity.ts` | Ventas POS |
|
|
| SaleItem | `sale-item.entity.ts` | Items de venta |
|
|
|
|
### 2.15 Modulo: Subscriptions (4 entities)
|
|
|
|
| Entity | Archivo | Descripcion |
|
|
|--------|---------|-------------|
|
|
| Plan | `plan.entity.ts` | Planes de suscripcion |
|
|
| Subscription | `subscription.entity.ts` | Suscripciones activas |
|
|
| TokenBalance | `token-balance.entity.ts` | Balance de tokens IA |
|
|
| TokenUsage | `token-usage.entity.ts` | Uso de tokens IA |
|
|
|
|
---
|
|
|
|
## 3. MODULOS SIN ENTITIES
|
|
|
|
| Modulo | Razon |
|
|
|--------|-------|
|
|
| billing | Logica de facturacion sin entity propia (usa Invoice) |
|
|
| widgets | Componentes UI, sin persistencia |
|
|
|
|
---
|
|
|
|
## 4. RELACIONES PRINCIPALES
|
|
|
|
```yaml
|
|
relaciones:
|
|
Tenant:
|
|
has_many: [User, Product, Sale, Order, Customer, Subscription]
|
|
belongs_to: []
|
|
|
|
User:
|
|
has_many: [Conversation, Notification]
|
|
belongs_to: [Tenant]
|
|
|
|
Product:
|
|
has_many: [SaleItem, OrderItem, InventoryMovement]
|
|
belongs_to: [Tenant, Category]
|
|
|
|
Sale:
|
|
has_many: [SaleItem]
|
|
belongs_to: [Tenant, Customer]
|
|
|
|
Order:
|
|
has_many: [OrderItem]
|
|
belongs_to: [Tenant, Customer]
|
|
|
|
Customer:
|
|
has_many: [Sale, Order, Fiado]
|
|
belongs_to: [Tenant]
|
|
|
|
Fiado:
|
|
has_many: [FiadoPayment]
|
|
belongs_to: [Tenant, Customer]
|
|
|
|
Conversation:
|
|
has_many: [Message]
|
|
belongs_to: [Tenant, User]
|
|
|
|
Subscription:
|
|
has_many: []
|
|
belongs_to: [Tenant, Plan]
|
|
|
|
Supplier:
|
|
has_many: [SupplierProduct, SupplierOrder, SupplierReview]
|
|
belongs_to: []
|
|
```
|
|
|
|
---
|
|
|
|
## 5. UBICACION EN CODIGO
|
|
|
|
```
|
|
backend/src/modules/
|
|
├── auth/entities/
|
|
│ ├── tenant.entity.ts
|
|
│ └── user.entity.ts
|
|
├── categories/entities/
|
|
│ └── category.entity.ts
|
|
├── codi-spei/entities/
|
|
│ ├── codi-transaction.entity.ts
|
|
│ ├── spei-transaction.entity.ts
|
|
│ └── virtual-account.entity.ts
|
|
├── customers/entities/
|
|
│ ├── customer.entity.ts
|
|
│ ├── fiado.entity.ts
|
|
│ └── fiado-payment.entity.ts
|
|
├── integrations/entities/
|
|
│ ├── tenant-integration-credential.entity.ts
|
|
│ └── tenant-whatsapp-number.entity.ts
|
|
├── inventory/entities/
|
|
│ ├── inventory-movement.entity.ts
|
|
│ └── stock-alert.entity.ts
|
|
├── invoices/entities/
|
|
│ ├── invoice.entity.ts
|
|
│ ├── invoice-item.entity.ts
|
|
│ └── tax-config.entity.ts
|
|
├── marketplace/entities/
|
|
│ ├── supplier.entity.ts
|
|
│ ├── supplier-product.entity.ts
|
|
│ ├── supplier-order.entity.ts
|
|
│ ├── supplier-order-item.entity.ts
|
|
│ ├── supplier-review.entity.ts
|
|
│ └── supplier-favorites.entity.ts
|
|
├── messaging/entities/
|
|
│ ├── conversation.entity.ts
|
|
│ ├── message.entity.ts
|
|
│ └── notification.entity.ts
|
|
├── orders/entities/
|
|
│ ├── order.entity.ts
|
|
│ └── order-item.entity.ts
|
|
├── payments/entities/
|
|
│ └── payment-method.entity.ts
|
|
├── products/entities/
|
|
│ └── product.entity.ts
|
|
├── referrals/entities/
|
|
│ ├── referral.entity.ts
|
|
│ ├── referral-code.entity.ts
|
|
│ └── referral-reward.entity.ts
|
|
├── sales/entities/
|
|
│ ├── sale.entity.ts
|
|
│ └── sale-item.entity.ts
|
|
└── subscriptions/entities/
|
|
├── plan.entity.ts
|
|
├── subscription.entity.ts
|
|
├── token-balance.entity.ts
|
|
└── token-usage.entity.ts
|
|
```
|
|
|
|
---
|
|
|
|
## 6. REFERENCIAS
|
|
|
|
- Database Schema: @MCH_DEF_DB
|
|
- Services: @MCH_DEF_SERVICES
|
|
- Backend Inventory: orchestration/inventarios/BACKEND_INVENTORY.yml
|
|
|
|
---
|
|
|
|
*Definicion canonica v2.0.0 - MiChangarrito - VALIDADO*
|