Se modificaron varias cosas en los endpoint y en algunas entities asi como en los dto
This commit is contained in:
@@ -26,11 +26,11 @@ export class CrearServicioDto {
|
||||
@IsEmail()
|
||||
correo: string;
|
||||
|
||||
@IsDate()
|
||||
fechaInicio: Date;
|
||||
@IsDateString()
|
||||
fechaInicio: string; // Cambiado a string antes tenia Date
|
||||
|
||||
@IsDate()
|
||||
fechaFin: Date;
|
||||
@IsDateString()
|
||||
fechaFin: string; // Cambiado a string antes tenia Date
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
|
||||
@@ -12,7 +12,7 @@ export class RegistroValidadoDto {
|
||||
idServicio: number;
|
||||
|
||||
@IsOptional()
|
||||
fechaNacimiento?: Date;
|
||||
fechaNacimiento?: string; // Lo pasamos a string antes date
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
|
||||
@@ -20,17 +20,17 @@ export class UpdateServicioDto {
|
||||
@IsOptional()
|
||||
@IsDateString({}, { message: 'fechaInicio debe ser una fecha válida' })
|
||||
//@Type(() => Date)
|
||||
fechaInicio?: Date;
|
||||
fechaInicio?: string; // Lo pasamos a string antes date
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString({}, { message: 'fechaFin debe ser una fecha válida' })
|
||||
//@Type(() => Date)
|
||||
fechaFin?: Date;
|
||||
fechaFin?: string; // Lo pasamos a string antes date
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString({}, { message: 'fechaNacimiento debe ser una fecha válida' })
|
||||
//@Type(() => Date)
|
||||
fechaNacimiento?: Date;
|
||||
fechaNacimiento?: string; // Lo pasamos a string antes date
|
||||
|
||||
@IsOptional()
|
||||
@IsString({ message: 'direccion debe ser texto' })
|
||||
|
||||
@@ -34,19 +34,19 @@ export class Servicio {
|
||||
direccion?: string;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
fechaInicio: Date;
|
||||
fechaInicio: string; // Cambios a tipo string antes tenia date
|
||||
|
||||
@Column({ type: 'date' })
|
||||
fechaFin: Date;
|
||||
fechaFin: string; // Cambios a tipo string antes tenia date
|
||||
|
||||
@Column({ type: 'date', nullable: true, default: null })
|
||||
fechaLiberacion?: Date;
|
||||
fechaLiberacion?: string; // Cambios a tipo string antes tenia date
|
||||
|
||||
@Column({ type: 'date', nullable: true, default: null })
|
||||
fechaNacimiento?: Date;
|
||||
fechaNacimiento?: string; // Cambios a tipo string antes tenia date
|
||||
|
||||
@Column({ type: 'varchar', length: 60 })
|
||||
carpeta: string;
|
||||
carpeta: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 60 })
|
||||
cartaAceptacion: string;
|
||||
|
||||
@@ -83,10 +83,14 @@ export class ServicioController {
|
||||
return res.download(path);
|
||||
}
|
||||
|
||||
// Corregi el endpoint tenia llamando a otrea funcion
|
||||
@Get('reporte')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
async generarReporte(@Query() query: any, @Res() res: Response) {
|
||||
const path = await this.servicioService.generarGustavoBazPrada(query.year);
|
||||
async generarReporte(
|
||||
@Query('inicio') inicio: string,
|
||||
@Query('fin') fin: string,
|
||||
@Res() res: Response) {
|
||||
const path = await this.servicioService.generarReporte(inicio, fin);
|
||||
return res.download(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,11 @@ import { RegistroValidadoDto } from './dto/registro-validado.dto';
|
||||
import * as fs from 'fs';
|
||||
import { ServiciosAdminDto } from './dto/servicios-admin.dto';
|
||||
import { ServiciosResponsableDto } from './dto/servicios-responsable.dto';
|
||||
import { SendMailDto } from 'src/helpers.services/dto/send-email.dto';
|
||||
import { SendMailDto } from 'src/helpers.services/dto/send-email.dto';
|
||||
const {
|
||||
canceladoAlumno,
|
||||
canceladoResponsable,
|
||||
} = require('./../helpers.services/msjCorreos');
|
||||
|
||||
@Injectable()
|
||||
export class ServicioService {
|
||||
@@ -189,6 +193,7 @@ export class ServicioService {
|
||||
'usuario', // alumno
|
||||
'programa',
|
||||
'programa.usuario', // responsable
|
||||
'status', // Falto agregar la relacion de status
|
||||
],
|
||||
});
|
||||
|
||||
@@ -196,6 +201,11 @@ export class ServicioService {
|
||||
throw new NotFoundException('No existe este Servicio Social.');
|
||||
}
|
||||
|
||||
// Agregamos una validación para el status extra
|
||||
if (!servicio.status) {
|
||||
throw new BadRequestException('El Servicio Social no tiene un estatus válido.');
|
||||
}
|
||||
|
||||
if (servicio.status.idStatus === 10) {
|
||||
throw new BadRequestException('Este Servicio Social ya fue cancelado.');
|
||||
}
|
||||
@@ -422,8 +432,11 @@ export class ServicioService {
|
||||
4,
|
||||
);
|
||||
|
||||
const inicio = moment(`${year}-01-31`).toDate();
|
||||
const fin = moment(`${year + 1}-01-31`).toDate();
|
||||
// Los transformo a string para hacer la consulta
|
||||
//const inicio = moment(`${year}-01-31`).toDate();
|
||||
//const fin = moment(`${year + 1}-01-31`).toDate();
|
||||
const inicio = moment(`${year}-01-31`).format('YYYY-MM-DD');
|
||||
const fin = moment(`${year + 1}-01-31`).format('YYYY-MM-DD');
|
||||
const path: string = `server/uploads/${year}_gustavo_baz_prada.csv`;
|
||||
const data: any[] = [];
|
||||
|
||||
@@ -614,7 +627,7 @@ export class ServicioService {
|
||||
// 🔹 Actualizar el servicio
|
||||
await this.servicioRepo.update(idServicio, {
|
||||
status: { idStatus: 6 },
|
||||
fechaLiberacion: moment().toDate(),
|
||||
fechaLiberacion: moment().format('YYYY-MM-DD'), // lo mismo pasamos a string antes como toDate
|
||||
vistoBuenoAcatlan: vistoBuenoAcatlan ? true : false,
|
||||
});
|
||||
|
||||
@@ -1185,7 +1198,8 @@ export class ServicioService {
|
||||
};
|
||||
}
|
||||
|
||||
async generarReporte(inicio: Date, fin: Date): Promise<string> {
|
||||
// Pasamos el string antes tenia Date
|
||||
async generarReporte(inicio: string, fin: string): Promise<string> {
|
||||
const path = `server/uploads/reporte.csv`;
|
||||
const data: any[] = [];
|
||||
|
||||
@@ -1345,7 +1359,7 @@ export class ServicioService {
|
||||
'status.idStatus',
|
||||
'status.status',
|
||||
])
|
||||
.orderBy('servicio.updatedAt', 'DESC')
|
||||
.orderBy('servicio.createdAt', 'DESC') // Cambiamos el orderBy anteriormente orderBy('servicio.updatedAt', 'DESC')
|
||||
.skip(25 * (pagina - 1))
|
||||
.take(25);
|
||||
|
||||
@@ -1413,9 +1427,6 @@ export class ServicioService {
|
||||
|
||||
// ---- 📆 Validaciones de campos del body ----
|
||||
if (body.correo) dataUpdate.correo = body.correo;
|
||||
if (body.fechaInicio) dataUpdate.fechaInicio = body.fechaInicio;
|
||||
if (body.fechaFin) dataUpdate.fechaFin = body.fechaFin;
|
||||
if (body.fechaNacimiento) dataUpdate.fechaNacimiento = body.fechaNacimiento;
|
||||
if (body.direccion)
|
||||
dataUpdate.direccion = this.validacionService.validarAlfanumerico(
|
||||
body.direccion,
|
||||
@@ -1431,6 +1442,10 @@ export class ServicioService {
|
||||
15,
|
||||
);
|
||||
|
||||
if (body.fechaInicio) dataUpdate.fechaInicio = moment(body.fechaInicio).format('YYYY-MM-DD');
|
||||
if (body.fechaFin) dataUpdate.fechaFin = moment(body.fechaFin).format('YYYY-MM-DD');
|
||||
if (body.fechaNacimiento) dataUpdate.fechaNacimiento = moment(body.fechaNacimiento).format('YYYY-MM-DD');
|
||||
|
||||
if (this.validacionService.validarObjetoVacio(dataUpdate)) {
|
||||
throw new BadRequestException(
|
||||
'No se envió nada para actualizar este Servicio Social.',
|
||||
|
||||
Reference in New Issue
Block a user