separacion del credito
This commit is contained in:
@@ -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;
|
||||
@@ -12,7 +12,7 @@ const credito = async (body) => {
|
||||
where: { numeroCuenta },
|
||||
}).then(() => {
|
||||
return Usuario.findOne({
|
||||
attributes: ['credito', 'nombre', 'numeroCuenta'],
|
||||
attributes: ['credito'],
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
+14
-2
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user