Compare commits
4 commits
14361a858e
...
3941dc0fd2
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3941dc0fd2 | ||
![]() |
1a8448ca45 | ||
9954dbd66a | |||
8f8733cb7b |
9 changed files with 112 additions and 27 deletions
|
@ -89,6 +89,21 @@ class GrupoDeCompra extends Model
|
||||||
return ceil($this->totalPedidosSinBonos() / 500);
|
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(){
|
public function exportarPedidoEnCSV(){
|
||||||
$productos_en_pedido = DB::table('pedidos_aprobados')->where('grupo_de_compra_id',$this->id)->get()->keyBy('producto_id');
|
$productos_en_pedido = DB::table('pedidos_aprobados')->where('grupo_de_compra_id',$this->id)->get()->keyBy('producto_id');
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ class SubpedidoResource extends JsonResource
|
||||||
'bonos_de_transporte' => $this->cantidadBDT(),
|
'bonos_de_transporte' => $this->cantidadBDT(),
|
||||||
'subtotal_bonos_de_transporte' => number_format($this->getSubtotalBDT(),0),
|
'subtotal_bonos_de_transporte' => number_format($this->getSubtotalBDT(),0),
|
||||||
'total' => number_format($this->getTotal(),0),
|
'total' => number_format($this->getTotal(),0),
|
||||||
|
'total_menos_devoluciones' => number_format($this->getTotalMenosDevoluciones(),0),
|
||||||
'grupo_de_compra' => $this->grupoDeCompra,
|
'grupo_de_compra' => $this->grupoDeCompra,
|
||||||
'productos' => $this->productos,
|
'productos' => $this->productos,
|
||||||
'aprobado' => (bool) $this->aprobado,
|
'aprobado' => (bool) $this->aprobado,
|
||||||
|
|
|
@ -66,7 +66,11 @@ class Subpedido extends Model
|
||||||
|
|
||||||
public function getTotal()
|
public function getTotal()
|
||||||
{
|
{
|
||||||
return $this->totalSinBonos() + $this->getSubtotalBDT() + $this->getSubtotalBonos() - $this->getDevoluciones();
|
return $this->totalSinBonos() + $this->getSubtotalBDT() + $this->getSubtotalBonos();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTotalMenosDevoluciones() {
|
||||||
|
return $this->getTotal() - $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.
|
//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.
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
return this.$limpiarInt(this.$root.pedido.subtotal_bonos)
|
return this.$limpiarInt(this.$root.pedido.subtotal_bonos)
|
||||||
},
|
},
|
||||||
total: function() {
|
total: function() {
|
||||||
return this.$limpiarInt(this.$root.pedido.total)
|
return this.$limpiarInt(this.$root.pedido.total_menos_devoluciones)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="container is-max-widescreen is-max-desktop animate__animated" :class="animation">
|
<div class="container is-max-widescreen is-max-desktop">
|
||||||
<pedidos-admin-tabs-secciones></pedidos-admin-tabs-secciones>
|
<pedidos-admin-tabs-secciones></pedidos-admin-tabs-secciones>
|
||||||
<div class="block" id="pedidos-seccion"
|
<div class="block" id="pedidos-seccion"
|
||||||
:class="seccionActiva === 'pedidos-seccion' ? 'is-active' : 'is-hidden'">
|
:class="seccionActiva === 'pedidos-seccion' ? 'is-active' : 'is-hidden'">
|
||||||
<div class="block" id="pedidos-tabla-y-dropdown" v-show="hayPedidos">
|
<div class="block pb-6" id="pedidos-tabla-y-dropdown" v-show="hayPedidos">
|
||||||
<pedidos-admin-dropdown-descargar
|
<pedidos-admin-dropdown-descargar
|
||||||
:gdc="gdc">
|
:gdc="gdc">
|
||||||
</pedidos-admin-dropdown-descargar>
|
</pedidos-admin-dropdown-descargar>
|
||||||
<pedidos-admin-tabla-pedidos
|
<pedidos-admin-tabla-pedidos
|
||||||
:pedidos="pedidos" :bonosDeTransporte="bonosDeTransporte">
|
:pedidos="pedidos" :bonosDeTransporte="bonosDeTransporte" :totalBonosBarriales="totalBonosBarriales">
|
||||||
</pedidos-admin-tabla-pedidos>
|
</pedidos-admin-tabla-pedidos>
|
||||||
</div>
|
</div>
|
||||||
<p class="has-text-centered" v-show="!hayPedidos">
|
<p class="has-text-centered" v-show="!hayPedidos">
|
||||||
Todavía no hay ningún pedido para administrar.
|
Todavía no hay ningún pedido para administrar.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="block" id="bonos-seccion"
|
<div class="block pb-6" id="bonos-seccion"
|
||||||
:class="seccionActiva === 'bonos-seccion' ? 'is-active' : 'is-hidden'">
|
:class="seccionActiva === 'bonos-seccion' ? 'is-active' : 'is-hidden'">
|
||||||
<pedidos-admin-tabla-bonos v-show="hayAprobados"
|
<pedidos-admin-tabla-bonos v-show="hayAprobados"
|
||||||
:pedidos="pedidos">
|
:pedidos="pedidos">
|
||||||
|
@ -45,6 +45,7 @@ export default {
|
||||||
gdc: 0,
|
gdc: 0,
|
||||||
pedidos: [],
|
pedidos: [],
|
||||||
bonosDeTransporte: 0,
|
bonosDeTransporte: 0,
|
||||||
|
totalBonosBarriales: 0,
|
||||||
tabActiva: "pedidos",
|
tabActiva: "pedidos",
|
||||||
seccionActiva: "pedidos-seccion"
|
seccionActiva: "pedidos-seccion"
|
||||||
}
|
}
|
||||||
|
@ -72,6 +73,10 @@ export default {
|
||||||
setSeccionActiva(tabId) {
|
setSeccionActiva(tabId) {
|
||||||
this.tabActiva = tabId;
|
this.tabActiva = tabId;
|
||||||
this.seccionActiva = tabId + "-seccion";
|
this.seccionActiva = tabId + "-seccion";
|
||||||
|
},
|
||||||
|
getBonosBarriales() {
|
||||||
|
axios.get("/api/grupos-de-compra/"+this.gdc+"/bonos-barriales", {})
|
||||||
|
.then(response => this.totalBonosBarriales = response.data.bonos_barriales)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -82,6 +87,7 @@ export default {
|
||||||
axios.get("/admin/obtener_sesion").then(response => {
|
axios.get("/admin/obtener_sesion").then(response => {
|
||||||
this.gdc = response.data.gdc;
|
this.gdc = response.data.gdc;
|
||||||
this.fetchPedidos();
|
this.fetchPedidos();
|
||||||
|
this.bonosBarriales = this.getBonosBarriales()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ pedido.nombre }}</td>
|
<td>{{ pedido.nombre }}</td>
|
||||||
<td class="has-text-right" >{{ this.$limpiarInt(pedido.total) }}</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>
|
<td>
|
||||||
<pedidos-admin-switch-aprobacion
|
<pedidos-admin-switch-aprobacion
|
||||||
:pedido="pedido">
|
:pedido="pedido">
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(bp, i) in bonosPorPedido" :key="i">
|
<tr v-for="(bp, i) in bonosPorPedido" :key="i">
|
||||||
<td> {{ bp.nucleo }} </td>
|
<td> {{ bp.nucleo }} </td>
|
||||||
<td v-for="(bono,j) in bp.bonos" :key="j">
|
<td v-for="(bono,j) in bp.bonos" :key="j" class="has-text-right">
|
||||||
{{ bono.cantidad }}
|
{{ bono.cantidad }}
|
||||||
</td>
|
</td>
|
||||||
<td class="has-text-right"> {{ bp.total }} </td>
|
<td class="has-text-right"> {{ bp.total }} </td>
|
||||||
|
|
|
@ -1,25 +1,43 @@
|
||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
<table class="table is-fullwidth is-striped is-bordered">
|
<table class="table is-fullwidth is-striped is-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Núcleo</th>
|
<th>Núcleo</th>
|
||||||
<th><abbr title="Total a Pagar">Total $</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="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="Aprobacion">Aprobación</abbr></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th></th>
|
|
||||||
<th>Total de los aprobados</th>
|
|
||||||
<th>$ {{ totalAprobados() }}</th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
<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">
|
||||||
|
<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>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -38,11 +56,46 @@ export default {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
totalBonosBarriales: {
|
||||||
|
type: Number,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
totalAprobados() {
|
totalBonosBarriales() {
|
||||||
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++) {
|
||||||
|
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 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].subtotal_bonos)
|
||||||
suma += this.$limpiarFloat(aprobados[i].subtotal_productos)
|
suma += this.$limpiarFloat(aprobados[i].subtotal_productos)
|
||||||
|
|
|
@ -32,6 +32,10 @@ Route::middleware('api')->group(function () {
|
||||||
$grupo = GrupoDeCompra::where('id',$gdc)->first();
|
$grupo = GrupoDeCompra::where('id',$gdc)->first();
|
||||||
return ['bdt' => $grupo->calcularCantidadBDT()];
|
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 () {
|
Route::prefix('subpedidos')->group(function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue