added programa, area ubicacion and programa_equipo
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsDate, IsNumber, IsString } from 'class-validator';
|
||||
import { IsDate, IsDateString, IsNumber, IsString } from 'class-validator';
|
||||
|
||||
export class CreateReciboDto {
|
||||
|
||||
@@ -13,3 +13,11 @@ export class CreateReciboDto {
|
||||
@Type(() => Date)
|
||||
fecha_recibo: Date;
|
||||
}
|
||||
|
||||
export class FindReciboByRangeDto {
|
||||
@IsDateString()
|
||||
desde: string;
|
||||
|
||||
@IsDateString()
|
||||
hasta: string;
|
||||
}
|
||||
@@ -29,13 +29,13 @@ export class Recibo {
|
||||
monto: number;
|
||||
|
||||
@Column({ name: 'fecha_recibo', type: 'date', nullable: false })
|
||||
fecha_recibo: Date ;
|
||||
fecha_recibo: Date;
|
||||
|
||||
@ManyToOne(() => Alumno, (alum) => alum.id_cuenta, {})
|
||||
@ManyToOne(() => Alumno, (alum) => alum.id_cuenta, { eager: true })
|
||||
@JoinColumn({ name: 'id_cuenta' })
|
||||
alum: Alumno;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.id_usuario, {})
|
||||
@ManyToOne(() => User, (user) => user.id_usuario, { eager: true })
|
||||
@JoinColumn({ name: 'id_usuario' })
|
||||
user: User;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,15 @@ import {
|
||||
Req,
|
||||
} from '@nestjs/common';
|
||||
import { ReciboService } from './recibo.service';
|
||||
import { FindReciboByRangeDto } from './dto/create-recibo.dto';
|
||||
|
||||
@Controller('recibo')
|
||||
export class ReciboController {
|
||||
constructor(private readonly reciboService: ReciboService) {}
|
||||
|
||||
@Post('rango')
|
||||
async findByDateRange(@Body() data: FindReciboByRangeDto) {
|
||||
return this.reciboService.findByDateRange(data.desde, data.hasta);
|
||||
}
|
||||
}
|
||||
//IO
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ConflictException, Injectable } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Recibo } from './entities/recibo.entity';
|
||||
import { EntityManager, Repository } from 'typeorm';
|
||||
import { Between, EntityManager, Repository } from 'typeorm';
|
||||
import { CreateReciboDto } from './dto/create-recibo.dto';
|
||||
|
||||
@Injectable()
|
||||
@@ -23,5 +23,17 @@ export class ReciboService {
|
||||
const details = repo.create(data);
|
||||
return await repo.save(details);
|
||||
}
|
||||
|
||||
async findByDateRange(desde: string, hasta: string) {
|
||||
// Convertimos strings a objetos Date
|
||||
const fechaDesde = new Date(desde);
|
||||
const fechaHasta = new Date(hasta);
|
||||
|
||||
return await this.reciboRepository.find({
|
||||
where: {
|
||||
fecha_recibo: Between(fechaDesde, fechaHasta),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
//IO
|
||||
|
||||
Reference in New Issue
Block a user