new ep uso and new ep in costo

This commit is contained in:
2026-02-25 13:01:34 -06:00
6 changed files with 42 additions and 5 deletions
+6
View File
@@ -19,6 +19,12 @@ export class MesaController {
return this.mesaService.findAllActivo();
}
@UseGuards(JwtAuthGuard)
@Get('uso')
async findActiveMesas() {
return this.mesaService.findActiveMesas();
}
@UseGuards(JwtAuthGuard)
@Patch(':id')
async updateActivo(
+23
View File
@@ -119,4 +119,27 @@ export class MesaService {
activo: nuevoActivo,
};
}
findActiveMesas() {
return this.mesaRepository
.createQueryBuilder('mesa')
.select([
'mesa.id_mesa AS id_mesa',
`
EXISTS (
SELECT 1
FROM bitacora_mesa bm
WHERE bm.id_mesa = mesa.id_mesa
AND TIMESTAMPDIFF(
SECOND,
NOW(),
DATE_ADD(bm.tiempo_entrada, INTERVAL bm.tiempo_asignado MINUTE)
) > 0
) AS ocupado
`,
])
.where('mesa.activo = 1')
.orderBy('mesa.id_mesa', 'ASC')
.getRawMany();
}
}