Compare commits
20 commits
71a6e496e9
...
ca4dd862d0
| Author | SHA1 | Date | |
|---|---|---|---|
| ca4dd862d0 | |||
| deea20904b | |||
| a6f726f8a0 | |||
| 5f847dc9af | |||
| 7c368c3d24 | |||
| 88deb88f04 | |||
| a34bfd53a8 | |||
| 3e1c61da68 | |||
| e370ce2a0d | |||
| d7710c306b | |||
| 97fb03f299 | |||
| e8b5936233 | |||
| d7cef79a50 | |||
| f155f0d824 | |||
| 38ff38fb05 | |||
| 45c8fc1af0 | |||
| f521c726ef | |||
| 59af3693cb | |||
| e69c379304 | |||
| f008b9e263 |
15 changed files with 193 additions and 118 deletions
|
|
@ -127,21 +127,33 @@ class SubpedidoController extends Controller
|
||||||
*/
|
*/
|
||||||
public function syncFaltantesYSobrantes(Subpedido $subpedido): SubpedidoResource
|
public function syncFaltantesYSobrantes(Subpedido $subpedido): SubpedidoResource
|
||||||
{
|
{
|
||||||
$producto_id = request()->producto_id;
|
|
||||||
$producto = Producto::find($producto_id);
|
|
||||||
if (!$producto) {
|
|
||||||
throw new HttpException(400, "No se encontro el producto.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$cantidad = -1*($subpedido->productos()->find($producto_id)?->cantidad ?? 0);
|
|
||||||
|
|
||||||
$valid = request()->validate([
|
$valid = request()->validate([
|
||||||
'cantidad' => ['integer', 'required', 'min:' . $cantidad],
|
'cantidad' => ['integer', 'required'],
|
||||||
'producto_id' => ['required']
|
'producto_id' => [
|
||||||
|
'required',
|
||||||
|
Rule::in(Producto::all()->pluck('id')),
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$producto = Producto::find($valid['producto_id']);
|
||||||
|
if ($producto->bono)
|
||||||
|
abort(400, "No te puede haber faltado un bono");
|
||||||
|
|
||||||
$cantidad = $valid['cantidad'];
|
$cantidad = $valid['cantidad'];
|
||||||
$subpedido->syncProducto($producto, $cantidad, null);
|
if ($cantidad < 0) { // caso faltantes
|
||||||
|
$barrio = GrupoDeCompra::find($subpedido->grupo_de_compra_id);
|
||||||
|
$productosPedidos = $barrio->productosPedidos(true);
|
||||||
|
|
||||||
|
$productoPedido = $productosPedidos->where('producto_id', $producto->id)->first();
|
||||||
|
if (!$productoPedido)
|
||||||
|
abort(400, "No te puede faltar algo que no pediste.");
|
||||||
|
|
||||||
|
$cantidadPedida = intval($productoPedido->cantidad_pedida);
|
||||||
|
if ($cantidadPedida + $cantidad < 0)
|
||||||
|
abort(400, 'No te puede faltar más de lo que pediste');
|
||||||
|
}
|
||||||
|
|
||||||
|
$subpedido->syncProducto($producto, $cantidad);
|
||||||
return new SubpedidoResource($subpedido);
|
return new SubpedidoResource($subpedido);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,10 @@ namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\GrupoDeCompra;
|
use App\GrupoDeCompra;
|
||||||
use App\Http\Resources\PedidoFaltantesYSobrantesResource;
|
use App\Http\Resources\PedidoFaltantesYSobrantesResource;
|
||||||
use App\Http\Resources\PedidoOllasResource;
|
|
||||||
use App\TipoPedido;
|
use App\TipoPedido;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class FaltantesYSobrantesController extends Controller
|
class FaltantesYSobrantesController extends Controller
|
||||||
{
|
{
|
||||||
public function show()
|
|
||||||
{
|
|
||||||
return view('auth/login');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function pedido(GrupoDeCompra $gdc)
|
public function pedido(GrupoDeCompra $gdc)
|
||||||
{
|
{
|
||||||
$tipoFaltantesYSobrantes = TipoPedido::firstOrCreate(['nombre' => 'faltantes_y_sobrantes']);
|
$tipoFaltantesYSobrantes = TipoPedido::firstOrCreate(['nombre' => 'faltantes_y_sobrantes']);
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Resources;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
|
|
||||||
class GrupoDeCompraFaltantesYSobrantesResource extends JsonResource
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function toArray(Request $request): array
|
|
||||||
{
|
|
||||||
$productos_cantidades = [];
|
|
||||||
$productosPedidos = $this->productosPedidos();
|
|
||||||
foreach ($productosPedidos as $productoPedido) {
|
|
||||||
$productos_cantidades[$productoPedido->producto_id] = $productoPedido->cantidad_pedida;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'id' => $this->id,
|
|
||||||
'nombre' => $this->nombre,
|
|
||||||
'productos_cantidades' => $productos_cantidades,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -109,7 +109,7 @@ class Subpedido extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
public function syncProducto(Producto $producto, int $cantidad, string $notas)
|
public function syncProducto(Producto $producto, int $cantidad, string $notas = "")
|
||||||
{
|
{
|
||||||
if ($cantidad) {
|
if ($cantidad) {
|
||||||
//si la cantidad es 1 o más se agrega el producto o actualiza la cantidad
|
//si la cantidad es 1 o más se agrega el producto o actualiza la cantidad
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,30 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="block ml-3 mr-3 is-max-widescreen is-max-desktop">
|
<div>
|
||||||
<tabs-secciones :tabs="tabs" :tabInicial="tabActiva"/>
|
<pedidos-main v-if="show_faltantes_y_sobrantes"/>
|
||||||
<div class="block" id="pedidos-seccion"
|
<div class="block ml-3 mr-3 is-max-widescreen is-max-desktop" v-else>
|
||||||
:class="seccionActiva === 'pedidos-seccion' ? 'is-active' : 'is-hidden'">
|
<tabs-secciones :tabs="tabs" :tabInicial="tabActiva"/>
|
||||||
<div class="block pb-6" id="pedidos-tabla-y-dropdown" v-if="hayPedidos">
|
<div class="block" id="pedidos-seccion"
|
||||||
<dropdown-descargar/>
|
:class="seccionActiva === 'pedidos-seccion' ? 'is-active' : 'is-hidden'">
|
||||||
<tabla-pedidos/>
|
<div class="block pb-6" id="pedidos-tabla-y-dropdown" v-if="hayPedidos">
|
||||||
|
<div class="is-flex is-justify-content-space-between mb-3">
|
||||||
|
<button class="button is-danger" @click="abrirFaltantesYSobrantes">
|
||||||
|
<span class="icon">
|
||||||
|
<i class="fa fa-refresh"></i>
|
||||||
|
</span>
|
||||||
|
<span>Faltantes y Sobrantes</span>
|
||||||
|
</button>
|
||||||
|
<dropdown-descargar/>
|
||||||
|
</div>
|
||||||
|
<tabla-pedidos/>
|
||||||
|
</div>
|
||||||
|
<p class="has-text-centered" v-else>
|
||||||
|
Todavía no hay ningún pedido para administrar.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="block pb-6" id="caracteristicas-seccion"
|
||||||
|
:class="seccionActiva === 'caracteristicas-seccion' ? 'is-active' : 'is-hidden'">
|
||||||
|
<caracteristicas-opcionales/>
|
||||||
</div>
|
</div>
|
||||||
<p class="has-text-centered" v-else>
|
|
||||||
Todavía no hay ningún pedido para administrar.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="block pb-6" id="caracteristicas-seccion"
|
|
||||||
:class="seccionActiva === 'caracteristicas-seccion' ? 'is-active' : 'is-hidden'">
|
|
||||||
<caracteristicas-opcionales/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -23,10 +34,14 @@ import CaracteristicasOpcionales from "./CaracteristicasOpcionales.vue";
|
||||||
import TabsSecciones from "../comunes/TabsSecciones.vue";
|
import TabsSecciones from "../comunes/TabsSecciones.vue";
|
||||||
import DropdownDescargar from "./DropdownDescargar.vue";
|
import DropdownDescargar from "./DropdownDescargar.vue";
|
||||||
import TablaPedidos from "./TablaPedidos.vue";
|
import TablaPedidos from "./TablaPedidos.vue";
|
||||||
import { mapActions, mapGetters } from "vuex";
|
import { mapActions, mapGetters, mapMutations, mapState } from "vuex";
|
||||||
|
import Canasta from "../pedidos/Canasta.vue";
|
||||||
|
import PedidosMain from "../pedidos/PedidosMain.vue";
|
||||||
export default {
|
export default {
|
||||||
name: "AdminBody",
|
name: "AdminBody",
|
||||||
components: {
|
components: {
|
||||||
|
PedidosMain,
|
||||||
|
Canasta,
|
||||||
CaracteristicasOpcionales,
|
CaracteristicasOpcionales,
|
||||||
TabsSecciones,
|
TabsSecciones,
|
||||||
DropdownDescargar,
|
DropdownDescargar,
|
||||||
|
|
@ -42,9 +57,12 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters('admin', ['hayPedidos']),
|
...mapGetters('admin', ['hayPedidos']),
|
||||||
|
...mapState('ui', ['show_faltantes_y_sobrantes'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('admin', ['getGrupoDeCompra']),
|
...mapActions('admin', ['getGrupoDeCompra', 'abrirFaltantesYSobrantes']),
|
||||||
|
...mapActions('ui', ['toast']),
|
||||||
|
...mapMutations('ui', ['toggleFaltantesYSobrantes']),
|
||||||
setSeccionActiva(tabId) {
|
setSeccionActiva(tabId) {
|
||||||
this.tabActiva = tabId;
|
this.tabActiva = tabId;
|
||||||
this.seccionActiva = tabId + "-seccion";
|
this.seccionActiva = tabId + "-seccion";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,11 @@
|
||||||
<div class="buttons is-right">
|
<div class="buttons is-right">
|
||||||
<div class="dropdown" :class="{'is-active': dropdownActivo}" @mouseleave="dropdownActivo = false">
|
<div class="dropdown" :class="{'is-active': dropdownActivo}" @mouseleave="dropdownActivo = false">
|
||||||
<div class="dropdown-trigger">
|
<div class="dropdown-trigger">
|
||||||
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu" :disabled="!hayAprobados" @click="dropdownActivo = !dropdownActivo">
|
<button class="button"
|
||||||
|
aria-haspopup="true"
|
||||||
|
aria-controls="dropdown-menu"
|
||||||
|
:disabled="!hayAprobados"
|
||||||
|
@click="dropdownActivo = !dropdownActivo">
|
||||||
<span class="icon is-small">
|
<span class="icon is-small">
|
||||||
<i class="fas fa-download"></i>
|
<i class="fas fa-download"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -18,71 +18,25 @@
|
||||||
/>
|
/>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table class="table is-striped is-bordered">
|
<tabla-totales/>
|
||||||
<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">$ {{ devoluciones_habilitadas ? total_a_recaudar : total_sin_devoluciones }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Total bonos barriales:</th>
|
|
||||||
<td class="has-text-right">$ {{ total_barrial }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-if="devoluciones_habilitadas">
|
|
||||||
<th>Total devoluciones:</th>
|
|
||||||
<td class="has-text-right">- $ {{ total_devoluciones }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Cantidad bonos de transporte:</th>
|
|
||||||
<td class="has-text-right">{{ cantidad_transporte }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Total bonos de transporte:</th>
|
|
||||||
<td class="has-text-right">$ {{ total_transporte }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Total de pedido:</th>
|
|
||||||
<td class="has-text-right">$ {{ total_de_pedido }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>{{ texto_saldo }}</th>
|
|
||||||
<td class="has-text-right"> $ {{ saldo }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>Total a transferir:</th>
|
|
||||||
<td class="has-text-right">$ {{ total_a_transferir }}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import FilaPedido from "./FilaPedido.vue";
|
import FilaPedido from "./FilaPedido.vue";
|
||||||
import { mapGetters, mapState } from "vuex";
|
import { mapGetters, mapState } from "vuex";
|
||||||
|
import TablaTotales from "./TablaTotales.vue";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
TablaTotales,
|
||||||
FilaPedido
|
FilaPedido
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('admin', [
|
...mapState('admin', [
|
||||||
"devoluciones_habilitadas",
|
"devoluciones_habilitadas",
|
||||||
"pedidos",
|
"pedidos",
|
||||||
"total_a_recaudar",
|
|
||||||
"total_sin_devoluciones",
|
|
||||||
"total_barrial",
|
|
||||||
"total_devoluciones",
|
|
||||||
"cantidad_transporte",
|
|
||||||
"total_transporte",
|
|
||||||
"total_de_pedido",
|
|
||||||
"total_a_transferir",
|
|
||||||
"saldo",
|
|
||||||
]),
|
]),
|
||||||
...mapGetters('admin', ['pedidosAprobados']),
|
...mapGetters('admin', ['pedidosAprobados']),
|
||||||
texto_saldo() {
|
|
||||||
return this.saldo < 0 ? "Deuda:" : "Saldo a favor:";
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
69
resources/js/components/admin/TablaTotales.vue
Normal file
69
resources/js/components/admin/TablaTotales.vue
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
<script>
|
||||||
|
import { mapGetters, mapState } from "vuex";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'TablaTotales',
|
||||||
|
computed: {
|
||||||
|
...mapState('admin', [
|
||||||
|
"devoluciones_habilitadas",
|
||||||
|
"total_a_recaudar",
|
||||||
|
"total_sin_devoluciones",
|
||||||
|
"total_barrial",
|
||||||
|
"total_devoluciones",
|
||||||
|
"cantidad_transporte",
|
||||||
|
"total_transporte",
|
||||||
|
"total_de_pedido",
|
||||||
|
"total_a_transferir",
|
||||||
|
"saldo",
|
||||||
|
]),
|
||||||
|
...mapGetters('admin', ['pedidosAprobados']),
|
||||||
|
texto_saldo() {
|
||||||
|
return this.saldo < 0 ? "Deuda:" : "Saldo a favor:";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<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">$ {{ devoluciones_habilitadas ? total_a_recaudar : total_sin_devoluciones }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Total bonos barriales:</th>
|
||||||
|
<td class="has-text-right">$ {{ total_barrial }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-if="devoluciones_habilitadas">
|
||||||
|
<th>Total devoluciones:</th>
|
||||||
|
<td class="has-text-right">- $ {{ total_devoluciones }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Cantidad bonos de transporte:</th>
|
||||||
|
<td class="has-text-right">{{ cantidad_transporte }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Total bonos de transporte:</th>
|
||||||
|
<td class="has-text-right">$ {{ total_transporte }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Total de pedido:</th>
|
||||||
|
<td class="has-text-right">$ {{ total_de_pedido }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>{{ texto_saldo }}</th>
|
||||||
|
<td class="has-text-right"> $ {{ saldo }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Total a transferir:</th>
|
||||||
|
<td class="has-text-right">$ {{ total_a_transferir }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<th class="has-text-right">{{ cantidad_transporte }}</th>
|
<th class="has-text-right">{{ cantidad_transporte }}</th>
|
||||||
<th class="has-text-right">{{ total_transporte }}</th>
|
<th class="has-text-right">{{ total_transporte }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="grupo_de_compra.devoluciones_habilitadas && !aprobado">
|
<tr v-if="mostrarDevoluciones">
|
||||||
<th><p>Devoluciones</p></th>
|
<th><p>Devoluciones</p></th>
|
||||||
<td>
|
<td>
|
||||||
<abbr :title="devoluciones_notas">{{ notas_abreviadas }}</abbr>
|
<abbr :title="devoluciones_notas">{{ notas_abreviadas }}</abbr>
|
||||||
|
|
@ -49,6 +49,7 @@ import { mapMutations, mapState } from "vuex";
|
||||||
export default {
|
export default {
|
||||||
components: { ProductoRow },
|
components: { ProductoRow },
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState('login', ["rol"]),
|
||||||
...mapState('pedido',[
|
...mapState('pedido',[
|
||||||
"grupo_de_compra",
|
"grupo_de_compra",
|
||||||
"productos",
|
"productos",
|
||||||
|
|
@ -65,6 +66,9 @@ export default {
|
||||||
mostrar_tabla() {
|
mostrar_tabla() {
|
||||||
return this.productos?.length !== 0;
|
return this.productos?.length !== 0;
|
||||||
},
|
},
|
||||||
|
mostrarDevoluciones() {
|
||||||
|
return this.rol === "barrio" && this.grupo_de_compra.devoluciones_habilitadas && !this.aprobado;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations('ui',["toggleDevoluciones"]),
|
...mapMutations('ui',["toggleDevoluciones"]),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="is-justify-content-center">
|
<div class="is-justify-content-center">
|
||||||
<div class="field has-addons is-justify-content-center contador">
|
<div class="field has-addons is-justify-content-center contador">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button class="button is-small" :disabled="cantidadControl < 1" v-if="!aprobado" @click.capture="decrementar();">
|
<button class="button is-small" :disabled="!puedeDecrementar" v-if="!aprobado" @click.capture="decrementar();">
|
||||||
<i class="fa fa-solid fa-minus"></i>
|
<i class="fa fa-solid fa-minus"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<i class="fa fa-solid fa-plus"></i>
|
<i class="fa fa-solid fa-plus"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button :disabled="!hayCambios || cantidadControl < 0" v-if="!aprobado" class="button is-small is-success ml-1" @click="confirmar()">
|
<button :disabled="!puedeConfirmar" v-if="!aprobado" class="button is-small is-success ml-1" @click="confirmar()">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="fas fa-check"></i>
|
<i class="fas fa-check"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -82,8 +82,13 @@ export default {
|
||||||
this.actualizar();
|
this.actualizar();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState('login', ["rol"]),
|
||||||
...mapState('pedido', ["aprobado"]),
|
...mapState('pedido', ["aprobado"]),
|
||||||
...mapGetters('pedido', ["enChismosa", "cantidad", "notas"]),
|
...mapGetters('pedido', ["enChismosa", "cantidad", "notas"]),
|
||||||
|
...mapGetters('admin', ["cantidadBarrial"]),
|
||||||
|
cantidadTotal() {
|
||||||
|
return this.cantidadBarrial(this.producto_id);
|
||||||
|
},
|
||||||
cantidadEnChismosa() {
|
cantidadEnChismosa() {
|
||||||
return this.cantidad(this.producto_id);
|
return this.cantidad(this.producto_id);
|
||||||
},
|
},
|
||||||
|
|
@ -99,6 +104,14 @@ export default {
|
||||||
faltaNotas() {
|
faltaNotas() {
|
||||||
return this.requiere_notas && this.cantidadControl > 0 && !this.notasControl;
|
return this.requiere_notas && this.cantidadControl > 0 && !this.notasControl;
|
||||||
},
|
},
|
||||||
|
puedeDecrementar() {
|
||||||
|
const min = this.rol === "admin_barrio" ? -1*this.cantidadTotal : 0;
|
||||||
|
return this.cantidadControl > min;
|
||||||
|
},
|
||||||
|
puedeConfirmar() {
|
||||||
|
const min = this.rol === "admin_barrio" ? -1*this.cantidadTotal : 0;
|
||||||
|
return this.hayCambios && this.cantidadControl >= min;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('pedido', ["modificarChismosa"]),
|
...mapActions('pedido', ["modificarChismosa"]),
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ const state: AdminState = {
|
||||||
total_transporte: undefined,
|
total_transporte: undefined,
|
||||||
cantidad_transporte: undefined,
|
cantidad_transporte: undefined,
|
||||||
saldo: undefined,
|
saldo: undefined,
|
||||||
|
productos_cantidades: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
|
|
@ -40,6 +41,8 @@ const mutations = {
|
||||||
state.total_transporte = grupo_de_compra.total_transporte;
|
state.total_transporte = grupo_de_compra.total_transporte;
|
||||||
state.cantidad_transporte = grupo_de_compra.cantidad_transporte;
|
state.cantidad_transporte = grupo_de_compra.cantidad_transporte;
|
||||||
state.saldo = grupo_de_compra.saldo;
|
state.saldo = grupo_de_compra.saldo;
|
||||||
|
state.productos_cantidades = grupo_de_compra.productos_cantidades
|
||||||
|
.map(pc => ({...pc, cantidad: parseInt(pc.cantidad)}));
|
||||||
},
|
},
|
||||||
toggleCaracteristica(state, { caracteristica_id }) {
|
toggleCaracteristica(state, { caracteristica_id }) {
|
||||||
state[`${caracteristica_id}_habilitadas`] = !state[`${caracteristica_id}_habilitadas`];
|
state[`${caracteristica_id}_habilitadas`] = !state[`${caracteristica_id}_habilitadas`];
|
||||||
|
|
@ -62,6 +65,14 @@ const actions = {
|
||||||
await axios.post(`/api/grupos-de-compra/${state.grupo_de_compra_id}/${caracteristica_id}`);
|
await axios.post(`/api/grupos-de-compra/${state.grupo_de_compra_id}/${caracteristica_id}`);
|
||||||
commit('toggleCaracteristica', { caracteristica_id: caracteristica_id })
|
commit('toggleCaracteristica', { caracteristica_id: caracteristica_id })
|
||||||
},
|
},
|
||||||
|
async abrirFaltantesYSobrantes({ commit, dispatch }) {
|
||||||
|
const { data } = await axios.get(`/admin/${state.grupo_de_compra_id}/faltantes-y-sobrantes`)
|
||||||
|
const pedido = { pedido_id: data.id };
|
||||||
|
dispatch("productos/init", null, { root: true });
|
||||||
|
dispatch("pedido/elegirPedido", pedido, { root: true });
|
||||||
|
dispatch("ui/migasFaltantesYSobrantes", null, { root: true });
|
||||||
|
dispatch("ui/toggleFaltantesYSobrantes", null, { root: true });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getters = {
|
const getters = {
|
||||||
|
|
@ -85,6 +96,10 @@ const getters = {
|
||||||
},
|
},
|
||||||
getCaracteristica() {
|
getCaracteristica() {
|
||||||
return (caracteristica) => state[`${caracteristica}_habilitadas`];
|
return (caracteristica) => state[`${caracteristica}_habilitadas`];
|
||||||
|
},
|
||||||
|
cantidadBarrial() {
|
||||||
|
return (producto_id) =>
|
||||||
|
state.productos_cantidades.find(pc => pc.id === producto_id)?.cantidad ?? 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ export interface Barrio {
|
||||||
total_transporte?: number,
|
total_transporte?: number,
|
||||||
cantidad_transporte?: number,
|
cantidad_transporte?: number,
|
||||||
saldo?: number,
|
saldo?: number,
|
||||||
|
productos_cantidades: ProductoCantidad[],
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Pedido {
|
export interface Pedido {
|
||||||
|
|
@ -31,3 +32,8 @@ export interface Pedido {
|
||||||
devoluciones_total: number,
|
devoluciones_total: number,
|
||||||
devoluciones_notas: string
|
devoluciones_notas: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ProductoCantidad {
|
||||||
|
id: number,
|
||||||
|
cantidad: number,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ const state: UiState = {
|
||||||
show_chismosa: false,
|
show_chismosa: false,
|
||||||
show_devoluciones: false,
|
show_devoluciones: false,
|
||||||
show_tags: true,
|
show_tags: true,
|
||||||
|
show_faltantes_y_sobrantes: false,
|
||||||
burger_activa: false,
|
burger_activa: false,
|
||||||
tags_interactuada: false,
|
tags_interactuada: false,
|
||||||
migas: [{ nombre: 'Pedidos', action: 'pedido/resetear' }],
|
migas: [{ nombre: 'Pedidos', action: 'pedido/resetear' }],
|
||||||
|
|
@ -24,6 +25,9 @@ const mutations = {
|
||||||
state.tags_interactuada = manual;
|
state.tags_interactuada = manual;
|
||||||
state.show_tags = !state.show_tags;
|
state.show_tags = !state.show_tags;
|
||||||
},
|
},
|
||||||
|
toggleFaltantesYSobrantes(state) {
|
||||||
|
state.show_faltantes_y_sobrantes = !state.show_faltantes_y_sobrantes;
|
||||||
|
},
|
||||||
toggleBurger(state) {
|
toggleBurger(state) {
|
||||||
state.burger_activa = !state.burger_activa;
|
state.burger_activa = !state.burger_activa;
|
||||||
},
|
},
|
||||||
|
|
@ -41,6 +45,10 @@ const mutations = {
|
||||||
migasOllas(state) {
|
migasOllas(state) {
|
||||||
state.migas.reverse().pop();
|
state.migas.reverse().pop();
|
||||||
},
|
},
|
||||||
|
migasFaltantesYSobrantes(state) {
|
||||||
|
const migaAdmin = { nombre: 'Administración', action: 'ui/toggleFaltantesYSobrantes' }
|
||||||
|
state.migas[0] = migaAdmin;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
|
|
@ -80,6 +88,12 @@ const actions = {
|
||||||
migasOllas({ commit }) {
|
migasOllas({ commit }) {
|
||||||
commit("migasOllas");
|
commit("migasOllas");
|
||||||
},
|
},
|
||||||
|
toggleFaltantesYSobrantes({ commit }) {
|
||||||
|
commit("toggleFaltantesYSobrantes");
|
||||||
|
},
|
||||||
|
migasFaltantesYSobrantes({ commit }) {
|
||||||
|
commit("migasFaltantesYSobrantes");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ export interface UiState {
|
||||||
show_chismosa: boolean,
|
show_chismosa: boolean,
|
||||||
show_devoluciones: boolean,
|
show_devoluciones: boolean,
|
||||||
show_tags: boolean,
|
show_tags: boolean,
|
||||||
|
show_faltantes_y_sobrantes: boolean,
|
||||||
|
burger_activa: boolean,
|
||||||
tags_interactuada: boolean,
|
tags_interactuada: boolean,
|
||||||
migas: Miga[],
|
migas: Miga[],
|
||||||
canasta_actual?: DatosCanasta,
|
canasta_actual?: DatosCanasta,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ Route::middleware(['auth'])->group(function () {
|
||||||
Route::get('/user/grupo_de_compra', 'UserController@grupoDeCompra');
|
Route::get('/user/grupo_de_compra', 'UserController@grupoDeCompra');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware(['auth', 'role:barrio'])->group(function() {
|
Route::middleware(['auth'])->group(function() {
|
||||||
Route::get('/pedido', 'RouteController@main')->name('pedido');
|
Route::get('/pedido', 'RouteController@main')->name('pedido');
|
||||||
Route::get('/pedido/sesion', 'SessionController@fetch');
|
Route::get('/pedido/sesion', 'SessionController@fetch');
|
||||||
Route::post('/pedido/sesion', 'SessionController@store');
|
Route::post('/pedido/sesion', 'SessionController@store');
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue