305 lines
10 KiB
Markdown
305 lines
10 KiB
Markdown
# EPICA: EPIC-MMD-006 - Cotizaciones
|
|
|
|
## Metadata
|
|
|
|
| Campo | Valor |
|
|
|-------|-------|
|
|
| **ID** | EPIC-MMD-006 |
|
|
| **Nombre** | Cotizaciones |
|
|
| **Modulo** | cotizaciones |
|
|
| **Fase** | Fase 1 - MVP |
|
|
| **Prioridad** | P1 (Alta) |
|
|
| **Estado** | Backlog |
|
|
| **Story Points** | 26 |
|
|
| **Sprint(s)** | Sprint 5-6 |
|
|
|
|
---
|
|
|
|
## Descripcion
|
|
|
|
Modulo de generacion y gestion de cotizaciones para servicios de reparacion. Permite crear cotizaciones basadas en diagnosticos, con desglose de mano de obra, refacciones, y tiempos estimados. Incluye flujo de aprobacion por parte del cliente y conversion a orden de servicio.
|
|
|
|
---
|
|
|
|
## Objetivo de Negocio
|
|
|
|
- Profesionalizar presentacion de presupuestos
|
|
- Reducir tiempo de cotizacion de 30min a 5min
|
|
- Aumentar tasa de aprobacion con cotizaciones claras
|
|
- Registro de cotizaciones para seguimiento comercial
|
|
- Base para facturacion posterior
|
|
|
|
---
|
|
|
|
## Historias de Usuario
|
|
|
|
| ID | Historia | Prioridad | SP | Estado |
|
|
|----|----------|-----------|-----|--------|
|
|
| US-MMD006-001 | Como recepcionista, quiero crear cotizacion desde diagnostico para presentar al cliente | P0 | 5 | Backlog |
|
|
| US-MMD006-002 | Como recepcionista, quiero agregar servicios con precio de catalogo para cotizar rapidamente | P0 | 3 | Backlog |
|
|
| US-MMD006-003 | Como recepcionista, quiero agregar refacciones con costo y margen para incluir en cotizacion | P0 | 5 | Backlog |
|
|
| US-MMD006-004 | Como recepcionista, quiero aplicar descuento a cotizacion para negociar con cliente | P1 | 3 | Backlog |
|
|
| US-MMD006-005 | Como recepcionista, quiero generar PDF de cotizacion profesional para enviar al cliente | P0 | 5 | Backlog |
|
|
| US-MMD006-006 | Como cliente, quiero aprobar/rechazar cotizacion para autorizar trabajos | P0 | 3 | Backlog |
|
|
| US-MMD006-007 | Como recepcionista, quiero convertir cotizacion aprobada en orden de servicio | P0 | 2 | Backlog |
|
|
|
|
**Total Story Points:** 26 SP
|
|
|
|
---
|
|
|
|
## Flujo de Cotizacion
|
|
|
|
```
|
|
┌─────────────────┐
|
|
│ DIAGNOSTICO │ ← Origen de la cotizacion
|
|
└────────┬────────┘
|
|
│
|
|
▼
|
|
┌─────────────────┐
|
|
│ BORRADOR │ ← Se agregan servicios y refacciones
|
|
└────────┬────────┘
|
|
│
|
|
▼
|
|
┌─────────────────┐
|
|
│ ENVIADA │ ← Se envia al cliente (PDF/WhatsApp)
|
|
└────────┬────────┘
|
|
│
|
|
┌────┴────┐
|
|
▼ ▼
|
|
┌───────┐ ┌───────────┐
|
|
│APROBADA│ │ RECHAZADA │
|
|
└───┬───┘ └───────────┘
|
|
│
|
|
▼
|
|
┌─────────────────┐
|
|
│ ORDEN SERVICIO │ ← Conversion automatica
|
|
└─────────────────┘
|
|
```
|
|
|
|
**Estados adicionales:**
|
|
- `VENCIDA` - Cotizacion paso su vigencia sin respuesta
|
|
- `MODIFICADA` - Cliente solicito cambios
|
|
|
|
---
|
|
|
|
## Criterios de Aceptacion de la Epica
|
|
|
|
**Funcionales:**
|
|
- [ ] Crear cotizacion desde diagnostico o desde cero
|
|
- [ ] Agregar servicios del catalogo con precio
|
|
- [ ] Agregar refacciones con costo y margen
|
|
- [ ] Aplicar descuento global o por linea
|
|
- [ ] Calcular subtotal, IVA, total automaticamente
|
|
- [ ] Generar PDF con formato profesional
|
|
- [ ] Enviar por email/WhatsApp
|
|
- [ ] Registro de aprobacion/rechazo
|
|
- [ ] Convertir a orden de servicio
|
|
|
|
**No Funcionales:**
|
|
- [ ] Generacion de PDF < 3 segundos
|
|
- [ ] Cotizacion vigente por 15 dias (configurable)
|
|
|
|
**Tecnicos:**
|
|
- [ ] Integracion con modulo Diagnosticos
|
|
- [ ] Integracion con modulo Ordenes
|
|
- [ ] Integracion con modulo Inventario (precios)
|
|
- [ ] Template de PDF configurable
|
|
|
|
---
|
|
|
|
## Estructura de Cotizacion
|
|
|
|
```typescript
|
|
interface Quote {
|
|
id: string;
|
|
folio: string; // COT-2025-0001
|
|
vehicle_id: string; // Vehiculo a cotizar
|
|
client_id: string; // Cliente
|
|
diagnostic_id?: string; // Diagnostico origen (opcional)
|
|
|
|
// Items
|
|
services: QuoteService[]; // Servicios
|
|
parts: QuotePart[]; // Refacciones
|
|
|
|
// Totales
|
|
subtotal_services: number;
|
|
subtotal_parts: number;
|
|
discount: number;
|
|
discount_type: 'percent' | 'amount';
|
|
subtotal: number;
|
|
iva: number;
|
|
total: number;
|
|
|
|
// Metadata
|
|
validity_days: number; // Dias de vigencia
|
|
expires_at: Date;
|
|
status: QuoteStatus;
|
|
notes: string;
|
|
created_at: Date;
|
|
approved_at?: Date;
|
|
approved_by?: string; // Nombre de quien aprueba
|
|
}
|
|
|
|
interface QuoteService {
|
|
service_id: string;
|
|
description: string;
|
|
quantity: number;
|
|
unit: string;
|
|
unit_price: number;
|
|
discount?: number;
|
|
total: number;
|
|
}
|
|
|
|
interface QuotePart {
|
|
part_id: string;
|
|
description: string;
|
|
quantity: number;
|
|
unit: string;
|
|
cost: number; // Costo interno
|
|
price: number; // Precio al cliente
|
|
margin_percent: number; // Margen aplicado
|
|
total: number;
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## Dependencias
|
|
|
|
**Esta epica depende de:**
|
|
| Epica/Modulo | Estado | Bloqueante |
|
|
|--------------|--------|------------|
|
|
| EPIC-MMD-001 Fundamentos | Backlog | Si |
|
|
| EPIC-MMD-003 Diagnosticos | Backlog | No |
|
|
| EPIC-MMD-004 Inventario | Backlog | Si |
|
|
| EPIC-MMD-005 Vehiculos | Backlog | Si |
|
|
|
|
**Esta epica bloquea:**
|
|
| Epica/Modulo | Razon |
|
|
|--------------|-------|
|
|
| EPIC-MME-007 Facturacion | Base para facturar |
|
|
|
|
---
|
|
|
|
## Desglose Tecnico
|
|
|
|
**Database:**
|
|
- [ ] Schema: `service_management` (compartido)
|
|
- [ ] Tablas: 4 (quotes, quote_services, quote_parts, quote_log)
|
|
- [ ] Funciones: 2 (calcular_totales, generar_folio)
|
|
|
|
**Backend:**
|
|
- [ ] Modulo: `quotes`
|
|
- [ ] Entities: 3 (Quote, QuoteService, QuotePart)
|
|
- [ ] Endpoints: 12+
|
|
- [ ] Tests: 20+
|
|
|
|
**Frontend:**
|
|
- [ ] Paginas: 3 (QuotesList, QuoteDetail, QuoteForm)
|
|
- [ ] Componentes: 8+ (QuoteLineItem, TotalsCard, PDFPreview, etc.)
|
|
- [ ] Stores: 1 (quotesStore)
|
|
|
|
---
|
|
|
|
## Endpoints API
|
|
|
|
| Metodo | Endpoint | Descripcion |
|
|
|--------|----------|-------------|
|
|
| GET | /api/quotes | Listar cotizaciones |
|
|
| POST | /api/quotes | Crear cotizacion |
|
|
| GET | /api/quotes/:id | Detalle cotizacion |
|
|
| PATCH | /api/quotes/:id | Actualizar cotizacion |
|
|
| POST | /api/quotes/:id/services | Agregar servicio |
|
|
| POST | /api/quotes/:id/parts | Agregar refaccion |
|
|
| POST | /api/quotes/:id/send | Enviar al cliente |
|
|
| POST | /api/quotes/:id/approve | Aprobar |
|
|
| POST | /api/quotes/:id/reject | Rechazar |
|
|
| POST | /api/quotes/:id/convert | Convertir a orden |
|
|
| GET | /api/quotes/:id/pdf | Generar PDF |
|
|
|
|
---
|
|
|
|
## Template PDF Cotizacion
|
|
|
|
```
|
|
┌─────────────────────────────────────────────────┐
|
|
│ [LOGO] TALLER MECANICO DIESEL │
|
|
│ RFC: XXXX000000XXX │
|
|
│ Direccion, Tel, Email │
|
|
├─────────────────────────────────────────────────┤
|
|
│ COTIZACION: COT-2025-0001 │
|
|
│ Fecha: 06/12/2025 Vigencia: 21/12/2025 │
|
|
├─────────────────────────────────────────────────┤
|
|
│ CLIENTE: Transportes del Norte SA │
|
|
│ VEHICULO: Kenworth T680 2020 - ABC-123 │
|
|
│ MOTOR: Cummins ISX15 (serie: XXXXX) │
|
|
├─────────────────────────────────────────────────┤
|
|
│ SERVICIOS │
|
|
│ ───────────────────────────────────────────── │
|
|
│ 1. Diagnostico computarizado 1 $500.00 │
|
|
│ 2. Reparacion bomba inyeccion 5h $2,250.00 │
|
|
│ │
|
|
│ REFACCIONES │
|
|
│ ───────────────────────────────────────────── │
|
|
│ 1. Kit reparacion bomba 1 $3,500.00 │
|
|
│ 2. Filtro diesel 2 $450.00 │
|
|
│ 3. Aceite motor 15W40 20L $1,800.00 │
|
|
├─────────────────────────────────────────────────┤
|
|
│ Subtotal: $8,500.00 │
|
|
│ IVA 16%: $1,360.00 │
|
|
│ TOTAL: $9,860.00 │
|
|
├─────────────────────────────────────────────────┤
|
|
│ NOTAS: │
|
|
│ - Tiempo estimado: 2 dias habiles │
|
|
│ - Garantia: 30 dias en mano de obra │
|
|
│ - Cotizacion valida por 15 dias │
|
|
├─────────────────────────────────────────────────┤
|
|
│ ☐ APROBADO ☐ RECHAZADO │
|
|
│ │
|
|
│ Firma: ____________________ Fecha: ________ │
|
|
└─────────────────────────────────────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## Riesgos
|
|
|
|
| Riesgo | Probabilidad | Impacto | Mitigacion |
|
|
|--------|--------------|---------|------------|
|
|
| Precios desactualizados | Media | Medio | Sincronizar con catalogo |
|
|
| Cotizaciones sin seguimiento | Alta | Medio | Alertas de vencimiento |
|
|
| PDF mal formateado | Baja | Bajo | Preview antes de enviar |
|
|
|
|
---
|
|
|
|
## Definition of Ready (DoR)
|
|
|
|
- [x] Historias de usuario definidas
|
|
- [x] Flujo de estados claro
|
|
- [x] Estructura de datos definida
|
|
- [ ] Template PDF aprobado
|
|
- [ ] Margenes de refacciones definidos
|
|
|
|
## Definition of Done (DoD)
|
|
|
|
- [ ] CRUD de cotizaciones funcionando
|
|
- [ ] Calculo de totales automatico
|
|
- [ ] Generacion de PDF
|
|
- [ ] Aprobacion/rechazo
|
|
- [ ] Conversion a orden
|
|
- [ ] Tests pasando
|
|
|
|
---
|
|
|
|
## Historial
|
|
|
|
| Fecha | Cambio | Autor |
|
|
|-------|--------|-------|
|
|
| 2025-12-06 | Creacion de epica | Requirements-Analyst |
|
|
|
|
---
|
|
|
|
**Creada por:** Requirements-Analyst
|
|
**Fecha:** 2025-12-06
|
|
**Ultima actualizacion:** 2025-12-06
|