@@ -123,16 +128,16 @@
diff --git a/APP/pages/ingresos.vue b/APP/pages/ingresos.vue
index 6c097d2..8694562 100644
--- a/APP/pages/ingresos.vue
+++ b/APP/pages/ingresos.vue
@@ -32,7 +32,7 @@
icon
size="sm"
class="btn-link"
- @click="updateIngresoClic($index)"
+ @click="updateIngresoClic(row._id)"
>
@@ -109,6 +109,7 @@ export default {
const axiosHeader = {
headers: {
token: this.$store.state.auth.token,
+ filtro:this.$store.state.filtro.fechas
},
};
this.$axios
@@ -158,7 +159,8 @@ export default {
},
updateIngresoClic(id) {
this.isUpdate = true;
- this.newIngreso = JSON.parse(JSON.stringify(this.ingresos[id]));
+ var reg_edit = this.ingresos.filter((ic) => ic._id===id)[0];
+ this.newIngreso = JSON.parse(JSON.stringify(reg_edit));
this.openForm = !this.openForm;
},
diff --git a/APP/pages/presupuesto.vue b/APP/pages/presupuesto.vue
index c360e35..452b0f9 100644
--- a/APP/pages/presupuesto.vue
+++ b/APP/pages/presupuesto.vue
@@ -261,6 +261,7 @@ export default {
const axiosHeader = {
headers: {
token: this.$store.state.auth.token,
+ limite:this.$store.state.filtro.npresupuesto
},
};
diff --git a/APP/store/index.js b/APP/store/index.js
index f99843f..2c4acb6 100644
--- a/APP/store/index.js
+++ b/APP/store/index.js
@@ -1,94 +1,85 @@
export const state = () => ({
- auth: null,
- notifications: [],
- fecha: fechaString(),
- categorias:[],
- metodos_de_pago:[]
- });
+ auth: null,
+ notifications: [],
+ filtro: {fechas:fechaString().slice(0, 7),npresupuesto:5},
+ fecha: fechaString(),
+ categorias: [],
+ metodos_de_pago: []
+});
- export const mutations = {
+export const mutations = {
+ setAuth(state, auth) {
+ state.auth = auth;
+ },
- setAuth(state, auth) {
- state.auth = auth;
- },
-
- setNotifications(state, notifications) {
- state.notifications = notifications;
- },
+ setNotifications(state, notifications) {
+ state.notifications = notifications;
+ },
- setCategorias(state, categorias) {
- state.categorias = categorias;
- },
+ setCategorias(state, categorias) {
+ state.categorias = categorias;
+ },
- setMetodos(state, metodos) {
- state.metodos_de_pago = metodos;
- },
-
-
-
- };
+ setMetodos(state, metodos) {
+ state.metodos_de_pago = metodos;
+ },
+ actualizarFiltro(state,filtro) {
- function fechaString(){
- let data = new Date();
- let year= data.getFullYear();
- let month = (data.getMonth() + 1)<9?"0"+(data.getMonth() + 1):(data.getMonth() + 1)
- let day = data.getDate()<9?"0"+data.getDate():data.getDate()
- let dataF=`${year}-${month}-${day}`
- return dataF;
-
+ state.filtro=filtro
+
+ }
+};
+
+function fechaString() {
+ let data = new Date();
+ let year = data.getFullYear();
+ let month =
+ data.getMonth() + 1 < 9 ? "0" + (data.getMonth() + 1) : data.getMonth() + 1;
+ let day = data.getDate() < 9 ? "0" + data.getDate() : data.getDate();
+ let dataF = `${year}-${month}-${day}`;
+ return dataF;
}
export const actions = {
-
- readToken() {
- let auth = null;
- try {
- auth = JSON.parse(localStorage.getItem("auth"));
- } catch (error) {
- console.log(err);
+ readToken() {
+ let auth = null;
+ try {
+ auth = JSON.parse(localStorage.getItem("auth"));
+ } catch (error) {
+ console.log(err);
+ }
+ //saving auth in state
+ this.commit("setAuth", auth);
+ },
+ getCategorias() {
+ const axiosHeader = {
+ headers: {
+ token: this.state.auth.token
}
- //saving auth in state
- this.commit("setAuth", auth);
- },
- getCategorias() {
-
- const axiosHeader = {
- headers: {
- token: this.state.auth.token
- }
- };
+ };
-
- this.$axios.get("/categoria", axiosHeader)
- .then(res => {
-
- this.commit("setCategorias", res.data.data);
-
-
- }).catch(error => {
- console.log(error);
- });
-
+ this.$axios
+ .get("/categoria", axiosHeader)
+ .then(res => {
+ this.commit("setCategorias", res.data.data);
+ })
+ .catch(error => {
+ console.log(error);
+ });
},
getMetodos() {
-
const axiosHeader = {
headers: {
- token: this.state.auth.token,
- },
+ token: this.state.auth.token
+ }
};
this.$axios
.get("/metodo", axiosHeader)
- .then((res) => {
-
+ .then(res => {
this.commit("setMetodos", res.data.data);
})
- .catch((e) => console.log(e));
-
-},
-
-
-
-}
+ .catch(e => console.log(e));
+ },
+};
diff --git a/routes/compras.js b/routes/compras.js
index 665fd39..c066a6a 100644
--- a/routes/compras.js
+++ b/routes/compras.js
@@ -5,8 +5,12 @@ const { checkAuth } = require("../middlewares/authentication");
router.get("/compras", checkAuth, async (req, res) => {
var compras;
-
- compras = await Compra.find({ user: req.userData._id }).sort({
+ let miFiltro = req.get('filtro');
+ const filtros = {
+ fecha: { $regex: miFiltro, $options: "i" },
+ };
+
+ compras = await Compra.find({$and:[{ user: req.userData._id },filtros]}).sort({
fecha: "desc",
});
diff --git a/routes/ingresos.js b/routes/ingresos.js
index f828757..97472d6 100644
--- a/routes/ingresos.js
+++ b/routes/ingresos.js
@@ -5,7 +5,13 @@ const { checkAuth } = require("../middlewares/authentication");
router.get("/ingreso", checkAuth, async (req, res) => {
var Ingresos;
- Ingresos = await Ingreso.find({ user: req.userData._id }).sort({
+ let miFiltro = req.get('filtro');
+ const filtros = {
+ fecha: { $regex: miFiltro, $options: "i" },
+ };
+
+
+ Ingresos = await Ingreso.find({$and:[{ user: req.userData._id },filtros]}).sort({
fecha: "desc",
});
diff --git a/routes/presupuesto.js b/routes/presupuesto.js
index c48c455..1ab69f1 100644
--- a/routes/presupuesto.js
+++ b/routes/presupuesto.js
@@ -5,9 +5,11 @@ const { checkAuth } = require("../middlewares/authentication");
router.get("/presupuesto", checkAuth, async (req, res) => {
var presupuestos;
+ let limite = req.get('limite');
presupuestos = await presupuesto.find({ user: req.userData._id }).sort({
date: "desc",
- });
+ }).limit(parseInt(limite));
+
return res.send({
status: "ok",