This commit is contained in:
xXpuma99Xx
2022-06-14 20:57:28 -05:00
parent 2ddd98be37
commit 426ca54328
8 changed files with 192 additions and 30 deletions
+19 -11
View File
@@ -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;