diff --git a/docs/06_Secuencia/venta/01_gestionar_facturas.png b/docs/06_Secuencia/venta/01_gestionar_facturas.png new file mode 100644 index 0000000..4a853fb --- /dev/null +++ b/docs/06_Secuencia/venta/01_gestionar_facturas.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53729f64e2e5d7697b9713461d2db301ac68a0e1513ea0880f72120ec91f5993 +size 95308 diff --git a/docs/06_Secuencia/venta/02_crear_factura_venta.png b/docs/06_Secuencia/venta/02_crear_factura_venta.png new file mode 100644 index 0000000..15e0161 --- /dev/null +++ b/docs/06_Secuencia/venta/02_crear_factura_venta.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1e24814939089e58f9415d5457a41f0a29da7ccca43130a9b3902e66ab28858 +size 224966 diff --git a/docs/06_Secuencia/venta/03_listar_facturas.png b/docs/06_Secuencia/venta/03_listar_facturas.png new file mode 100644 index 0000000..b8ae37f --- /dev/null +++ b/docs/06_Secuencia/venta/03_listar_facturas.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf21d98e249f65087640968265597c4a0032859061ecc6399406a007d68c681a +size 97584 diff --git a/docs/06_Secuencia/venta/04_busqueda_filtro_facturas.png b/docs/06_Secuencia/venta/04_busqueda_filtro_facturas.png new file mode 100644 index 0000000..0546dd8 --- /dev/null +++ b/docs/06_Secuencia/venta/04_busqueda_filtro_facturas.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b17f06d91d4d6b4c3cfc9ab3974fcb8cfc549a2a2c573258a883037ae032f90a +size 149001 diff --git a/docs/06_Secuencia/venta/05_modificar_factura.png b/docs/06_Secuencia/venta/05_modificar_factura.png new file mode 100644 index 0000000..ce02430 --- /dev/null +++ b/docs/06_Secuencia/venta/05_modificar_factura.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f3411d06cdd9e4eed690f04c97f20a13dcc103198e94c69e6a5b30fc06b0ed0 +size 201405 diff --git a/docs/06_Secuencia/venta/06_cancelar_factura.png b/docs/06_Secuencia/venta/06_cancelar_factura.png new file mode 100644 index 0000000..91d3fe6 --- /dev/null +++ b/docs/06_Secuencia/venta/06_cancelar_factura.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c9f999025ddda4500cfac3b908a6265e8a4eca13109d6beb012ceb33068073f6 +size 154714 diff --git a/docs/06_Secuencia/venta/07_crear_nota_credito.png b/docs/06_Secuencia/venta/07_crear_nota_credito.png new file mode 100644 index 0000000..4e0ad87 --- /dev/null +++ b/docs/06_Secuencia/venta/07_crear_nota_credito.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ecc542c9cfa0ab8a7b9dea3857d4df5ef604bca58b6f88a91d74e98f61ca88e4 +size 72858 diff --git a/docs/06_Secuencia/venta/08_crear_nota_debito.png b/docs/06_Secuencia/venta/08_crear_nota_debito.png new file mode 100644 index 0000000..ee32ff3 --- /dev/null +++ b/docs/06_Secuencia/venta/08_crear_nota_debito.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:26e00a34ec0df8a0446dfee8d5ca5a1de61eb3229bee7b2761755a5cc2c66b9e +size 84778 diff --git a/docs/06_Secuencia/venta/10_validar_stock_disponible.png b/docs/06_Secuencia/venta/10_validar_stock_disponible.png new file mode 100644 index 0000000..845751f --- /dev/null +++ b/docs/06_Secuencia/venta/10_validar_stock_disponible.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c94887d55131f4695d51838bd790700fbf588840a807f7e82ae644b5e2826e02 +size 96392 diff --git a/docs/06_Secuencia/venta/11_calcular_totales_impuestos.png b/docs/06_Secuencia/venta/11_calcular_totales_impuestos.png new file mode 100644 index 0000000..3cdb18b --- /dev/null +++ b/docs/06_Secuencia/venta/11_calcular_totales_impuestos.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04fb358b80f12bd83531f282e8377498adcb616a61f3663198038f451f9d0b27 +size 51199 diff --git a/docs/06_Secuencia/venta/12_generar_comprobante.png b/docs/06_Secuencia/venta/12_generar_comprobante.png new file mode 100644 index 0000000..9fd9e6b --- /dev/null +++ b/docs/06_Secuencia/venta/12_generar_comprobante.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12fca5623d3e3b7b8d66cfcdbe0a3a17a8c26fe3a30f072b39cb158000a9b40c +size 95741 diff --git a/docs/06_Secuencia/venta/13_aplicar_descuento.png b/docs/06_Secuencia/venta/13_aplicar_descuento.png new file mode 100644 index 0000000..f753f49 --- /dev/null +++ b/docs/06_Secuencia/venta/13_aplicar_descuento.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a1ad5fb1e5e8583b687501bca3cef48183c37f4ac01ec4be741a71d0267c21a1 +size 77640 diff --git a/docs/06_Secuencia/venta/14_generar_alerta_stock_bajo.png b/docs/06_Secuencia/venta/14_generar_alerta_stock_bajo.png new file mode 100644 index 0000000..cfea1c5 --- /dev/null +++ b/docs/06_Secuencia/venta/14_generar_alerta_stock_bajo.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d2d564f02a3f71ef7b47ef05b72ca7f6ea6d67a647c9d309c613fb901f081af +size 53393 diff --git a/docs/06_Secuencia/venta/15_enviar_email_cliente.png b/docs/06_Secuencia/venta/15_enviar_email_cliente.png new file mode 100644 index 0000000..55b4204 --- /dev/null +++ b/docs/06_Secuencia/venta/15_enviar_email_cliente.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f54b4017901f895d14a3f8379b9c0ecdf163c3961e28263fc294b44c094925d +size 129348 diff --git a/docs/06_Secuencia/venta/16_registrar_pago.png b/docs/06_Secuencia/venta/16_registrar_pago.png new file mode 100644 index 0000000..3933b70 --- /dev/null +++ b/docs/06_Secuencia/venta/16_registrar_pago.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01b9cda0b11009e37b03ac2fce1f677452cd243c05d4030d575f926bfbd3fb2e +size 163671 diff --git a/docs/06_Secuencia/venta/17_registrar_pago_factura_existente.png b/docs/06_Secuencia/venta/17_registrar_pago_factura_existente.png new file mode 100644 index 0000000..a9f5b4f --- /dev/null +++ b/docs/06_Secuencia/venta/17_registrar_pago_factura_existente.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a653034c6232d5a98037d6587f5085ff2ffdc081ca81f4a78115cef0ec6b258 +size 111362 diff --git a/docs/06_Secuencia/venta/plantuml/01_Gestionar_Facturas.org b/docs/06_Secuencia/venta/plantuml/01_Gestionar_Facturas.org new file mode 100644 index 0000000..21e1696 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/01_Gestionar_Facturas.org @@ -0,0 +1,60 @@ +#+TITLE: CU-01: Gestionar Facturas — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-01: Gestionar Facturas +- **Boundary UI / Wireframe**: Wireframe 01: Pantalla Principal 'Gestión de Facturas' +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Factura]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../01_gestionar_facturas.png +@startuml +title "CU-01: Gestionar Facturas - Diagrama de Secuencia Unificado" +autonumber + +actor Empleado as "Empleado \n(Usuario)" +boundary UI as "UI_GestionFacturas \n(Wireframe 01)" +control Ctrl as "GestorFacturacionController" +entity Factura as "Factura \n(Entidad)" +participant RepoFactura as "RepositorioFactura \n(IRepositorio[Factura])" +database DB as "MySQL \n(Base de Datos)" + +Empleado -> UI: Accede al módulo de Gestión de Facturación +activate UI +UI -> Ctrl: solicitarMenuGeneral(usuarioID) +activate Ctrl + +Ctrl -> Ctrl: verificarPermisosUsuario(usuarioID) + +alt Usuario autorizado con permisos [Flujo Principal] + ref over Ctrl, RepoFactura, DB : CU-03: Listar Facturas + + Ctrl --> UI: despliegaMenuYListado(facturasDTO) + UI --> Empleado: Muestra pantalla principal con tabla de facturas y opciones (Crear, Filtrar, Cobrar, Cancelar, Modificar) + +else Usuario sin permisos suficientes [Excepción E1] + Ctrl --> UI: mostrarErrorAcceso("Acceso denegado: El usuario no posee rol de facturación") + UI --> Empleado: Muestra mensaje de restricción de seguridad +end + +deactivate Ctrl +deactivate UI + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Actor | Empleado | Usuario autenticado | + | Boundary | UI_GestionFacturas | Dashboard Principal (W-01) | + | Control | GestorFacturacionController | Controlador de módulo | + | Entity | Factura | Entidad de Dominio | + | Repository | RepositorioFactura | Implementación IRepositorio[Factura] | + | Database | MySQL | BD Relacional MySQL | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../01_gestionar_facturas.png]] diff --git a/docs/06_Secuencia/venta/plantuml/02_Crear_Factura_Venta.org b/docs/06_Secuencia/venta/plantuml/02_Crear_Factura_Venta.org new file mode 100644 index 0000000..4862994 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/02_Crear_Factura_Venta.org @@ -0,0 +1,121 @@ +#+TITLE: CU-02: Crear Factura de Venta — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-02: Crear Factura de Venta +- **Boundary UI / Wireframe**: Wireframe 02: Formulario 'Crear Factura de Venta' & Wireframe 07: 'Comprobante de Venta' +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Factura]`, `IRepositorio[Producto]`, `IRepositorio[AsientoContable]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../02_crear_factura_venta.png +@startuml +title "CU-02: Crear Factura de Venta - Diagrama de Secuencia Unificado" +autonumber + +actor Empleado as "Empleado \n(Usuario)" +boundary UI as "UI_CrearFacturaVenta \n(Wireframe 02)" +control Ctrl as "CrearFacturaController" +entity Factura as "Factura \n(Entidad)" +participant RepoFactura as "RepositorioFactura \n(IRepositorio[Factura])" +participant RepoProducto as "RepositorioProducto \n(IRepositorio[Producto])" +participant RepoAsiento as "RepositorioAsientoContable \n(IRepositorio[AsientoContable])" +database DB as "MySQL \n(Base de Datos)" +boundary UIComprobante as "UI_ComprobanteVenta \n(Wireframe 07)" + +Empleado -> UI: Selecciona cliente, ingresa ítems con cantidades y presiona "Registrar Venta" +activate UI +UI -> Ctrl: registrarVenta(datosCliente, listaItems, usuarioID) +activate Ctrl + +ref over Ctrl, RepoProducto, DB : CU-10: Validar Stock Disponible + +alt Stock suficiente para todos los productos [Flujo Principal] + ref over Ctrl, Factura : CU-11: Calcular Totales e Impuestos + + Ctrl -> DB: START TRANSACTION + activate DB + + Ctrl -> Factura: NuevaFactura(datosCliente, listaItems, totales) + activate Factura + Factura --> Ctrl: entidadFactura + deactivate Factura + + Ctrl -> RepoFactura: Crear(entidadFactura, usuarioID) + activate RepoFactura + RepoFactura -> DB: INSERT INTO factura (cliente_id, fecha, subtotal, iva, total, estado, usuario_id) VALUES (%cliente_id%, NOW(), %subtotal%, %iva%, %total%, 'EMITIDA', %usuario_id%) + + alt Inserción exitosa en MySQL + DB --> RepoFactura: MySQL ExecResult (LastInsertId: 1042) + deactivate DB + RepoFactura --> Ctrl: nil (error = nil) + deactivate RepoFactura + + Ctrl -> RepoProducto: Actualizar(&productoActual, inputDescuentoStock, usuarioID) + activate RepoProducto + RepoProducto -> DB: UPDATE producto SET stock_actual = stock_actual - %qty% WHERE id = %producto_id% + activate DB + DB --> RepoProducto: MySQL ExecResult (RowsAffected: 1) + deactivate DB + RepoProducto --> Ctrl: nil + deactivate RepoProducto + + Ctrl -> RepoAsiento: Crear(asientoEntidad, usuarioID) + activate RepoAsiento + RepoAsiento -> DB: INSERT INTO asiento_contable (factura_id, fecha, debe, haber, usuario_id) VALUES (1042, NOW(), %total%, %total%, %usuario_id%) + activate DB + DB --> RepoAsiento: MySQL ExecResult (LastInsertId: 501) + deactivate DB + RepoAsiento --> Ctrl: nil + deactivate RepoAsiento + + Ctrl -> DB: COMMIT + deactivate DB + + ref over Ctrl, UIComprobante : CU-12: Generar Comprobante + + Ctrl --> UI: ventaRegistradaExitosamente(facturaID) + UI -> UIComprobante: redirigirAComprobante(facturaID) + activate UIComprobante + UIComprobante --> Empleado: Muestra Comprobante de Venta renderizado (Wireframe 07) + deactivate UIComprobante + + else Error de almacenamiento / MySQL Error [Excepción E2] + activate DB + activate RepoFactura + DB --> RepoFactura: MySQLError 1062 / Deadlock / Timeout + deactivate DB + RepoFactura --> Ctrl: ErrBaseDeDatos + deactivate RepoFactura + + Ctrl -> DB: ROLLBACK + deactivate DB + Ctrl --> UI: mostrarErrorBaseDatos("Error crítico: No se pudo registrar la factura en MySQL") + UI --> Empleado: Muestra mensaje de falla de persistencia + end + +else Stock insuficiente en productos [Excepción E1] + Ctrl --> UI: mostrarAlertaStockInsuficiente("Stock insuficiente para uno o más ítems") + UI --> Empleado: Muestra advertencia con lista de productos faltantes +end + +deactivate Ctrl +deactivate UI + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Actor | Empleado | Usuario operador de ventas | + | Boundary | UI_CrearFacturaVenta / UI_ComprobanteVenta | Formulario (W-02) y Comprobante (W-07) | + | Control | CrearFacturaController | Coordinador de emisión | + | Entity | Factura | Entidad de dominio | + | Repository | RepositorioFactura / RepositorioProducto / RepositorioAsientoContable | Implementaciones IRepositorio[T] | + | Database | MySQL | Engine MySQL con ACID Transactions | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../02_crear_factura_venta.png]] diff --git a/docs/06_Secuencia/venta/plantuml/03_Listar_Facturas.org b/docs/06_Secuencia/venta/plantuml/03_Listar_Facturas.org new file mode 100644 index 0000000..1bcefd2 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/03_Listar_Facturas.org @@ -0,0 +1,70 @@ +#+TITLE: CU-03: Listar Facturas — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-03: Listar Facturas +- **Boundary UI / Wireframe**: Wireframe 01: Pantalla Principal 'Gestión de Facturas' +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Factura]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../03_listar_facturas.png +@startuml +title "CU-03: Listar Facturas - Diagrama de Secuencia Unificado" +autonumber + +boundary UI as "UI_GestionFacturas \n(Wireframe 01)" +control Ctrl as "GestorFacturacionController" +entity Factura as "Factura \n(Entidad)" +participant RepoFactura as "RepositorioFactura \n(IRepositorio[Factura])" +database DB as "MySQL \n(Base de Datos)" + +UI -> Ctrl: recuperarRegistrosFacturas() +activate UI +activate Ctrl + +Ctrl -> RepoFactura: ObtenerTodos() +activate RepoFactura +RepoFactura -> DB: SELECT f.id, f.fecha, c.razon_social, f.total, f.estado FROM factura f JOIN cliente c ON f.cliente_id = c.id ORDER BY f.fecha DESC +activate DB + +alt Existen facturas registradas en MySQL [Flujo Principal] + DB --> RepoFactura: MySQL Rowset ([]Factura) + deactivate DB + RepoFactura --> Ctrl: ([]Factura, nil) + deactivate RepoFactura + + Ctrl --> UI: presentarListado(facturasDTO) + UI --> UI: Renderiza grilla (# N° Factura, Cliente, Fecha, Total, Estado) + +else No existen facturas registradas [Excepción E1] + activate DB + activate RepoFactura + DB --> RepoFactura: MySQL Empty Set + deactivate DB + RepoFactura --> Ctrl: ([]Factura{}, nil) + deactivate RepoFactura + + Ctrl --> UI: presentarListadoVacio("No hay facturas registradas en el sistema") + UI --> UI: Muestra grilla vacía con mensaje informativo +end + +deactivate Ctrl +deactivate UI + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Boundary | UI_GestionFacturas | Dashboard Principal (W-01) | + | Control | GestorFacturacionController | Controlador del listado | + | Entity | Factura | Entidad de Dominio | + | Repository | RepositorioFactura | Implementación IRepositorio[Factura] | + | Database | MySQL | Engine MySQL | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../03_listar_facturas.png]] diff --git a/docs/06_Secuencia/venta/plantuml/04_Busqueda_Filtro_Facturas.org b/docs/06_Secuencia/venta/plantuml/04_Busqueda_Filtro_Facturas.org new file mode 100644 index 0000000..b3b0846 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/04_Busqueda_Filtro_Facturas.org @@ -0,0 +1,88 @@ +#+TITLE: CU-04: Búsqueda y Filtro de Facturas — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-04: Búsqueda y Filtro de Facturas +- **Boundary UI / Wireframe**: Wireframe 01: Pantalla Principal 'Gestión de Facturas' +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Factura]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../04_busqueda_filtro_facturas.png +@startuml +title "CU-04: Búsqueda y Filtro de Facturas - Diagrama de Secuencia Unificado" +autonumber + +actor Empleado as "Empleado \n(Usuario)" +boundary UI as "UI_GestionFacturas \n(Wireframe 01)" +control Ctrl as "GestorFacturacionController" +entity Factura as "Factura \n(Entidad)" +participant RepoFactura as "RepositorioFactura \n(IRepositorio[Factura])" +database DB as "MySQL \n(Base de Datos)" + +Empleado -> UI: Ingresa criterios de filtro (Rango Fechas, Estado, Cliente) y clic "Buscar" +activate UI +UI -> Ctrl: filtrarFacturas(criteriosFiltro) +activate Ctrl + +alt Criterios de búsqueda válidos [Flujo Principal] + Ctrl -> RepoFactura: ObtenerTodos() + activate RepoFactura + RepoFactura -> DB: SELECT f.id, f.fecha, c.razon_social, f.total, f.estado FROM factura f JOIN cliente c ON f.cliente_id = c.id WHERE f.fecha BETWEEN %desde% AND %hasta% AND f.estado = %estado% ORDER BY f.fecha DESC + activate DB + + alt Se encuentran coincidencias en MySQL + DB --> RepoFactura: MySQL Rowset (facturasFiltradas) + deactivate DB + RepoFactura --> Ctrl: (facturasFiltradas, nil) + deactivate RepoFactura + + Ctrl --> UI: mostrarResultadosFiltrados(facturasFiltradas) + UI --> Empleado: Actualiza grilla con las facturas coincidentes + + else Ninguna factura coincide con los filtros [Excepción E1] + activate DB + activate RepoFactura + DB --> RepoFactura: MySQL Empty Set + deactivate DB + RepoFactura --> Ctrl: ([]Factura{}, nil) + deactivate RepoFactura + + Ctrl --> UI: mostrarAlertaSinCoincidencias("No se encontraron facturas para los criterios ingresados") + UI --> Empleado: Muestra aviso de búsqueda sin resultados + end + +else Búsqueda sin parámetros definidos [Camino Alternativo A1] + Ctrl -> RepoFactura: ObtenerTodos() + activate RepoFactura + RepoFactura -> DB: SELECT f.id, f.fecha, c.razon_social, f.total, f.estado FROM factura f JOIN cliente c ON f.cliente_id = c.id ORDER BY f.fecha DESC LIMIT 100 + activate DB + DB --> RepoFactura: MySQL Rowset (ultimas100Facturas) + deactivate DB + RepoFactura --> Ctrl: (ultimas100Facturas, nil) + deactivate RepoFactura + + Ctrl --> UI: mostrarUltimosRegistros(ultimas100Facturas) + UI --> Empleado: Refresca grilla con las últimas 100 facturas registradas +end + +deactivate Ctrl +deactivate UI + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Actor | Empleado | Usuario operador | + | Boundary | UI_GestionFacturas | Dashboard Principal (W-01) | + | Control | GestorFacturacionController | Controlador de búsqueda | + | Entity | Factura | Entidad de Dominio | + | Repository | RepositorioFactura | Implementación IRepositorio[Factura] | + | Database | MySQL | BD Relacional MySQL | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../04_busqueda_filtro_facturas.png]] diff --git a/docs/06_Secuencia/venta/plantuml/05_Modificar_Factura.org b/docs/06_Secuencia/venta/plantuml/05_Modificar_Factura.org new file mode 100644 index 0000000..dea41c8 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/05_Modificar_Factura.org @@ -0,0 +1,107 @@ +#+TITLE: CU-05: Modificar Factura — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-05: Modificar Factura +- **Boundary UI / Wireframe**: Wireframe 06: Formulario 'Modificar Factura' +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Factura]`, `IRepositorio[Producto]`, `IRepositorio[NotaCredito]`, `IRepositorio[NotaDebito]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../05_modificar_factura.png +@startuml +title "CU-05: Modificar Factura - Diagrama de Secuencia Unificado" +autonumber + +actor Empleado as "Empleado \n(Usuario)" +boundary UI as "UI_ModificarFactura \n(Wireframe 06)" +control Ctrl as "ModificarFacturaController" +entity Factura as "Factura \n(Entidad)" +participant RepoFactura as "RepositorioFactura \n(IRepositorio[Factura])" +participant RepoProducto as "RepositorioProducto \n(IRepositorio[Producto])" +participant RepoNC as "RepositorioNotaCredito \n(IRepositorio[NotaCredito])" +participant RepoND as "RepositorioNotaDebito \n(IRepositorio[NotaDebito])" +database DB as "MySQL \n(Base de Datos)" + +Empleado -> UI: Modifica ítems/cantidades y presiona "Guardar Cambios" +activate UI +UI -> Ctrl: solicitarModificacionFactura(facturaID, nuevosItems, usuarioID) +activate Ctrl + +Ctrl -> RepoFactura: ObtenerPorID(facturaID) +activate RepoFactura +RepoFactura -> DB: SELECT id, total, estado FROM factura WHERE id = %facturaID% +activate DB +DB --> RepoFactura: MySQL Rowset (facturaOriginal) +deactivate DB +RepoFactura --> Ctrl: (*Factura, nil) +deactivate RepoFactura + +alt Factura en estado activo (EMITIDA / PENDIENTE) + Ctrl -> Factura: calcularDiferenciaMonto(nuevosItems) + activate Factura + Factura --> Ctrl: montoDiferencia, tipoAjuste ("MENOR_VALOR" / "MAYOR_VALOR" / "IGUAL") + deactivate Factura + + alt Disminución de saldo [Camino Alt A1: Emisión Nota de Crédito] + ref over Ctrl, RepoNC, DB : CU-07: Crear Nota de Crédito + + Ctrl -> RepoFactura: Actualizar(&facturaExistente, inputModificado, usuarioID) + activate RepoFactura + RepoFactura -> DB: UPDATE factura SET total = %nuevoTotal%, estado = 'MODIFICADA' WHERE id = %facturaID% + activate DB + DB --> RepoFactura: MySQL ExecResult (RowsAffected: 1) + deactivate DB + RepoFactura --> Ctrl: nil + deactivate RepoFactura + + Ctrl --> UI: confirmacionModificacionOK("Factura modificada. Se emitió Nota de Crédito por la diferencia") + + else Incremento de saldo [Camino Alt A2: Emisión Nota de Débito] + ref over Ctrl, RepoProducto, DB : CU-10: Validar Stock Disponible + + alt Stock suficiente para ítems agregados + ref over Ctrl, RepoND, DB : CU-08: Crear Nota de Débito + + Ctrl -> RepoFactura: Actualizar(&facturaExistente, inputModificado, usuarioID) + activate RepoFactura + RepoFactura -> DB: UPDATE factura SET total = %nuevoTotal%, estado = 'MODIFICADA' WHERE id = %facturaID% + activate DB + DB --> RepoFactura: MySQL ExecResult (RowsAffected: 1) + deactivate DB + RepoFactura --> Ctrl: nil + deactivate RepoFactura + + Ctrl --> UI: confirmacionModificacionOK("Factura modificada. Se emitió Nota de Débito por la diferencia") + + else Stock insuficiente [Excepción E1] + Ctrl --> UI: mostrarErrorStock("No se pueden agregar ítems por stock insuficiente") + end + + end + +else Factura cancelada o cerrada [Excepción E2] + Ctrl --> UI: mostrarErrorEstado("La factura se encuentra cancelada o cerrada y no permite modificaciones") + UI --> Empleado: Muestra alerta indicando imposibilidad de edición +end + +deactivate Ctrl +deactivate UI + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Actor | Empleado | Usuario operador | + | Boundary | UI_ModificarFactura | Formulario W-06 | + | Control | ModificarFacturaController | Controlador de ajuste | + | Entity | Factura | Entidad de Dominio | + | Repository | RepositorioFactura / RepoNC / RepoND | Implementaciones IRepositorio[T] | + | Database | MySQL | Engine MySQL | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../05_modificar_factura.png]] diff --git a/docs/06_Secuencia/venta/plantuml/06_Cancelar_Factura.org b/docs/06_Secuencia/venta/plantuml/06_Cancelar_Factura.org new file mode 100644 index 0000000..6dfa7cf --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/06_Cancelar_Factura.org @@ -0,0 +1,92 @@ +#+TITLE: CU-06: Cancelar Factura — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-06: Cancelar Factura +- **Boundary UI / Wireframe**: Wireframe 05: Modal 'Cancelar Factura' +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Factura]`, `IRepositorio[Producto]`, `IRepositorio[NotaCredito]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../06_cancelar_factura.png +@startuml +title "CU-06: Cancelar Factura - Diagrama de Secuencia Unificado" +autonumber + +actor Empleado as "Empleado \n(Usuario)" +boundary UI as "UI_CancelarFacturaModal \n(Wireframe 05)" +control Ctrl as "CancelarFacturaController" +entity Factura as "Factura \n(Entidad)" +participant RepoFactura as "RepositorioFactura \n(IRepositorio[Factura])" +participant RepoProducto as "RepositorioProducto \n(IRepositorio[Producto])" +database DB as "MySQL \n(Base de Datos)" + +Empleado -> UI: Ingresa motivo de cancelación y presiona "Confirmar Anulación" +activate UI +UI -> Ctrl: solicitarCancelarFactura(facturaID, motivo, usuarioID) +activate Ctrl + +Ctrl -> RepoFactura: ObtenerPorID(facturaID) +activate RepoFactura +RepoFactura -> DB: SELECT id, total, estado, cliente_id FROM factura WHERE id = %facturaID% +activate DB +DB --> RepoFactura: MySQL Rowset (facturaDTO) +deactivate DB +RepoFactura --> Ctrl: (*Factura, nil) +deactivate RepoFactura + +alt Factura activa (EMITIDA / PENDIENTE) [Flujo Principal] + Ctrl -> DB: START TRANSACTION + activate DB + + ref over Ctrl, DB : CU-07: Crear Nota de Crédito + + Ctrl -> RepoFactura: Actualizar(&facturaExistente, inputAnulacion, usuarioID) + activate RepoFactura + RepoFactura -> DB: UPDATE factura SET estado = 'CANCELADA', motivo_anulacion = %motivo% WHERE id = %facturaID% + activate DB + DB --> RepoFactura: MySQL ExecResult (RowsAffected: 1) + deactivate DB + RepoFactura --> Ctrl: nil + deactivate RepoFactura + + Ctrl -> RepoProducto: Actualizar(&producto, inputDevolucionStock, usuarioID) + activate RepoProducto + RepoProducto -> DB: UPDATE producto SET stock_actual = stock_actual + %qty% WHERE id = %producto_id% + activate DB + DB --> RepoProducto: MySQL ExecResult (RowsAffected: 1) + deactivate DB + RepoProducto --> Ctrl: nil + deactivate RepoProducto + + Ctrl -> DB: COMMIT + deactivate DB + + Ctrl --> UI: facturaCanceladaExitosamente("Factura anulada. Se reincorporó el stock y se emitió la Nota de Crédito") + UI --> Empleado: Muestra confirmación de cancelación y refresca vista + +else Factura ya cancelada previamente [Excepción E1] + Ctrl --> UI: mostrarErrorAnulacion("La factura ya se encuentra en estado CANCELADA") + UI --> Empleado: Muestra advertencia indicando imposibilidad de re-anulación +end + +deactivate Ctrl +deactivate UI + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Actor | Empleado | Usuario operador | + | Boundary | UI_CancelarFacturaModal | Modal Wireframe 05 | + | Control | CancelarFacturaController | Coordinador de anulación | + | Entity | Factura | Entidad de Dominio | + | Repository | RepositorioFactura / RepositorioProducto | Implementaciones IRepositorio[T] | + | Database | MySQL | Engine MySQL con Transacciones | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../06_cancelar_factura.png]] diff --git a/docs/06_Secuencia/venta/plantuml/07_Crear_Nota_Credito.org b/docs/06_Secuencia/venta/plantuml/07_Crear_Nota_Credito.org new file mode 100644 index 0000000..b48833c --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/07_Crear_Nota_Credito.org @@ -0,0 +1,55 @@ +#+TITLE: CU-07: Crear Nota de Crédito — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-07: Crear Nota de Crédito +- **Boundary UI / Wireframe**: Integrado desde `UI_CancelarFacturaModal` / `UI_ModificarFactura` +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[NotaCredito]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../07_crear_nota_credito.png +@startuml +title "CU-07: Crear Nota de Crédito - Diagrama de Secuencia Unificado" +autonumber + +control Ctrl as "CancelarFacturaController" +entity NotaCredito as "NotaCredito \n(Entidad)" +participant RepoNC as "RepositorioNotaCredito \n(IRepositorio[NotaCredito])" +database DB as "MySQL \n(Base de Datos)" + +Ctrl -> NotaCredito: NuevaNotaCredito(facturaID, importeNC, motivo) +activate Ctrl +activate NotaCredito +NotaCredito --> Ctrl: entidadNC +deactivate NotaCredito + +Ctrl -> RepoNC: Crear(entidadNC, usuarioID) +activate RepoNC +RepoNC -> DB: INSERT INTO nota_credito (factura_id, fecha, importe, motivo, usuario_id) VALUES (%facturaID%, NOW(), %importeNC%, %motivo%, %usuarioID%) +activate DB +DB --> RepoNC: MySQL ExecResult (LastInsertId: 801) +deactivate DB +RepoNC --> Ctrl: nil (error = nil) +deactivate RepoNC + +ref over Ctrl : CU-12: Generar Comprobante + +Ctrl --> Ctrl: notaCreditoEmitidaOK(id: 801) +deactivate Ctrl + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Control | CancelarFacturaController | Invocador del servicio NC | + | Entity | NotaCredito | Entidad de Dominio | + | Repository | RepositorioNotaCredito | Implementación IRepositorio[NotaCredito] | + | Database | MySQL | BD Relacional MySQL | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../07_crear_nota_credito.png]] diff --git a/docs/06_Secuencia/venta/plantuml/08_Crear_Nota_Debito.org b/docs/06_Secuencia/venta/plantuml/08_Crear_Nota_Debito.org new file mode 100644 index 0000000..3ad9272 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/08_Crear_Nota_Debito.org @@ -0,0 +1,61 @@ +#+TITLE: CU-08: Crear Nota de Débito — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-08: Crear Nota de Débito +- **Boundary UI / Wireframe**: Formulario 'Modificar Factura' (Wireframe 06) +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[NotaDebito]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../08_crear_nota_debito.png +@startuml +title "CU-08: Crear Nota de Débito - Diagrama de Secuencia Unificado" +autonumber + +control Ctrl as "ModificarFacturaController" +entity NotaDebito as "NotaDebito \n(Entidad)" +participant RepoND as "RepositorioNotaDebito \n(IRepositorio[NotaDebito])" +database DB as "MySQL \n(Base de Datos)" + +Ctrl -> NotaDebito: NuevaNotaDebito(facturaID, importeND, concepto) +activate Ctrl +activate NotaDebito +NotaDebito --> Ctrl: entidadND +deactivate NotaDebito + +alt Importes y datos válidos [Flujo Principal] + Ctrl -> RepoND: Crear(entidadND, usuarioID) + activate RepoND + RepoND -> DB: INSERT INTO nota_debito (factura_id, fecha, importe, concepto, usuario_id) VALUES (%facturaID%, NOW(), %importeND%, %concepto%, %usuarioID%) + activate DB + DB --> RepoND: MySQL ExecResult (LastInsertId: 901) + deactivate DB + RepoND --> Ctrl: nil + deactivate RepoND + + ref over Ctrl : CU-12: Generar Comprobante + + Ctrl --> Ctrl: notaDebitoEmitidaOK(id: 901) + +else Importe inválido / Menor o igual a cero [Excepción E1] + Ctrl --> Ctrl: errorNotaDebito("El importe de la Nota de Débito debe ser mayor a cero") +end + +deactivate Ctrl + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Control | ModificarFacturaController | Invocador | + | Entity | NotaDebito | Entidad de Dominio | + | Repository | RepositorioNotaDebito | Implementación IRepositorio[NotaDebito] | + | Database | MySQL | Engine MySQL | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../08_crear_nota_debito.png]] diff --git a/docs/06_Secuencia/venta/plantuml/10_Validar_Stock_Disponible.org b/docs/06_Secuencia/venta/plantuml/10_Validar_Stock_Disponible.org new file mode 100644 index 0000000..393ccd4 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/10_Validar_Stock_Disponible.org @@ -0,0 +1,76 @@ +#+TITLE: CU-10: Validar Stock Disponible — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-10: Validar Stock Disponible +- **Boundary UI / Wireframe**: Formulario 'Crear Factura de Venta' (Wireframe 02) / 'Modificar Factura' (Wireframe 06) +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Producto]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../10_validar_stock_disponible.png +@startuml +title "CU-10: Validar Stock Disponible - Diagrama de Secuencia Unificado" +autonumber + +control Ctrl as "CrearFacturaController" +entity Producto as "Producto \n(Entidad)" +participant RepoProducto as "RepositorioProducto \n(IRepositorio[Producto])" +database DB as "MySQL \n(Base de Datos)" + +Ctrl -> RepoProducto: ObtenerPorID(productoID) +activate Ctrl +activate RepoProducto +RepoProducto -> DB: SELECT id, nombre, stock_actual, stock_minimo FROM producto WHERE id IN (%ids%) AND activo = 1 +activate DB + +alt Stock suficiente para todos los ítems [Flujo Principal] + DB --> RepoProducto: MySQL Rowset ([]Producto) + deactivate DB + RepoProducto --> Ctrl: ([]Producto, nil) + deactivate RepoProducto + + Ctrl -> Producto: verificarDisponibilidad(cantidadesSolicitadas) + activate Producto + Producto --> Ctrl: disponibilidadOK (true) + deactivate Producto + + opt Stock cercano al punto de pedido + ref over Ctrl, RepoProducto, DB : CU-14: Generar Alerta de Stock Bajo + end + + Ctrl --> Ctrl: validacionStockExitosa() + +else Stock insuficiente en uno o más productos [Excepción E1] + activate RepoProducto + activate DB + DB --> RepoProducto: MySQL Rowset (stock_actual < cantidad_solicitada) + deactivate DB + RepoProducto --> Ctrl: ([]Producto, nil) + deactivate RepoProducto + + Ctrl -> Producto: verificarDisponibilidad(cantidadesSolicitadas) + activate Producto + Producto --> Ctrl: disponibilidadFail (false, itemsFaltantes) + deactivate Producto + + Ctrl --> Ctrl: errorStockInsuficiente(itemsFaltantes) +end + +deactivate Ctrl + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Control | CrearFacturaController | Verificador de inventario | + | Entity | Producto | Entidad de Dominio | + | Repository | RepositorioProducto | Implementación IRepositorio[Producto] | + | Database | MySQL | BD Relacional MySQL | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../10_validar_stock_disponible.png]] diff --git a/docs/06_Secuencia/venta/plantuml/11_Calcular_Totales_Impuestos.org b/docs/06_Secuencia/venta/plantuml/11_Calcular_Totales_Impuestos.org new file mode 100644 index 0000000..df062fe --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/11_Calcular_Totales_Impuestos.org @@ -0,0 +1,51 @@ +#+TITLE: CU-11: Calcular Totales e Impuestos — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-11: Calcular Totales e Impuestos +- **Boundary UI / Wireframe**: Formulario 'Crear Factura de Venta' (Wireframe 02) +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../11_calcular_totales_impuestos.png +@startuml +title "CU-11: Calcular Totales e Impuestos - Diagrama de Secuencia Unificado" +autonumber + +control Ctrl as "CrearFacturaController" +entity Factura as "Factura \n(Entidad)" + +Ctrl -> Factura: calcularSubtotalYTasas(listaItems) +activate Ctrl +activate Factura + +opt Descuento previamente aplicado (CU-13) [Camino Alt A1] + Factura -> Factura: aplicarDescuentoASubtotal(montoDescuento) +end + +alt Configuración impositiva correcta [Flujo Principal] + Factura -> Factura: calcularIVA(21%) + Factura -> Factura: calcularTotalFinal() + Factura --> Ctrl: totalesCalculadosDTO(subtotal, iva, total) + +else Error o tasa impositiva no válida / Nula [Excepción E1] + Factura --> Ctrl: errorCalculoImpositivo("Configuración impositiva inválida o tasa inexistente") + deactivate Factura +end + +deactivate Ctrl + +legend right + |= Patrón BCE |= Componente |= Descripción | + | Control | CrearFacturaController | Coordinador de cálculos | + | Entity | Factura | Lógica impositiva y aritmética de importes | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../11_calcular_totales_impuestos.png]] diff --git a/docs/06_Secuencia/venta/plantuml/12_Generar_Comprobante.org b/docs/06_Secuencia/venta/plantuml/12_Generar_Comprobante.org new file mode 100644 index 0000000..cb7f806 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/12_Generar_Comprobante.org @@ -0,0 +1,62 @@ +#+TITLE: CU-12: Generar Comprobante — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-12: Generar Comprobante +- **Boundary UI / Wireframe**: Wireframe 07: Pantalla 'Comprobante de Venta' +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Factura]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../12_generar_comprobante.png +@startuml +title "CU-12: Generar Comprobante - Diagrama de Secuencia Unificado" +autonumber + +control Ctrl as "ComprobanteController" +participant RepoFactura as "RepositorioFactura \n(IRepositorio[Factura])" +database DB as "MySQL \n(Base de Datos)" +boundary UIComprobante as "UI_ComprobanteVenta \n(Wireframe 07)" + +Ctrl -> RepoFactura: ObtenerPorID(facturaID) +activate Ctrl +activate RepoFactura +RepoFactura -> DB: SELECT f.*, c.razon_social, c.cuit, c.direccion FROM factura f JOIN cliente c ON f.cliente_id = c.id WHERE f.id = %facturaID% +activate DB +DB --> RepoFactura: MySQL Rowset (facturaCompleta) +deactivate DB +RepoFactura --> Ctrl: (*Factura, nil) +deactivate RepoFactura + +alt Renderización HTML/PDF exitosa [Flujo Principal] + Ctrl -> Ctrl: renderizarPlantillaHTML_PDF(facturaCompleta) + Ctrl --> UIComprobante: desplegarComprobante(comprobanteHTML_PDF) + activate UIComprobante + UIComprobante --> UIComprobante: Renderiza vista imprimible y activa botones "Imprimir" / "Descargar PDF" / "Enviar por Email" + deactivate UIComprobante + +else Falla en el motor de renderizado PDF [Excepción E1] + Ctrl -> Ctrl: renderizarPlantillaHTML_PDF(facturaCompleta) + Ctrl --> UIComprobante: errorGeneracionComprobante("Error al renderizar el documento PDF") + activate UIComprobante + UIComprobante --> UIComprobante: Muestra mensaje de error y opción de reintentar + deactivate UIComprobante +end + +deactivate Ctrl + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Boundary | UI_ComprobanteVenta | Pantalla de Comprobante (W-07) | + | Control | ComprobanteController | Renderizador de comprobante | + | Repository | RepositorioFactura | Implementación IRepositorio[Factura] | + | Database | MySQL | Engine MySQL | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../12_generar_comprobante.png]] diff --git a/docs/06_Secuencia/venta/plantuml/13_Aplicar_Descuento.org b/docs/06_Secuencia/venta/plantuml/13_Aplicar_Descuento.org new file mode 100644 index 0000000..72706d5 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/13_Aplicar_Descuento.org @@ -0,0 +1,59 @@ +#+TITLE: CU-13: Aplicar Descuento — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-13: Aplicar Descuento +- **Boundary UI / Wireframe**: Formulario 'Crear Factura de Venta' (Wireframe 02) +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../13_aplicar_descuento.png +@startuml +title "CU-13: Aplicar Descuento - Diagrama de Secuencia Unificado" +autonumber + +actor Empleado as "Empleado \n(Usuario)" +boundary UI as "UI_CrearFacturaVenta \n(Wireframe 02)" +control Ctrl as "CrearFacturaController" +entity Factura as "Factura \n(Entidad)" + +Empleado -> UI: Ingresa porcentaje/monto de descuento y presiona "Aplicar" +activate UI +UI -> Ctrl: aplicarDescuento(porcentajeDescuento, usuarioID) +activate Ctrl + +Ctrl -> Ctrl: verificarTopeAutorizadoUsuario(usuarioID, porcentajeDescuento) + +alt Descuento dentro del límite permitido (<= Tope) [Flujo Principal] + Ctrl -> Factura: registrarDescuento(porcentajeDescuento) + activate Factura + Factura --> Ctrl: descuentoAplicadoOK + deactivate Factura + + Ctrl --> UI: confirmacionDescuento(nuevoSubtotal) + UI --> Empleado: Actualiza subtotal reflejando la bonificación + +else Descuento excede el máximo autorizado [Excepción E1] + Ctrl --> UI: mostrarErrorDescuento("El porcentaje ingresado excede el límite máximo permitido para su rol") + UI --> Empleado: Muestra advertencia indicando necesidad de autorización gerencial +end + +deactivate Ctrl +deactivate UI + +legend right + |= Patrón BCE |= Componente |= Descripción | + | Actor | Empleado | Operador de venta | + | Boundary | UI_CrearFacturaVenta | Formulario Wireframe 02 | + | Control | CrearFacturaController | Validador de descuento | + | Entity | Factura | Entidad de Dominio | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../13_aplicar_descuento.png]] diff --git a/docs/06_Secuencia/venta/plantuml/14_Generar_Alerta_Stock_Bajo.org b/docs/06_Secuencia/venta/plantuml/14_Generar_Alerta_Stock_Bajo.org new file mode 100644 index 0000000..380e61d --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/14_Generar_Alerta_Stock_Bajo.org @@ -0,0 +1,54 @@ +#+TITLE: CU-14: Generar Alerta de Stock Bajo — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-14: Generar Alerta de Stock Bajo +- **Boundary UI / Wireframe**: Formulario 'Crear Factura de Venta' (Wireframe 02) / Dashboard (Wireframe 01) +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Producto]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../14_generar_alerta_stock_bajo.png +@startuml +title "CU-14: Generar Alerta de Stock Bajo - Diagrama de Secuencia Unificado" +autonumber + +control Ctrl as "CrearFacturaController" +entity Producto as "Producto \n(Entidad)" +boundary UI as "UI_CrearFacturaVenta \n(Wireframe 02)" + +Ctrl -> Producto: evaluarUmbralStock() +activate Ctrl +activate Producto + +alt stock_actual <= stock_minimo [Flujo Principal] + Producto --> Ctrl: alertaStockBajo(productoID, stockActual, stockMinimo) + deactivate Producto + + Ctrl --> UI: desplegarBannerAlerta("Atención: El producto " + nombre + " ha alcanzado el nivel crítico de reponedor") + activate UI + UI --> UI: Muestra indicador visual amarillo/rojo en la interfaz + deactivate UI + +else stock_actual > stock_minimo + activate Producto + Producto --> Ctrl: stockNormalOK + deactivate Producto +end + +deactivate Ctrl + +legend right + |= Patrón BCE |= Componente |= Descripción | + | Control | CrearFacturaController | Evaluador de umbral | + | Entity | Producto | Entidad de Dominio con regla de punto de pedido | + | Boundary | UI_CrearFacturaVenta | Notificación en pantalla | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../14_generar_alerta_stock_bajo.png]] diff --git a/docs/06_Secuencia/venta/plantuml/15_Enviar_Email_Cliente.org b/docs/06_Secuencia/venta/plantuml/15_Enviar_Email_Cliente.org new file mode 100644 index 0000000..cf94a89 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/15_Enviar_Email_Cliente.org @@ -0,0 +1,76 @@ +#+TITLE: CU-15: Enviar Email al Cliente — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-15: Enviar Email al Cliente +- **Boundary UI / Wireframe**: Wireframe 07: Pantalla 'Comprobante de Venta' +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Cliente]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../15_enviar_email_cliente.png +@startuml +title "CU-15: Enviar Email al Cliente - Diagrama de Secuencia Unificado" +autonumber + +actor Empleado as "Empleado \n(Usuario)" +boundary UI as "UI_ComprobanteVenta \n(Wireframe 07)" +control Ctrl as "ComprobanteController" +participant RepoCliente as "RepositorioCliente \n(IRepositorio[Cliente])" +database DB as "MySQL \n(Base de Datos)" +actor SrvEmail as "ServicioEmail \n(Servicio Externo)" + +Empleado -> UI: Presiona botón "Enviar por Email" +activate UI +UI -> Ctrl: enviarEmailComprobante(facturaID) +activate Ctrl + +Ctrl -> RepoCliente: ObtenerPorID(clienteID) +activate RepoCliente +RepoCliente -> DB: SELECT email, email_verificado FROM cliente WHERE id = %clienteID% +activate DB +DB --> RepoCliente: MySQL Rowset (email, email_verificado: true) +deactivate DB +RepoCliente --> Ctrl: (*Cliente, nil) +deactivate RepoCliente + +alt Casilla de correo registrada y verificada [Flujo Principal] + Ctrl -> SrvEmail: solicitarDespacho(emailCliente, adjuntoPDF) + activate SrvEmail + + alt Envío exitoso por servidor SMTP + SrvEmail --> Ctrl: despachoExitoso(200 OK) + Ctrl --> UI: confirmacionEnvioEmail("El comprobante fue enviado con éxito a " + emailCliente) + UI --> Empleado: Muestra notificación verde de éxito + + else Falla de conexión con servicio externo SMTP [Excepción E2] + SrvEmail --> Ctrl: errorConexionServicio("503 Service Unavailable / SMTP Timeout") + deactivate SrvEmail + Ctrl --> UI: mostrarErrorEmail("No se pudo conectar con el servidor de correo. Intente más tarde") + UI --> Empleado: Muestra mensaje de fallo de conexión externa + end + +else Casilla de correo no registrada o no verificada [Excepción E1] + Ctrl --> UI: mostrarErrorEmail("El cliente no posee una dirección de correo válida registrada") + UI --> Empleado: Muestra mensaje de advertencia indicando actualizar datos +end + +deactivate Ctrl +deactivate UI + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Actor | Empleado / ServicioEmail | Usuario y servidor SMTP externo | + | Boundary | UI_ComprobanteVenta | Comprobante Wireframe 07 | + | Control | ComprobanteController | Despachador de email | + | Repository | RepositorioCliente | Implementación IRepositorio[Cliente] | + | Database | MySQL | Engine MySQL | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../15_enviar_email_cliente.png]] diff --git a/docs/06_Secuencia/venta/plantuml/16_Registrar_Pago.org b/docs/06_Secuencia/venta/plantuml/16_Registrar_Pago.org new file mode 100644 index 0000000..86b2f67 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/16_Registrar_Pago.org @@ -0,0 +1,95 @@ +#+TITLE: CU-16: Registrar Pago — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-16: Registrar Pago +- **Boundary UI / Wireframe**: Wireframe 04: Modal 'Registrar Pago' +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Pago]`, `IRepositorio[Factura]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../16_registrar_pago.png +@startuml +title "CU-16: Registrar Pago - Diagrama de Secuencia Unificado" +autonumber + +actor Empleado as "Empleado \n(Usuario)" +boundary UI as "UI_RegistrarPagoModal \n(Wireframe 04)" +control Ctrl as "RegistrarPagoController" +entity Pago as "Pago \n(Entidad)" +participant RepoPago as "RepositorioPago \n(IRepositorio[Pago])" +participant RepoFactura as "RepositorioFactura \n(IRepositorio[Factura])" +database DB as "MySQL \n(Base de Datos)" + +Empleado -> UI: Ingresa medio de pago, importe y presiona "Confirmar Pago" +activate UI +UI -> Ctrl: registrarCobro(facturaID, datosPago, usuarioID) +activate Ctrl + +Ctrl -> RepoFactura: ObtenerPorID(facturaID) +activate RepoFactura +RepoFactura -> DB: SELECT id, total, saldo_pendiente FROM factura WHERE id = %facturaID% +activate DB +DB --> RepoFactura: MySQL Rowset (saldo_pendiente) +deactivate DB +RepoFactura --> Ctrl: (*Factura, nil) +deactivate RepoFactura + +alt Monto de pago válido (Monto > 0 y Monto <= Saldo Pendiente) [Flujo Principal] + Ctrl -> DB: START TRANSACTION + activate DB + + Ctrl -> Pago: NuevoPago(facturaID, medioPago, monto) + activate Pago + Pago --> Ctrl: entidadPago + deactivate Pago + + Ctrl -> RepoPago: Crear(entidadPago, usuarioID) + activate RepoPago + RepoPago -> DB: INSERT INTO pago (factura_id, fecha, medio_pago, monto, usuario_id) VALUES (%facturaID%, NOW(), %medioPago%, %monto%, %usuarioID%) + activate DB + DB --> RepoPago: MySQL ExecResult (LastInsertId: 301) + deactivate DB + RepoPago --> Ctrl: nil + deactivate RepoPago + + Ctrl -> RepoFactura: Actualizar(&facturaExistente, inputSaldoActualizado, usuarioID) + activate RepoFactura + RepoFactura -> DB: UPDATE factura SET saldo_pendiente = saldo_pendiente - %monto%, estado = IF(saldo_pendiente - %monto% = 0, 'PAGADA', 'PARCIAL') WHERE id = %facturaID% + activate DB + DB --> RepoFactura: MySQL ExecResult (RowsAffected: 1) + deactivate DB + RepoFactura --> Ctrl: nil + deactivate RepoFactura + + Ctrl -> DB: COMMIT + deactivate DB + + Ctrl --> UI: cobroRegistradoExitosamente("Pago de $" + monto + " registrado correctamente") + UI --> Empleado: Muestra recibo de cobro y actualiza estado de la factura + +else Monto de pago inválido / Inconsistente [Excepción E1] + Ctrl --> UI: mostrarErrorPago("El monto ingresado es inválido o supera el saldo pendiente de la factura") + UI --> Empleado: Muestra advertencia indicando ajustar el importe +end + +deactivate Ctrl +deactivate UI + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Actor | Empleado | Operador de cobranzas | + | Boundary | UI_RegistrarPagoModal | Modal Wireframe 04 | + | Control | RegistrarPagoController | Coordinador de cobranzas | + | Entity | Pago / Factura | Entidades de Dominio | + | Repository | RepositorioPago / RepositorioFactura | Implementaciones IRepositorio[T] | + | Database | MySQL | Engine MySQL con Transacciones | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../16_registrar_pago.png]] diff --git a/docs/06_Secuencia/venta/plantuml/17_Registrar_Pago_Factura_Existente.org b/docs/06_Secuencia/venta/plantuml/17_Registrar_Pago_Factura_Existente.org new file mode 100644 index 0000000..1460ff8 --- /dev/null +++ b/docs/06_Secuencia/venta/plantuml/17_Registrar_Pago_Factura_Existente.org @@ -0,0 +1,69 @@ +#+TITLE: CU-17: Registrar Pago a Factura Existente — Diagrama de Secuencia Unificado +#+AUTHOR: Arquitectura de Software SAP-TFI-2026 +#+DATE: 2026-10-13 +#+OPTIONS: toc:nil num:t + +* Contexto y Mapeo Arquitectónico +- **Caso de Uso**: CU-17: Registrar Pago a Factura Existente +- **Boundary UI / Wireframe**: Wireframe 01: Pantalla Principal 'Gestión de Facturas' & Wireframe 04: 'Registrar Pago' +- **Patrón de Arquitectura**: Clean Architecture / Go Repository Pattern (`IRepositorio[Factura]`) +- **Base de Datos**: MySQL + +* Diagrama de Secuencia UML (PlantUML) + +#+begin_src plantuml :file ../17_registrar_pago_factura_existente.png +@startuml +title "CU-17: Registrar Pago a Factura Existente - Diagrama de Secuencia Unificado" +autonumber + +actor Empleado as "Empleado \n(Usuario)" +boundary UI as "UI_GestionFacturas \n(Wireframe 01)" +boundary UIModal as "UI_RegistrarPagoModal \n(Wireframe 04)" +control Ctrl as "RegistrarPagoController" +participant RepoFactura as "RepositorioFactura \n(IRepositorio[Factura])" +database DB as "MySQL \n(Base de Datos)" + +Empleado -> UI: Selecciona factura de la grilla y presiona "Registrar Pago" +activate UI +UI -> Ctrl: abrirModalPago(facturaID) +activate Ctrl + +Ctrl -> RepoFactura: ObtenerPorID(facturaID) +activate RepoFactura +RepoFactura -> DB: SELECT id, total, saldo_pendiente, estado FROM factura WHERE id = %facturaID% +activate DB +DB --> RepoFactura: MySQL Rowset (facturaDTO) +deactivate DB +RepoFactura --> Ctrl: (*Factura, nil) +deactivate RepoFactura + +alt Factura con saldo pendiente (estado != 'PAGADA') [Flujo Principal] + Ctrl --> UI: desplegarModalPago(facturaDTO) + UI -> UIModal: abrirModal(facturaID, saldoPendiente) + activate UIModal + UIModal --> Empleado: Despliega formulario de cobro indicando el saldo pendiente actualizado + + ref over Empleado, UIModal, Ctrl : CU-16: Registrar Pago + deactivate UIModal + +else Factura ya se encuentra totalmente saldada [Excepción E1] + Ctrl --> UI: mostrarAdvertencia("La factura seleccionada ya se encuentra en estado PAGADA") + UI --> Empleado: Muestra aviso flotante indicando saldo $0.00 +end + +deactivate Ctrl +deactivate UI + +legend right + |= Patrón BCE / Repositorio |= Componente |= Descripción | + | Actor | Empleado | Operador de cobranzas | + | Boundary | UI_GestionFacturas / UI_RegistrarPagoModal | Dashboard W-01 y Modal W-04 | + | Control | RegistrarPagoController | Coordinador de flujo de pago | + | Repository | RepositorioFactura | Implementación IRepositorio[Factura] | + | Database | MySQL | Engine MySQL | +endlegend +@enduml +#+end_src + +#+RESULTS: +[[file:../17_registrar_pago_factura_existente.png]]