42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
|
import { DetalleServicioService } from './detalle_servicio.service';
|
|
import { FindReciboByRangeDto } from 'src/recibo/dto/create-recibo.dto';
|
|
import { JwtAuthGuard } from 'src/user/jwt.guard';
|
|
import { RolesGuard } from 'src/roles.guard';
|
|
import { Roles } from 'src/roles.decorator';
|
|
import { Role } from 'src/role.enum';
|
|
|
|
|
|
@Controller('detalle-servicio')
|
|
export class DetalleServicioController {
|
|
constructor(private readonly detalleServicioService: DetalleServicioService) { }
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
|
@Get()
|
|
findAll() {
|
|
return this.detalleServicioService.findAll()
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
|
@Post('rango')
|
|
async findByDateRange(@Body() data: FindReciboByRangeDto) {
|
|
return this.detalleServicioService.findByDateRange(data.desde, data.hasta);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
|
|
@Get('totales-por-periodo')
|
|
async getTotalesPorPeriodo(
|
|
@Query('periodoInicio') periodoInicio?: string,
|
|
@Query('periodoFin') periodoFin?: string,
|
|
@Query('servicioId') servicioId?: string,
|
|
) {
|
|
const inicio = periodoInicio ? parseInt(periodoInicio) : undefined;
|
|
const fin = periodoFin ? parseInt(periodoFin) : undefined;
|
|
const servicio = servicioId ? parseInt(servicioId) : undefined;
|
|
return this.detalleServicioService.getTotalesPorServicioYPeriodo(inicio, fin, servicio);
|
|
}
|
|
}
|