Compare commits

..

14 commits

16 changed files with 219 additions and 122 deletions

1
.gitignore vendored
View file

@ -12,3 +12,4 @@ npm-debug.log
yarn-error.log yarn-error.log
.idea .idea
/resources/csv/exports/*.csv /resources/csv/exports/*.csv
/public

View file

@ -17,6 +17,13 @@ class GrupoDeCompra extends Model
protected $table = 'grupos_de_compra'; protected $table = 'grupos_de_compra';
protected $hidden = ['password']; protected $hidden = ['password'];
public function toggleDevoluciones()
{
$this->devoluciones_habilitadas = !$this->devoluciones_habilitadas;
$this->save();
return $this->devoluciones_habilitadas;
}
public function subpedidos() { public function subpedidos() {
return $this->hasMany('App\Subpedido'); return $this->hasMany('App\Subpedido');
} }

View file

@ -1,50 +0,0 @@
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0be94811453f bc48a6b1eec1 "/bin/sh -c 'apt-get…" 3 days ago Exited (100) 3 days ago festive_poitras
20904ea983a8 bc48a6b1eec1 "/bin/sh -c 'apt-get…" 3 days ago Exited (100) 3 days ago nifty_antonelli
eb71d65b34cc odoo:15 "/entrypoint.sh odoo" 6 weeks ago Up 6 days 0.0.0.0:8069->8069/tcp, 8071-8072/tcp odoo_bar_web_1
6b08d5b023b7 postgres:latest "docker-entrypoint.s…" 6 weeks ago Up 6 weeks 0.0.0.0:32775->5432/tcp odoo_bar_db_1
2be39cf0f208 wordpress:latest "docker-entrypoint.s…" 2 months ago Up 2 months 0.0.0.0:8007->80/tcp wordpress-mps_wordpress_1
1fb3ab9d5196 mariadb:10.3 "docker-entrypoint.s…" 2 months ago Up 2 months 3306/tcp wordpress-mps_db_1
62d94ac320a9 wordpress:cli-php8.0 "docker-entrypoint.s…" 2 months ago Exited (1) 2 months ago wordpress-mps_wpcli_1
dfa0be51db2f mysql:5.7 "docker-entrypoint.s…" 6 months ago Up 4 months 33060/tcp, 0.0.0.0:33060->3306/tcp pedi2-db
d2261994fbbb nginx:alpine "/docker-entrypoint.…" 6 months ago Up 4 months 0.0.0.0:8903->80/tcp pedi2-nginx
8dfd4713c569 laravel-image "docker-php-entrypoi…" 6 months ago Up 4 months 9000/tcp pedi2-app
1717f2e0e075 collabora/code:latest "/start-collabora-on…" 6 months ago Up 4 months 0.0.0.0:9980->9980/tcp collabora
949c45e8e331 nginx:alpine "/docker-entrypoint.…" 11 months ago Up 4 months 0.0.0.0:8902->80/tcp planifibot-nginx
855c759a117d 70bc6d959246 "docker-php-entrypoi…" 11 months ago Up 4 months 9000/tcp planifibot-app
f8591a57bab7 mysql:5.7 "docker-entrypoint.s…" 11 months ago Up 4 months 33060/tcp, 0.0.0.0:3316->3306/tcp planifibot-db
a7de86736ea4 akaunting/akaunting:es "/usr/local/bin/akau…" 12 months ago Exited (0) 8 months ago akaunting
0f4753ad709d mariadb "docker-entrypoint.s…" 12 months ago Exited (0) 8 months ago akaunting-db
7dab3c403e21 127.0.0.1:5000/mps/planifibot:latest "docker-php-entrypoi…" 12 months ago Exited (255) 12 months ago 0.0.0.0:8044->80/tcp planifibot
5880418fe8df 105826cada74 "docker-php-entrypoi…" 12 months ago Exited (255) 12 months ago 0.0.0.0:8044->80/tcp admiring_lumiere
8fd9068db7ed 592f6de18841 "docker-php-entrypoi…" 12 months ago Exited (0) 12 months ago tender_kare
db313e1dc227 72ba750ea9de "/bin/sh -c 'chown -…" 12 months ago Exited (1) 12 months ago pedantic_torvalds
4bd63fb01f80 8e2bc9d43c26 "/bin/sh -c 'chown -…" 12 months ago Exited (1) 12 months ago stoic_goldstine
8181000e76cc 1ed58aad8567 "/bin/sh -c 'docker-…" 12 months ago Exited (1) 12 months ago lucid_lalande
ec7da80bde1a b042c91004f0 "/bin/sh -c 'apt-get…" 12 months ago Exited (100) 12 months ago keen_mendel
43fd36cd860f b042c91004f0 "/bin/sh -c 'docker-…" 12 months ago Exited (1) 12 months ago jovial_khayyam
02a551fc62b5 b042c91004f0 "/bin/sh -c 'docker-…" 12 months ago Exited (1) 12 months ago heuristic_curie
47f377f81a3e 1b37a536c088 "/bin/sh -c 'apt-get…" 12 months ago Exited (1) 12 months ago laughing_franklin
0f63ee6729d9 1b37a536c088 "/bin/sh -c 'apt-get…" 12 months ago Exited (1) 12 months ago elegant_hoover
8a97c786f1e8 1b37a536c088 "/bin/sh -c 'apt-get…" 12 months ago Exited (100) 12 months ago distracted_yonath
d4c7f0f8b235 1b37a536c088 "/bin/sh -c 'apt-get…" 12 months ago Exited (100) 12 months ago vigilant_brown
a6d3cf25487e 80bfd1c2ffed "/bin/sh -c 'apt-get…" 12 months ago Exited (100) 12 months ago dazzling_williams
50030ac55043 80bfd1c2ffed "/bin/sh -c 'apt-get…" 12 months ago Exited (100) 12 months ago pedantic_lovelace
0ba2516ca8bd 1e9cc426f6db "/bin/sh -c 'apt-get…" 12 months ago Exited (100) 12 months ago suspicious_merkle
506eb5744961 1e9cc426f6db "/bin/sh -c 'apt-get…" 12 months ago Exited (100) 12 months ago stupefied_curie
29a25c955eef 1e9cc426f6db "/bin/sh -c 'apt-get…" 12 months ago Exited (100) 12 months ago competent_greider
bcbd4a6e70fc 1e9cc426f6db "/bin/sh -c 'apt-get…" 12 months ago Exited (100) 12 months ago condescending_chaum
0ff1e51bf0c5 1e9cc426f6db "/bin/sh -c 'apt-get…" 12 months ago Exited (100) 12 months ago eager_morse
4b200797fbb8 9ff09bb3bbaf "/bin/sh -c 'apk add…" 12 months ago Exited (127) 12 months ago trusting_euler
4630e65da875 38b8d34febc3 "/bin/sh -c 'docker-…" 12 months ago Exited (2) 12 months ago pensive_khorana
31bc5cbeebda 38b8d34febc3 "/bin/sh -c 'docker-…" 13 months ago Exited (2) 13 months ago elated_chatterjee
dcbaf807509c c2521253d4dc "/bin/sh -c 'docker-…" 13 months ago Exited (2) 13 months ago mystifying_cohen
a8d287e4972e c2521253d4dc "/bin/sh -c 'docker-…" 13 months ago Exited (2) 13 months ago adoring_boyd
57e55bd140e5 919da407c087 "/bin/sh -c 'apt-get…" 13 months ago Exited (100) 13 months ago blissful_turing
16759118d07b 919da407c087 "/bin/sh -c 'apt-get…" 13 months ago Exited (100) 13 months ago modest_edison
686e965026ac 919da407c087 "/bin/sh -c 'apt-get…" 13 months ago Exited (100) 13 months ago upbeat_khorana
e6a4f4e0bc55 919da407c087 "/bin/sh -c 'apt-get…" 13 months ago Exited (100) 13 months ago inspiring_lovelace
d19e81ca0ad2 34258187e19e "/bin/sh -c 'wget -q…" 17 months ago Exited (127) 17 months ago hardcore_lederberg
0d3305ea4c5d fc0cc68061fd "/bin/sh -c 'apt-get…" 17 months ago Exited (2) 17 months ago epic_einstein
1f0cc817b5f9 fc0cc68061fd "/bin/sh -c 'apt-get…" 17 months ago Exited (2) 17 months ago flamboyant_jang
ec330033c36f mariadb:10.3 "docker-entrypoint.s…" 22 months ago Exited (137) 17 months ago akaunting_db_1

25
resources/js/app.js vendored
View file

@ -59,7 +59,8 @@ const app = new Vue({
data() { data() {
return { return {
gdc: null, gdc: null,
pedido: null pedido: null,
devoluciones: null,
} }
}, },
computed: { computed: {
@ -71,18 +72,32 @@ const app = new Vue({
cantidad(producto) { cantidad(producto) {
let pedido = this.productos.some(p => p.id == producto.id) let pedido = this.productos.some(p => p.id == producto.id)
return pedido ? this.productos.find(p => p.id == producto.id).pivot.cantidad : 0 return pedido ? this.productos.find(p => p.id == producto.id).pivot.cantidad : 0
},
settearDevoluciones() {
axios.get(`/api/grupos-de-compra/${this.gdc}/devoluciones`)
.then(response => {
this.devoluciones = response.data.devoluciones;
});
} }
}, },
mounted() { mounted() {
Event.$on('obtener-sesion', () => { Event.$on('obtener-sesion', () => {
axios.get('/subpedidos/obtener_sesion') axios.get('/subpedidos/obtener_sesion')
.then(response => { .then(response => {
this.pedido = response.data.subpedido.id if (response.data.subpedido.id) {
this.gdc = response.data.gdc;
this.settearDevoluciones();
this.pedido = response.data.subpedido.id;
axios.get('/api/subpedidos/' + this.pedido) axios.get('/api/subpedidos/' + this.pedido)
.then(response => { .then(response => {
this.pedido = response.data.data this.pedido = response.data.data;
this.gdc = this.pedido.grupo_de_compra.id });
}) } else {
axios.get('/admin/obtener_sesion')
.then(response => {
this.gdc = response.data.gdc
});
}
}) })
}) })
Event.$on('sync-subpedido', (cantidad, id) => { Event.$on('sync-subpedido', (cantidad, id) => {

View file

@ -18,7 +18,7 @@
<th></th> <th></th>
<th></th> <th></th>
</tr> </tr>
<tr> <tr v-if="this.$root.devoluciones">
<th><p :title="this.$root.pedido.devoluciones_notas">Devoluciones</p></th> <th><p :title="this.$root.pedido.devoluciones_notas">Devoluciones</p></th>
<th class="has-text-right"></th> <th class="has-text-right"></th>
<th class="has-text-right">-{{ this.$root.pedido.devoluciones_total }}</th> <th class="has-text-right">-{{ this.$root.pedido.devoluciones_total }}</th>
@ -62,7 +62,7 @@
return this.$limpiarInt(this.$root.pedido.subtotal_bonos_de_transporte) return this.$limpiarInt(this.$root.pedido.subtotal_bonos_de_transporte)
}, },
total: function() { total: function() {
return this.$limpiarInt(this.$root.pedido.total_menos_devoluciones) return this.$limpiarInt(this.$root.devoluciones ? this.$root.pedido.total_menos_devoluciones : this.$root.pedido.total)
} }
}, },
methods: { methods: {

View file

@ -5,7 +5,7 @@
<span class="icon is-small mr-1"> <span class="icon is-small mr-1">
<img src="/assets/chismosa.png"> <img src="/assets/chismosa.png">
</span> </span>
<span v-text="'$' + this.$limpiarInt(this.$root.pedido.total_menos_devoluciones)"></span> <span v-text="'$' + this.$limpiarInt($root.devoluciones ? $root.pedido.total_menos_devoluciones : $root.pedido.total)"></span>
</a> </a>
</div> </div>
<div class="dropdown-menu chismosa-menu" :id="id" role="menu"> <div class="dropdown-menu chismosa-menu" :id="id" role="menu">

View file

@ -24,6 +24,11 @@
Todavía no hay pedidos aprobados. Todavía no hay pedidos aprobados.
</p> </p>
</div> </div>
<div class="block pb-6" id="caracteristicas-seccion"
:class="seccionActiva === 'caracteristicas-seccion' ? 'is-active' : 'is-hidden'">
<pedidos-admin-caracteristicas-opcionales>
</pedidos-admin-caracteristicas-opcionales>
</div>
</div> </div>
</template> </template>
@ -32,9 +37,11 @@ import PedidosAdminTabsSecciones from './PedidosAdminTabsSecciones.vue';
import PedidosAdminDropdownDescargar from "./PedidosAdminDropdownDescargar.vue"; import PedidosAdminDropdownDescargar from "./PedidosAdminDropdownDescargar.vue";
import PedidosAdminTablaBonos from './PedidosAdminTablaBonos.vue'; import PedidosAdminTablaBonos from './PedidosAdminTablaBonos.vue';
import PedidosAdminTablaPedidos from "./PedidosAdminTablaPedidos.vue"; import PedidosAdminTablaPedidos from "./PedidosAdminTablaPedidos.vue";
import PedidosAdminCaracteristicasOpcionales from "./PedidosAdminCaracteristicasOpcionales.vue";
export default { export default {
name: "PedidosAdminBody", name: "PedidosAdminBody",
components: { components: {
PedidosAdminCaracteristicasOpcionales,
PedidosAdminTabsSecciones, PedidosAdminTabsSecciones,
PedidosAdminDropdownDescargar, PedidosAdminDropdownDescargar,
PedidosAdminTablaPedidos, PedidosAdminTablaPedidos,
@ -47,7 +54,7 @@ export default {
bonosDeTransporte: 0, bonosDeTransporte: 0,
totalBonosBarriales: 0, totalBonosBarriales: 0,
tabActiva: "pedidos", tabActiva: "pedidos",
seccionActiva: "pedidos-seccion" seccionActiva: "pedidos-seccion",
} }
}, },
computed: { computed: {

View file

@ -0,0 +1,45 @@
<script>
import axios from "axios";
import PedidosAdminFilaCaracteristica from "./PedidosAdminFilaCaracteristica.vue";
export default {
name: "PedidosAdminCaracteristicasOpcionales",
components: {PedidosAdminFilaCaracteristica},
data() {
return {
caracteristicas: [
{
id: "devoluciones",
nombre: "Devoluciones",
habilitada: false
},
]
}
},
}
</script>
<template>
<div class="block">
<table class="table is-fullwidth is-striped is-bordered">
<thead>
<tr>
<th> Característica </th>
<th> Habilitada </th>
</tr>
</thead>
<tbody>
<pedidos-admin-fila-caracteristica
v-for="(c,i) in caracteristicas"
:key="i"
:caracteristica="c">
</pedidos-admin-fila-caracteristica>
</tbody>
</table>
</div>
</template>
<style scoped>
</style>

View file

@ -0,0 +1,68 @@
<script>
import axios from "axios";
export default {
name: "PedidosAdminFilaCaracteristica",
props: {
caracteristica: Object
},
data: {
gdc: undefined
},
watch: {
'$root.gdc' : {
handler(newValue) {
if (newValue) {
this.gdc = newValue;
this.obtenerValor();
}
}
},
},
methods: {
toggleActivacion() {
const id = this.caracteristica.id;
axios.post(`/api/grupos-de-compra/${this.gdc}/${id}`)
.then(response => {
this.caracteristica.habilitada = response.data[id];
this.$root[id] = response.data[id];
});
},
obtenerValor() {
const id = this.caracteristica.id;
axios.get(`/api/grupos-de-compra/${this.gdc}/${id}`)
.then(response => {
this.caracteristica.habilitada = response.data[id];
this.$root[id] = response.data[id];
});
},
},
mounted() {
if (this.$root.gdc) {
this.gdc = this.$root.gdc;
this.obtenerValor(this);
}
}
}
</script>
<template>
<tr>
<td>{{ caracteristica.nombre }}</td>
<td>
<div class="field">
<input type="checkbox" class="switch is-rounded is-success"
:id="'switch-'+caracteristica.id"
:checked="caracteristica.habilitada"
@change="toggleActivacion(caracteristica)">
<label :for="'switch-'+caracteristica.id">
<span class="is-hidden-mobile">{{ caracteristica.habilitada ? 'Habilitada' : 'Deshabilitada' }}</span>
</label>
</div>
</td>
</tr>
</template>
<style scoped>
</style>

View file

@ -23,7 +23,7 @@ export default {
}, },
computed: { computed: {
mensaje: function () { mensaje: function () {
return this.aprobado ? "Aprobado" : "No aprobado" return this.aprobado ? "Pagado" : "No pagado"
} }
}, },
methods: { methods: {

View file

@ -7,16 +7,17 @@
<th><abbr title="Total sin tomar en cuenta las devoluciones">Total parcial $</abbr></th> <th><abbr title="Total sin tomar en cuenta las devoluciones">Total parcial $</abbr></th>
<th><abbr title="Devoluciones correspondientes al núcleo">Devoluciones $</abbr></th> <th><abbr title="Devoluciones correspondientes al núcleo">Devoluciones $</abbr></th>
<th><abbr title="Total a Pagar por el núleo">Total real $</abbr></th> <th><abbr title="Total a Pagar por el núleo">Total real $</abbr></th>
<th class="is-1"><abbr title="Aprobacion">Aprobación</abbr></th> <th class="is-1"><abbr title="Pagado">Pagado</abbr></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<pedidos-admin-fila-pedido v-for="pedido in this.pedidos" <pedidos-admin-fila-pedido
v-for="pedido in this.pedidos"
:pedido="pedido" :key="pedido.id"> :pedido="pedido" :key="pedido.id">
</pedidos-admin-fila-pedido> </pedidos-admin-fila-pedido>
</tbody> </tbody>
</table> </table>
<table class="table is-striped is-bordered"> <table v-if="$root.devoluciones" class="table is-striped is-bordered">
<tr> <tr>
<th colspan="2" class="has-background-black has-text-white has-text-centered">TOTALES</th> <th colspan="2" class="has-background-black has-text-white has-text-centered">TOTALES</th>
</tr> </tr>
@ -32,6 +33,10 @@
<th>Total devoluciones:</th> <th>Total devoluciones:</th>
<td class="has-text-right">- $ {{ totalDevoluciones() }}</td> <td class="has-text-right">- $ {{ totalDevoluciones() }}</td>
</tr> </tr>
<tr>
<th>Total bonos de transporte:</th>
<td class="has-text-right">$ {{ bonosDeTransporte * 15 }}</td>
</tr>
<tr> <tr>
<th>Total a depositar:</th> <th>Total a depositar:</th>
<td class="has-text-right">$ {{ totalAprobados() - totalBonosBarriales }}</td> <td class="has-text-right">$ {{ totalAprobados() - totalBonosBarriales }}</td>
@ -62,43 +67,28 @@ export default {
}, },
}, },
methods: { methods: {
totalBonosBarriales() {
let suma = 0;
let aprobados = this.pedidos.filter(p => p.aprobado);
for (let i = 0; i < aprobados.length; i++) {
let bonoBarrial = aprobados[i].productos.find(p => p.nombre.includes("barrial"))
if (bonoBarrial) {
suma += this.$limpiarInt(bonoBarrial.pivot.total)
}
}
return suma;
},
totalDevoluciones() { totalDevoluciones() {
let suma = 0 let suma = 0
let aprobados = this.pedidos.filter(p => p.aprobado); let aprobados = this.pedidos.filter(p => p.aprobado);
for (let i = 0; i < aprobados.length; i++) { for (let i = 0; i < aprobados.length; i++) {
suma = aprobados[i].devoluciones_total suma += aprobados[i].devoluciones_total
} }
suma += parseInt(this.bonosDeTransporte)*15
return suma; return suma;
}, },
totalAprobadosMenosDevoluciones() { totalAprobadosMenosDevoluciones() {
let suma = 0 let suma = 0
let aprobados = this.pedidos.filter(p => p.aprobado); let aprobados = this.pedidos.filter(p => p.aprobado);
for (let i = 0; i < aprobados.length; i++) { for (let i = 0; i < aprobados.length; i++) {
suma += this.$limpiarFloat(aprobados[i].subtotal_bonos) suma += this.$limpiarFloat(aprobados[i].total_menos_devoluciones)
suma += this.$limpiarFloat(aprobados[i].subtotal_productos)
suma -= aprobados[i].devoluciones_total
} }
suma += parseInt(this.bonosDeTransporte)*15
return suma; return suma;
}, },
totalAprobados() { totalAprobados() {
let suma = 0 let suma = 0
let aprobados = this.pedidos.filter(p => p.aprobado); let aprobados = this.pedidos.filter(p => p.aprobado);
for (let i = 0; i < aprobados.length; i++) { for (let i = 0; i < aprobados.length; i++) {
suma += this.$limpiarFloat(aprobados[i].subtotal_bonos) suma += this.$limpiarFloat(aprobados[i].total)
suma += this.$limpiarFloat(aprobados[i].subtotal_productos) suma -= this.$limpiarFloat(aprobados[i].subtotal_bonos_de_transporte)
} }
suma += parseInt(this.bonosDeTransporte)*15 suma += parseInt(this.bonosDeTransporte)*15
return suma; return suma;

View file

@ -31,6 +31,10 @@ export default {
{ {
id: "bonos", id: "bonos",
nombre: "Bonos" nombre: "Bonos"
},
{
id: "caracteristicas",
nombre: "Caracteristicas opcionales"
} }
] ]
} }

View file

@ -79,7 +79,8 @@
}, },
guardarSubpedidoEnSesion(subpedido) { guardarSubpedidoEnSesion(subpedido) {
axios.post("/subpedidos/guardar_sesion", { axios.post("/subpedidos/guardar_sesion", {
subpedido: subpedido subpedido: subpedido,
grupo_de_compra_id: this.gdcid
}).then(_ => { }).then(_ => {
Event.$emit('obtener-sesion') Event.$emit('obtener-sesion')
window.location.href = 'productos'; window.location.href = 'productos';

View file

@ -36,9 +36,13 @@ Route::middleware('api')->group(function () {
$grupo = GrupoDeCompra::where('id',$gdc)->first(); $grupo = GrupoDeCompra::where('id',$gdc)->first();
return ['bonos_barriales' => $grupo->totalBonosBarriales()]; return ['bonos_barriales' => $grupo->totalBonosBarriales()];
}); });
Route::get('/{gdc}/devoluciones-habilitadas', function($gdc) { Route::get('/{gdc}/devoluciones', function($gdc) {
$habilitadas = GrupoDeCompra::where('id',$gdc)->value('devoluciones_habilitadas'); $habilitadas = GrupoDeCompra::find($gdc)->devoluciones_habilitadas;
return ['devoluciones_habilitadas' => $habilitadas]; return ['devoluciones' => $habilitadas];
});
Route::post('/{gdc}/devoluciones', function($gdc) {
$habilitadas = GrupoDeCompra::find($gdc)->toggleDevoluciones();
return ['devoluciones' => $habilitadas];
}); });
}); });

View file

@ -54,8 +54,12 @@ Route::middleware('auth')->group( function() {
if (!isset($r["subpedido"])) { if (!isset($r["subpedido"])) {
throw new HttpException(400, "La request necesita un subpedido para guardar en sesión"); throw new HttpException(400, "La request necesita un subpedido para guardar en sesión");
} }
if (!isset($r["grupo_de_compra_id"])) {
throw new HttpException(400, "La request necesita un grupo de compra para guardar en sesión");
}
session(["subpedido_nombre" => $r["subpedido"]["nombre"]]); session(["subpedido_nombre" => $r["subpedido"]["nombre"]]);
session(["subpedido_id" => $r["subpedido"]["id"]]); session(["subpedido_id" => $r["subpedido"]["id"]]);
session(["gdc" => $r["grupo_de_compra_id"]]);
return "Subpedido guardado en sesión"; return "Subpedido guardado en sesión";
})->name('guardarSesion'); })->name('guardarSesion');
@ -64,7 +68,8 @@ Route::middleware('auth')->group( function() {
'subpedido' => [ 'subpedido' => [
'nombre' => session("subpedido_nombre"), 'nombre' => session("subpedido_nombre"),
'id' => session("subpedido_id") 'id' => session("subpedido_id")
] ],
'gdc' => session("gdc")
]; ];
return $sesion; return $sesion;
})->name('obtenerSesion'); })->name('obtenerSesion');