Compare commits

..

No commits in common. "3941dc0fd29a063f3cc1e6394e968441672c5b64" and "14361a858e085e1ca7c2c4082dfaa6b4a8574596" have entirely different histories.

9 changed files with 27 additions and 112 deletions

View file

@ -89,21 +89,6 @@ class GrupoDeCompra extends Model
return ceil($this->totalPedidosSinBonos() / 500);
}
public function totalBonosBarriales() {
$total = 0;
$bonoBarrial = Producto::where('nombre','LIKE','%barrial%')->first();
if ($bonoBarrial) {
$pedidos = $this->pedidosAprobados();
foreach ($pedidos as $pedido) {
$bonoPedido = $pedido->productos()->find($bonoBarrial["id"]);
if ($bonoPedido) {
$total += $bonoPedido["pivot"]["total"];
}
}
}
return $total;
}
public function exportarPedidoEnCSV(){
$productos_en_pedido = DB::table('pedidos_aprobados')->where('grupo_de_compra_id',$this->id)->get()->keyBy('producto_id');

View file

@ -22,7 +22,6 @@ class SubpedidoResource extends JsonResource
'bonos_de_transporte' => $this->cantidadBDT(),
'subtotal_bonos_de_transporte' => number_format($this->getSubtotalBDT(),0),
'total' => number_format($this->getTotal(),0),
'total_menos_devoluciones' => number_format($this->getTotalMenosDevoluciones(),0),
'grupo_de_compra' => $this->grupoDeCompra,
'productos' => $this->productos,
'aprobado' => (bool) $this->aprobado,

View file

@ -66,11 +66,7 @@ class Subpedido extends Model
public function getTotal()
{
return $this->totalSinBonos() + $this->getSubtotalBDT() + $this->getSubtotalBonos();
}
public function getTotalMenosDevoluciones() {
return $this->getTotal() - $this->getDevoluciones();
return $this->totalSinBonos() + $this->getSubtotalBDT() + $this->getSubtotalBonos() - $this->getDevoluciones();
}
//Actualiza el pedido, agregando o quitando del subpedido según sea necesario. Debe ser llamado desde el controlador de subpedidos, luego de validar que los parámetros $producto y $cantidad son correctos. También calcula el subtotal por producto.

View file

@ -75,7 +75,7 @@
return this.$limpiarInt(this.$root.pedido.subtotal_bonos)
},
total: function() {
return this.$limpiarInt(this.$root.pedido.total_menos_devoluciones)
return this.$limpiarInt(this.$root.pedido.total)
}
},
methods: {

View file

@ -1,21 +1,21 @@
<template>
<div class="container is-max-widescreen is-max-desktop">
<div class="container is-max-widescreen is-max-desktop animate__animated" :class="animation">
<pedidos-admin-tabs-secciones></pedidos-admin-tabs-secciones>
<div class="block" id="pedidos-seccion"
:class="seccionActiva === 'pedidos-seccion' ? 'is-active' : 'is-hidden'">
<div class="block pb-6" id="pedidos-tabla-y-dropdown" v-show="hayPedidos">
<div class="block" id="pedidos-tabla-y-dropdown" v-show="hayPedidos">
<pedidos-admin-dropdown-descargar
:gdc="gdc">
</pedidos-admin-dropdown-descargar>
<pedidos-admin-tabla-pedidos
:pedidos="pedidos" :bonosDeTransporte="bonosDeTransporte" :totalBonosBarriales="totalBonosBarriales">
:pedidos="pedidos" :bonosDeTransporte="bonosDeTransporte">
</pedidos-admin-tabla-pedidos>
</div>
<p class="has-text-centered" v-show="!hayPedidos">
Todavía no hay ningún pedido para administrar.
</p>
</div>
<div class="block pb-6" id="bonos-seccion"
<div class="block" id="bonos-seccion"
:class="seccionActiva === 'bonos-seccion' ? 'is-active' : 'is-hidden'">
<pedidos-admin-tabla-bonos v-show="hayAprobados"
:pedidos="pedidos">
@ -45,7 +45,6 @@ export default {
gdc: 0,
pedidos: [],
bonosDeTransporte: 0,
totalBonosBarriales: 0,
tabActiva: "pedidos",
seccionActiva: "pedidos-seccion"
}
@ -73,10 +72,6 @@ export default {
setSeccionActiva(tabId) {
this.tabActiva = tabId;
this.seccionActiva = tabId + "-seccion";
},
getBonosBarriales() {
axios.get("/api/grupos-de-compra/"+this.gdc+"/bonos-barriales", {})
.then(response => this.totalBonosBarriales = response.data.bonos_barriales)
}
},
mounted() {
@ -87,7 +82,6 @@ export default {
axios.get("/admin/obtener_sesion").then(response => {
this.gdc = response.data.gdc;
this.fetchPedidos();
this.bonosBarriales = this.getBonosBarriales()
});
}
}

View file

@ -2,8 +2,6 @@
<tr>
<td>{{ pedido.nombre }}</td>
<td class="has-text-right" >{{ this.$limpiarInt(pedido.total) }}</td>
<td class="has-text-right" >-{{ pedido.devoluciones_total }}</td>
<td class="has-text-right" >{{ pedido.total_menos_devoluciones }}</td>
<td>
<pedidos-admin-switch-aprobacion
:pedido="pedido">

View file

@ -19,7 +19,7 @@
<tbody>
<tr v-for="(bp, i) in bonosPorPedido" :key="i">
<td> {{ bp.nucleo }} </td>
<td v-for="(bono,j) in bp.bonos" :key="j" class="has-text-right">
<td v-for="(bono,j) in bp.bonos" :key="j">
{{ bono.cantidad }}
</td>
<td class="has-text-right"> {{ bp.total }} </td>

View file

@ -1,43 +1,25 @@
<template>
<div>
<table class="table is-fullwidth is-striped is-bordered">
<thead>
<tr>
<th>Núcleo</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="Total a Pagar por el núleo">Total real $</abbr></th>
<th><abbr title="Total a Pagar">Total $</abbr></th>
<th class="is-1"><abbr title="Aprobacion">Aprobación</abbr></th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>Total de los aprobados</th>
<th>$ {{ totalAprobados() }}</th>
</tr>
</tfoot>
<tbody>
<pedidos-admin-fila-pedido v-for="pedido in this.pedidos"
:pedido="pedido" :key="pedido.id">
</pedidos-admin-fila-pedido>
</tbody>
</table>
<table class="table is-striped is-bordered">
<tr>
<th colspan="2" class="has-background-black has-text-white has-text-centered">TOTALES</th>
</tr>
<tr>
<th>Total a recaudar:</th>
<td class="has-text-right">$ {{ totalAprobadosMenosDevoluciones() }}</td>
</tr>
<tr v-if="totalBonosBarriales > 0">
<th>Total bonos barriales:</th>
<td class="has-text-right">$ {{ totalBonosBarriales }}</td>
</tr>
<tr v-if="totalDevoluciones() > 0">
<th>Total devoluciones:</th>
<td class="has-text-right">- $ {{ totalDevoluciones() }}</td>
</tr>
<tr>
<th>Total a depositar:</th>
<td class="has-text-right">$ {{ totalAprobados() - totalBonosBarriales }}</td>
</tr>
</table>
</div>
</template>
<script>
@ -56,45 +38,10 @@ export default {
type: Number,
required: true
},
totalBonosBarriales: {
type: Number,
required: true
},
},
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() {
let suma = 0
let aprobados = this.pedidos.filter(p => p.aprobado);
for (let i = 0; i < aprobados.length; i++) {
suma = aprobados[i].devoluciones_total
}
suma += parseInt(this.bonosDeTransporte)*15
return suma;
},
totalAprobadosMenosDevoluciones() {
let suma = 0
let aprobados = this.pedidos.filter(p => p.aprobado);
for (let i = 0; i < aprobados.length; i++) {
suma += this.$limpiarFloat(aprobados[i].subtotal_bonos)
suma += this.$limpiarFloat(aprobados[i].subtotal_productos)
suma -= aprobados[i].devoluciones_total
}
suma += parseInt(this.bonosDeTransporte)*15
return suma;
},
totalAprobados() {
let suma = 0
let suma = 0;
let aprobados = this.pedidos.filter(p => p.aprobado);
for (let i = 0; i < aprobados.length; i++) {
suma += this.$limpiarFloat(aprobados[i].subtotal_bonos)

View file

@ -32,10 +32,6 @@ Route::middleware('api')->group(function () {
$grupo = GrupoDeCompra::where('id',$gdc)->first();
return ['bdt' => $grupo->calcularCantidadBDT()];
});
Route::get('/{gdc}/bonos-barriales', function($gdc) {
$grupo = GrupoDeCompra::where('id',$gdc)->first();
return ['bonos_barriales' => $grupo->totalBonosBarriales()];
});
});
Route::prefix('subpedidos')->group(function () {