From 990023525018f5e2de4defe0ef13a0e9f6590e85 Mon Sep 17 00:00:00 2001 From: mono Date: Sun, 25 Oct 2026 18:40:00 -0500 Subject: [PATCH] fix: corregir ventas y mejorar catalogos --- .../src/__tests__/critical-flow.test.ts | 15 +++ apps/toldo-app/src/plugins/vuetify.ts | 1 + apps/toldo-app/src/views/Inventario.vue | 12 +- apps/toldo-app/src/views/Ventas.vue | 19 ++- docs/PRUEBAS-MANUALES.md | 19 +++ docs/inventario-prueba.csv | 111 ++++++++++++++++++ .../.openspec.yaml | 2 + .../fix-sale-transaction-catalog-ux/design.md | 23 ++++ .../proposal.md | 30 +++++ .../specs/catalog-large-list-ux/spec.md | 21 ++++ .../specs/sale-transaction-integrity/spec.md | 16 +++ .../fix-sale-transaction-catalog-ux/tasks.md | 12 ++ packages/services/src/ventas/VentasService.ts | 2 +- 13 files changed, 274 insertions(+), 9 deletions(-) create mode 100644 docs/PRUEBAS-MANUALES.md create mode 100644 docs/inventario-prueba.csv create mode 100644 openspec/changes/fix-sale-transaction-catalog-ux/.openspec.yaml create mode 100644 openspec/changes/fix-sale-transaction-catalog-ux/design.md create mode 100644 openspec/changes/fix-sale-transaction-catalog-ux/proposal.md create mode 100644 openspec/changes/fix-sale-transaction-catalog-ux/specs/catalog-large-list-ux/spec.md create mode 100644 openspec/changes/fix-sale-transaction-catalog-ux/specs/sale-transaction-integrity/spec.md create mode 100644 openspec/changes/fix-sale-transaction-catalog-ux/tasks.md diff --git a/apps/toldo-app/src/__tests__/critical-flow.test.ts b/apps/toldo-app/src/__tests__/critical-flow.test.ts index add27db..256cf87 100644 --- a/apps/toldo-app/src/__tests__/critical-flow.test.ts +++ b/apps/toldo-app/src/__tests__/critical-flow.test.ts @@ -1,7 +1,22 @@ import { describe, expect, it } from 'vitest'; import { ExportImportService } from '@toldo/services'; +import { db } from '@toldo/data'; +import { JornadaService } from '@toldo/services'; describe('contratos de operación y respaldo', () => { + it('persiste una venta y su movimiento de inventario dentro de la misma transacción', async () => { + await db.delete(); + await db.open(); + await db.productos.add({ id: 'product-sale', productorId: 'producer-sale', nombrePresentacion: 'Producto de prueba', precioUnitario: 1000, activo: true, createdAt: new Date() } as any); + await db.movimientosInventario.add({ id: 'stock-sale', fecha: new Date(), tipo: 'INGRESO_INICIAL', productoId: 'product-sale', cantidad: 3, createdAt: new Date() } as any); + const jornadaService = new JornadaService(); + const jornadaId = await jornadaService.abrirJornada(['Prueba'], 0); + const ventaId = crypto.randomUUID(); + await jornadaService.registrarVentaEnJornada(jornadaId, { id: ventaId, fecha: new Date(), subtotal: 1000, total: 1000, createdAt: new Date() } as any, [{ id: crypto.randomUUID(), ventaId, productoId: 'product-sale', cantidad: 1, precioUnitario: 1000, subtotal: 1000, formaPago: 'EFECTIVO' } as any]); + expect(await db.ventas.get(ventaId)).toBeTruthy(); + expect((await db.movimientosInventario.toArray()).filter((movimiento) => movimiento.referenciaId === ventaId)).toHaveLength(1); + }); + it('expone la versión actual en las exportaciones', () => { const result = new ExportImportService().exportAll({ productores: [], productos: [], movimientosInventario: [], ventas: [], ventaLineas: [], gastos: [], ajustes: [], cuadres: [] }); expect(result.appVersion).toBe('0.0.2'); diff --git a/apps/toldo-app/src/plugins/vuetify.ts b/apps/toldo-app/src/plugins/vuetify.ts index 3bff534..31bb9f1 100644 --- a/apps/toldo-app/src/plugins/vuetify.ts +++ b/apps/toldo-app/src/plugins/vuetify.ts @@ -1,4 +1,5 @@ import 'vuetify/styles' +import '@mdi/font/css/materialdesignicons.css' import { createVuetify } from 'vuetify' import * as components from 'vuetify/components' import * as directives from 'vuetify/directives' diff --git a/apps/toldo-app/src/views/Inventario.vue b/apps/toldo-app/src/views/Inventario.vue index 757f863..7d36538 100644 --- a/apps/toldo-app/src/views/Inventario.vue +++ b/apps/toldo-app/src/views/Inventario.vue @@ -20,8 +20,9 @@ Agregar + - + @@ -35,8 +36,9 @@ Agregar Producto + - + @@ -72,7 +74,7 @@