diff --git a/src/carrito-motivo/carrito-motivo.service.ts b/src/carrito-motivo/carrito-motivo.service.ts index 787a756..75bceed 100644 --- a/src/carrito-motivo/carrito-motivo.service.ts +++ b/src/carrito-motivo/carrito-motivo.service.ts @@ -6,7 +6,13 @@ import { Injectable, } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; -import { FindManyOptions, FindOptionsWhere, Repository } from 'typeorm'; +import { + Between, + FindManyOptions, + FindOptionsWhere, + MoreThanOrEqual, + Repository, +} from 'typeorm'; import { Carrito } from '../carrito/entity/carrito.entity'; import { CarritoMotivo } from './entity/carrito-motivo.entity'; import { Operador } from '../operador/entity/operador.entity'; @@ -79,6 +85,8 @@ export class CarritoMotivoService { admin: Operador, filtros: { carrito?: string; + fechaFin?: string; + fechaInicio?: string; id_institucion?: string; id_marca?: string; id_modelo?: string; @@ -109,6 +117,17 @@ export class CarritoMotivoService { }; if (filtros.carrito) busquedaCarrito.carrito = filtros.carrito; + if (filtros.fechaInicio) { + if (filtros.fechaFin) + busqueda.fecha_creacion = Between( + new Date(`${filtros.fechaInicio} 00:00`), + new Date(`${filtros.fechaFin} 23:59`), + ); + else + busqueda.fecha_creacion = MoreThanOrEqual( + new Date(`${filtros.fechaInicio} 00:00`), + ); + } if (admin.institucion) busquedaCarrito.modulo = { institucion: admin.institucion }; else if (institucion) busquedaCarrito.modulo = { institucion }; diff --git a/src/carrito-motivo/dto/input/laboratorio-movil.dto.ts b/src/carrito-motivo/dto/input/laboratorio-movil.dto.ts index cf7ff75..69ed274 100644 --- a/src/carrito-motivo/dto/input/laboratorio-movil.dto.ts +++ b/src/carrito-motivo/dto/input/laboratorio-movil.dto.ts @@ -1,4 +1,5 @@ import { + IsDateString, IsNotEmpty, IsNumberString, IsOptional, @@ -11,6 +12,14 @@ export class LaboratorioMovilDto { @IsOptional() carrito?: string; + @IsDateString() + @IsOptional() + fechaFin?: string; + + @IsDateString() + @IsOptional() + fechaInicio?: string; + @IsNumberString() @IsOptional() id_institucion?: string;