feat: repositorios, servicios, UI completa con rutas, Capacitor Android sync

This commit is contained in:
mono
2026-10-24 21:11:50 -05:00
parent 0c7cf651ce
commit df3838c2f3
36 changed files with 4224 additions and 402 deletions

View File

@@ -0,0 +1,31 @@
import { db } from '@toldo/data';
import type { Ajuste, MovimientoInventario } from '@toldo/core';
import { validateAjusteMotivo } from '@toldo/core';
export class AjustesService {
async crearAjuste(ajuste: Ajuste) {
validateAjusteMotivo(ajuste.motivo);
return db.transaction('rw', db.ajustes, db.movimientosInventario, async () => {
await db.ajustes.add(ajuste);
await db.movimientosInventario.add({
id: crypto.randomUUID(),
fecha: ajuste.fecha,
tipo: 'AJUSTE',
productoId: ajuste.productoId,
cantidad: ajuste.diferencia,
motivo: ajuste.motivo,
referenciaId: ajuste.id,
createdAt: new Date()
});
return ajuste.id;
});
}
async getAjustesDelDia(fecha: Date): Promise<Ajuste[]> {
const start = new Date(fecha);
start.setHours(0, 0, 0, 0);
const end = new Date(fecha);
end.setHours(23, 59, 59, 999);
return db.ajustes.where('fecha').between(start, end).toArray();
}
}