opeardor multa y operador cancelacion
This commit is contained in:
@@ -8,6 +8,7 @@ const Prestamo = require(`${dbPath}/Prestamo`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const multar = async (body) => {
|
||||
const idOperadorMulta = validar.validarId(body.idOperadorMulta);
|
||||
const idInfraccion = validar.validarId(body.idInfraccion);
|
||||
const numeroInventario = validar.validarAlfanumerico(
|
||||
body.numeroInventario,
|
||||
@@ -22,7 +23,11 @@ const multar = async (body) => {
|
||||
let prestamo = {};
|
||||
let fechaFin = moment();
|
||||
|
||||
return Infraccion.findOne({ where: { idInfraccion } })
|
||||
return Operador.findOne({ where: { idOperador: idOperadorMulta } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe esta este operador.');
|
||||
return Infraccion.findOne({ where: { idInfraccion } });
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe esta infracción.');
|
||||
if (res.gravedad == '1') fechaFin.add(7, 'd');
|
||||
@@ -52,6 +57,7 @@ const multar = async (body) => {
|
||||
.then((res) =>
|
||||
Multa.create({
|
||||
descripcion,
|
||||
idOperadorMulta,
|
||||
idInfraccion,
|
||||
idPrestamo: prestamo.idPrestamo,
|
||||
fechaFin: fechaFin.format(),
|
||||
|
||||
Reference in New Issue
Block a user