Agregado total sin devoluciones a resource de grupo de compra
This commit is contained in:
parent
d0ce8e8e23
commit
439f69a30c
4 changed files with 16 additions and 4 deletions
|
@ -43,6 +43,14 @@ class GrupoDeCompra extends Model
|
||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function totalSinDevoluciones() {
|
||||||
|
$total = 0;
|
||||||
|
foreach ($this->pedidosAprobados() as $subpedido) {
|
||||||
|
$total = $total + $subpedido->totalSinDevoluciones();
|
||||||
|
}
|
||||||
|
return $total;
|
||||||
|
}
|
||||||
|
|
||||||
public function totalBarrial()
|
public function totalBarrial()
|
||||||
{
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
|
|
|
@ -21,6 +21,7 @@ class GrupoDeCompraResource extends JsonResource
|
||||||
'devoluciones_habilitadas' => $this->devoluciones_habilitadas,
|
'devoluciones_habilitadas' => $this->devoluciones_habilitadas,
|
||||||
'pedidos' => SubpedidoResource::collection($this->subpedidos),
|
'pedidos' => SubpedidoResource::collection($this->subpedidos),
|
||||||
'total_a_recaudar' => number_format($this->totalARecaudar(),2),
|
'total_a_recaudar' => number_format($this->totalARecaudar(),2),
|
||||||
|
'total_sin_devoluciones' => number_format($this->totalSinDevoluciones(),2),
|
||||||
'total_barrial' => number_format($this->totalBarrial(),2),
|
'total_barrial' => number_format($this->totalBarrial(),2),
|
||||||
'total_devoluciones' => number_format($this->totalDevoluciones(),2),
|
'total_devoluciones' => number_format($this->totalDevoluciones(),2),
|
||||||
'total_a_transferir' => number_format($this->totalATransferir(),2),
|
'total_a_transferir' => number_format($this->totalATransferir(),2),
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Total a recaudar:</th>
|
<th>Total a recaudar:</th>
|
||||||
<td class="has-text-right">$ {{ total_a_recaudar }}</td>
|
<td class="has-text-right">$ {{ devoluciones_habilitadas ? total_a_recaudar : total_sin_devoluciones }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Total bonos barriales:</th>
|
<th>Total bonos barriales:</th>
|
||||||
|
@ -62,6 +62,7 @@ export default {
|
||||||
"devoluciones_habilitadas",
|
"devoluciones_habilitadas",
|
||||||
"pedidos",
|
"pedidos",
|
||||||
"total_a_recaudar",
|
"total_a_recaudar",
|
||||||
|
"total_sin_devoluciones",
|
||||||
"total_barrial",
|
"total_barrial",
|
||||||
"total_devoluciones",
|
"total_devoluciones",
|
||||||
"cantidad_transporte",
|
"cantidad_transporte",
|
||||||
|
|
8
resources/js/store/modules/admin.js
vendored
8
resources/js/store/modules/admin.js
vendored
|
@ -7,6 +7,7 @@ const state = {
|
||||||
devoluciones_habilitadas: null,
|
devoluciones_habilitadas: null,
|
||||||
pedidos: null,
|
pedidos: null,
|
||||||
total_a_recaudar: null,
|
total_a_recaudar: null,
|
||||||
|
total_sin_devoluciones: null,
|
||||||
total_barrial: null,
|
total_barrial: null,
|
||||||
total_devoluciones: null,
|
total_devoluciones: null,
|
||||||
total_a_transferir: null,
|
total_a_transferir: null,
|
||||||
|
@ -22,6 +23,7 @@ const mutations = {
|
||||||
state.devoluciones_habilitadas = grupo_de_compra.devoluciones_habilitadas;
|
state.devoluciones_habilitadas = grupo_de_compra.devoluciones_habilitadas;
|
||||||
state.pedidos = grupo_de_compra.pedidos;
|
state.pedidos = grupo_de_compra.pedidos;
|
||||||
state.total_a_recaudar = grupo_de_compra.total_a_recaudar;
|
state.total_a_recaudar = grupo_de_compra.total_a_recaudar;
|
||||||
|
state.total_sin_devoluciones = grupo_de_compra.total_sin_devoluciones;
|
||||||
state.total_barrial = grupo_de_compra.total_barrial;
|
state.total_barrial = grupo_de_compra.total_barrial;
|
||||||
state.total_devoluciones = grupo_de_compra.total_devoluciones;
|
state.total_devoluciones = grupo_de_compra.total_devoluciones;
|
||||||
state.total_a_transferir = grupo_de_compra.total_a_transferir;
|
state.total_a_transferir = grupo_de_compra.total_a_transferir;
|
||||||
|
@ -56,16 +58,16 @@ const getters = {
|
||||||
return state.lastFetch !== null;
|
return state.lastFetch !== null;
|
||||||
},
|
},
|
||||||
hayPedidos() {
|
hayPedidos() {
|
||||||
return getters.grupoDeCompraDefinido() && state.pedidos.length > 0;
|
return state.pedidos?.length > 0;
|
||||||
},
|
},
|
||||||
pedidosAprobados() {
|
pedidosAprobados() {
|
||||||
return getters.grupoDeCompraDefinido() ? state.pedidos.filter(p => p.aprobado) : [];
|
return state.pedidos?.filter(p => p.aprobado) ?? [];
|
||||||
},
|
},
|
||||||
hayAprobados() {
|
hayAprobados() {
|
||||||
return getters.pedidosAprobados().length !== 0;
|
return getters.pedidosAprobados().length !== 0;
|
||||||
},
|
},
|
||||||
getPedido() {
|
getPedido() {
|
||||||
return (pedido_id) => state.pedidos.find(p => p.id === pedido_id);
|
return (pedido_id) => state.pedidos?.find(p => p.id === pedido_id);
|
||||||
},
|
},
|
||||||
getCaracteristica() {
|
getCaracteristica() {
|
||||||
return (caracteristica) => state[`${caracteristica}_habilitadas`];
|
return (caracteristica) => state[`${caracteristica}_habilitadas`];
|
||||||
|
|
Loading…
Add table
Reference in a new issue