From 77bdccdf86f5c3be1d487b5c3ec1149b46ab6bd7 Mon Sep 17 00:00:00 2001 From: Ale Date: Wed, 8 Jun 2022 23:33:33 -0300 Subject: [PATCH 1/3] Suma el total de los pedidos aprobados --- public/js/app.js | 29 +++++++++++++++++++++++ resources/js/components/SubpedidosGdc.vue | 25 +++++++++++++++---- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index b4affff..327f0eb 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -2957,6 +2957,13 @@ __webpack_require__.r(__webpack_exports__); // // // +// +// +// +// +// +// +// /* harmony default export */ __webpack_exports__["default"] = ({ name: "SubpedidosGdc", @@ -2985,6 +2992,18 @@ __webpack_require__.r(__webpack_exports__); axios.get("/api/subpedidos/resources").then(function (response) { _this2.subpedidos = response.data.data; }); + }, + totalAprobados: function totalAprobados() { + var suma = 0; + var aprobados = this.subpedidos.filter(function (sp) { + return sp.aprobado; + }); + + for (var i = 0; i < aprobados.length; i++) { + suma += parseFloat(aprobados[i].total); + } + + return suma; } }, mounted: function mounted() { @@ -5922,6 +5941,16 @@ var render = function () { [ _vm._m(0), _vm._v(" "), + _c("tfoot", [ + _c("tr", [ + _c("th"), + _vm._v(" "), + _c("th", [_vm._v("Total de los aprobados")]), + _vm._v(" "), + _c("th", [_vm._v("$ " + _vm._s(_vm.totalAprobados()))]), + ]), + ]), + _vm._v(" "), _c( "tbody", _vm._l(this.subpedidos, function (subpedido) { diff --git a/resources/js/components/SubpedidosGdc.vue b/resources/js/components/SubpedidosGdc.vue index 4ccd7b8..e73cbd3 100644 --- a/resources/js/components/SubpedidosGdc.vue +++ b/resources/js/components/SubpedidosGdc.vue @@ -8,11 +8,18 @@ Aprobación - - - - + + + + Total de los aprobados + $ {{ totalAprobados() }} + + + + + +

Todavía no hay ningún pedido para administrar. @@ -42,6 +49,14 @@ export default { axios.get("/api/subpedidos/resources").then(response => { this.subpedidos = response.data.data }); + }, + totalAprobados() { + let suma = 0; + let aprobados = this.subpedidos.filter(sp => sp.aprobado); + for (let i = 0; i < aprobados.length; i++) { + suma += parseFloat(aprobados[i].total); + } + return suma; } }, mounted() { From ece866a3ec28c4639c6a441e3de21f360aaf8beb Mon Sep 17 00:00:00 2001 From: Ale Date: Thu, 9 Jun 2022 10:34:28 -0300 Subject: [PATCH 2/3] Arreglado bug que mostraba los pedidos de todos los barrios en la pantalla de admin de cualquier barrio --- public/js/app.js | 6 +++++- resources/js/components/SubpedidosGdc.vue | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 327f0eb..fff062a 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -2989,7 +2989,11 @@ __webpack_require__.r(__webpack_exports__); fetchSubpedidos: function fetchSubpedidos() { var _this2 = this; - axios.get("/api/subpedidos/resources").then(function (response) { + axios.get("/api/subpedidos/resources", { + params: { + grupo_de_compra: this.gdc + } + }).then(function (response) { _this2.subpedidos = response.data.data; }); }, diff --git a/resources/js/components/SubpedidosGdc.vue b/resources/js/components/SubpedidosGdc.vue index e73cbd3..767f12c 100644 --- a/resources/js/components/SubpedidosGdc.vue +++ b/resources/js/components/SubpedidosGdc.vue @@ -46,7 +46,11 @@ export default { }, methods: { fetchSubpedidos() { - axios.get("/api/subpedidos/resources").then(response => { + axios.get("/api/subpedidos/resources", { + params: { + grupo_de_compra: this.gdc + } + }).then(response => { this.subpedidos = response.data.data }); }, From 0d5551406a958e42cbcae60500a9ff92999d4d66 Mon Sep 17 00:00:00 2001 From: Ale Date: Thu, 9 Jun 2022 20:09:18 -0300 Subject: [PATCH 3/3] Arreglado bug de totales con coma --- public/js/app.js | 2 +- resources/js/components/SubpedidosGdc.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index fff062a..b406716 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -3004,7 +3004,7 @@ __webpack_require__.r(__webpack_exports__); }); for (var i = 0; i < aprobados.length; i++) { - suma += parseFloat(aprobados[i].total); + suma += parseFloat(aprobados[i].total.replace(/,/g, '')); } return suma; diff --git a/resources/js/components/SubpedidosGdc.vue b/resources/js/components/SubpedidosGdc.vue index 767f12c..de31f56 100644 --- a/resources/js/components/SubpedidosGdc.vue +++ b/resources/js/components/SubpedidosGdc.vue @@ -58,7 +58,7 @@ export default { let suma = 0; let aprobados = this.subpedidos.filter(sp => sp.aprobado); for (let i = 0; i < aprobados.length; i++) { - suma += parseFloat(aprobados[i].total); + suma += parseFloat(aprobados[i].total.replace(/,/g, '')); } return suma; }