multa
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { forwardRef, Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { MultaController } from './multa.controller';
|
||||
import { MultaService } from './multa.service';
|
||||
@@ -16,7 +16,7 @@ import { UsuarioModule } from '../usuario/usuario.module';
|
||||
InstitucionModule,
|
||||
InstitucionInfraccionModule,
|
||||
OperadorModule,
|
||||
PrestamoModule,
|
||||
forwardRef(() => PrestamoModule),
|
||||
TypeOrmModule.forFeature([Multa]),
|
||||
UsuarioModule,
|
||||
],
|
||||
|
||||
+19
-11
@@ -27,22 +27,30 @@ export class MultaService {
|
||||
) {}
|
||||
|
||||
async create(
|
||||
id_prestamo: number,
|
||||
id_operador: number,
|
||||
retraso?: boolean,
|
||||
id_prestamo: number | Prestamo,
|
||||
id_operador: number | Operador,
|
||||
descripcion: string,
|
||||
retraso?: number,
|
||||
id_institucion_infraccion?: number,
|
||||
) {
|
||||
const ahora = moment();
|
||||
const prestamo = await this.prestamoService.findById(id_prestamo);
|
||||
const operador = await this.operadorService.findById(id_operador);
|
||||
const prestamo =
|
||||
typeof id_prestamo === 'number'
|
||||
? await this.prestamoService.findById(id_prestamo)
|
||||
: id_prestamo;
|
||||
const operador =
|
||||
typeof id_operador === 'number'
|
||||
? await this.operadorService.findById(id_operador)
|
||||
: id_operador;
|
||||
const data: {
|
||||
prestamo: Prestamo;
|
||||
operador: Operador;
|
||||
descripcion: string;
|
||||
fecha_inicio: Date;
|
||||
operador: Operador;
|
||||
prestamo: Prestamo;
|
||||
fecha_fin?: Date;
|
||||
institucionInfraccion?: InstitucionInfraccion;
|
||||
retraso?: boolean;
|
||||
fecha_fin?: Date;
|
||||
} = { fecha_inicio: ahora.toDate(), prestamo, operador };
|
||||
} = { descripcion, fecha_inicio: ahora.toDate(), operador, prestamo };
|
||||
const institucionInfraccion = id_institucion_infraccion
|
||||
? await this.institucionInfraccionService.findById(
|
||||
id_institucion_infraccion,
|
||||
@@ -59,8 +67,8 @@ export class MultaService {
|
||||
'Ya existe una multa asignada a este prestamo.',
|
||||
);
|
||||
if (retraso) {
|
||||
data.retraso = retraso;
|
||||
ahora.add(operador.institucion.dias_multa_retraso, 'd');
|
||||
data.retraso = true;
|
||||
ahora.add(retraso * operador.institucion.dias_multa_retraso, 'd');
|
||||
}
|
||||
if (institucionInfraccion) {
|
||||
data.institucionInfraccion = institucionInfraccion;
|
||||
|
||||
Reference in New Issue
Block a user