separacion del credito

This commit is contained in:
Andres2908
2022-05-10 23:36:28 -05:00
parent c3954b0110
commit 63fc909859
4 changed files with 47 additions and 14 deletions
+20
View File
@@ -0,0 +1,20 @@
const dbPath = '../../db/tablas';
const Usuario = require(`${dbPath}/Usuario`);
const { validarNumeroCuenta } = require('../../helper/validar');
const credito = async (body) => {
const numeroCuenta = validarNumeroCuenta(
body.numeroCuenta,
'número de cuenta',
true
);
return Usuario.findOne({
where: { numeroCuenta },
}).then(() => {
return Usuario.findOne({
attributes: ['credito', 'nombre', 'numeroCuenta'],
});
});
};
module.exports = credito;
+1 -1
View File
@@ -12,7 +12,7 @@ const credito = async (body) => {
where: { numeroCuenta },
}).then(() => {
return Usuario.findOne({
attributes: ['credito', 'nombre', 'numeroCuenta'],
attributes: ['credito'],
});
});
};
+14 -2
View File
@@ -15,6 +15,7 @@ const validarTicket = require(`${controllerPath}/validarTicket`);
const reporte = require(`${controllerPath}/reporte`);
const restarCredito = require(`${controllerPath}/restarCredito`);
const ticketsImpresion = require(`${controllerPath}/ticketsImpresion`);
const credito = require(`${controllerPath}/credito`);
app.post(`${route}/login`, (req, res) => {
return login(req.body)
@@ -109,7 +110,7 @@ app.get(`${route}/reporte`, verificaToken, (req, res) => {
});
});
app.put(`${route}/restar_credito`, (req, res) => {
app.put(`${route}/restar_credito`, verificaToken, (req, res) => {
return restarCredito(req.body)
.then((data) => {
res.status(200).json(data);
@@ -119,7 +120,7 @@ app.put(`${route}/restar_credito`, (req, res) => {
});
});
app.get(`${route}/tickets_impresion`, (req, res) => {
app.get(`${route}/tickets_impresion`, verificaToken, (req, res) => {
return ticketsImpresion(req.query)
.then((data) => {
res.status(200).json(data);
@@ -128,4 +129,15 @@ app.get(`${route}/tickets_impresion`, (req, res) => {
res.status(400).json({ message: err.message });
});
});
app.get(`${route}/credito`, verificaToken, (req, res) => {
return credito(req.query)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
module.exports = app;
+12 -11
View File
@@ -9,8 +9,8 @@ const controllerPath = '../controller/Usuario';
const login = require(`${controllerPath}/login`);
const inscripciones = require(`${controllerPath}/inscripciones`);
const inscripcionUsuario = require(`${controllerPath}/inscripcionUsuario`);
const credito = require(`${controllerPath}/credito`);
const agregarCredito = require(`${controllerPath}/agregarCredito`);
const credito = require(`${controllerPath}/credito`);
app.post(`${route}/login`, (req, res) => {
return login(req.body)
@@ -47,16 +47,6 @@ app.post(
}
);
app.get(`${route}/credito`, (req, res) => {
return credito(req.query)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
app.put(`${route}/agregar_credito`, (req, res) => {
return agregarCredito(req.body)
.then((data) => {
@@ -66,4 +56,15 @@ app.put(`${route}/agregar_credito`, (req, res) => {
res.status(400).json({ message: err.message });
});
});
app.get(`${route}/credito`, verificaToken, (req, res) => {
return credito(req.query)
.then((data) => {
res.status(200).json(data);
})
.catch((err) => {
res.status(400).json({ message: err.message });
});
});
module.exports = app;