Compare commits

..

No commits in common. "funcion/faltantes-y-sobrantes" and "master" have entirely different histories.

21 changed files with 123 additions and 398 deletions

View file

@ -35,7 +35,6 @@ class PedidosExportHelper
) )
); );
} }
/** /**
* @throws InvalidArgument * @throws InvalidArgument
* @throws CannotInsertRecord * @throws CannotInsertRecord
@ -44,16 +43,16 @@ class PedidosExportHelper
static public function pedidosDeOllas() static public function pedidosDeOllas()
{ {
$filePath = "csv/exports/pedidos-de-ollas-" . now()->format('Y-m-d') . ".csv"; $filePath = "csv/exports/pedidos-de-ollas-" . now()->format('Y-m-d') . ".csv";
$tipo_olla = self::getTipoId('olla');
$barrios = GrupoDeCompra::barriosMenosPrueba() $barrios = GrupoDeCompra::barriosMenosPrueba()
->whereHas('subpedidos', function ($query) use ($tipo_olla) { ->whereHas('subpedidos', function ($query) {
$tipo_olla = self::getTipoId('olla');
$query->where('tipo_pedido_id', $tipo_olla); $query->where('tipo_pedido_id', $tipo_olla);
}) })
->get(); ->get();
$contenido = self::generarContenidoCSV($barrios, $contenido = self::generarContenidoCSV($barrios,
fn($grupoId) => "subpedidos.grupo_de_compra_id = $grupoId fn($grupoId) => "subpedidos.grupo_de_compra_id = $grupoId
AND subpedidos.tipo_pedido_id = $tipo_olla"); AND subpedidos.tipo_pedido_id = 2");
$ollas = self::cantidadDeOllasParaCSV($barrios, $contenido); $ollas = self::cantidadDeOllasParaCSV($barrios, $contenido);
self::exportarCSV( self::exportarCSV(
@ -129,32 +128,6 @@ class PedidosExportHelper
); );
} }
/**
* @throws InvalidArgument
* @throws CannotInsertRecord
* @throws Exception
*/
static public function faltantesYSobrantes()
{
$filePath = "csv/exports/faltantes-y-sobrantes-" . now()->format('Y-m-d') . ".csv";
$tipoPedidoId = self::getTipoId('faltantes_y_sobrantes');
$barrios = GrupoDeCompra::barriosMenosPrueba()
->whereHas('subpedidos', function ($query) use ($tipoPedidoId) {
$query->where('tipo_pedido_id', $tipoPedidoId);
})
->get();
$contenido = self::generarContenidoCSV($barrios,
fn($grupoId) => "subpedidos.grupo_de_compra_id = $grupoId
AND subpedidos.tipo_pedido_id = $tipoPedidoId");
self::exportarCSV(
$filePath,
$barrios,
$contenido
);
}
/** /**
* @throws InvalidArgument * @throws InvalidArgument
* @throws CannotInsertRecord * @throws CannotInsertRecord
@ -279,7 +252,7 @@ class PedidosExportHelper
*/ */
public static function getTipoId(string $tipo) public static function getTipoId(string $tipo)
{ {
$tipoPedido = TipoPedido::where('nombre', $tipo)->first()->id; $tipo_olla = TipoPedido::where('nombre', $tipo)->first()->id;
return $tipoPedido; return $tipo_olla;
} }
} }

View file

@ -68,11 +68,23 @@ class SubpedidoController extends Controller
// recibe request, saca producto y cantidad, valida, y pasa a syncProducto en Subpedido // recibe request, saca producto y cantidad, valida, y pasa a syncProducto en Subpedido
public function syncProductos(Subpedido $subpedido) { public function syncProductos(Subpedido $subpedido) {
$faltantesYSobrantes = TipoPedido::firstOrCreate(['nombre' => 'faltantes_y_sobrantes']); if ($subpedido->aprobado)
if ($subpedido->tipo_pedido_id == $faltantesYSobrantes->id) { abort(400, "No se puede modificar un pedido aprobado.");
return $this->syncFaltantesYSobrantes($subpedido);
} $valid = request()->validate([
return $this->syncPedidoNormal($subpedido); 'cantidad' => ['integer','required','min:0'],
'notas' => 'nullable',
'producto_id' => [
'required',
Rule::in(Producto::all()->pluck('id')),
]
]);
$producto = Producto::find($valid['producto_id']);
$notas = $valid['notas'];
$cantidad = $valid['cantidad'];
$subpedido->syncProducto($producto, $cantidad, $notas ?? "");
return new SubpedidoResource($subpedido);
} }
public function toggleAprobacion(Subpedido $subpedido) { public function toggleAprobacion(Subpedido $subpedido) {
@ -95,64 +107,4 @@ class SubpedidoController extends Controller
return new SubpedidoResource($subpedido); return new SubpedidoResource($subpedido);
} }
/**
* @param Subpedido $subpedido
* @return SubpedidoResource
*/
public function syncPedidoNormal(Subpedido $subpedido): SubpedidoResource
{
if ($subpedido->aprobado)
abort(400, "No se puede modificar un pedido aprobado.");
$valid = request()->validate([
'cantidad' => ['integer', 'required', 'min:0'],
'notas' => 'nullable',
'producto_id' => [
'required',
Rule::in(Producto::all()->pluck('id')),
]
]);
$producto = Producto::find($valid['producto_id']);
$notas = $valid['notas'];
$cantidad = $valid['cantidad'];
$subpedido->syncProducto($producto, $cantidad, $notas ?? "");
return new SubpedidoResource($subpedido);
}
/**
* @param Subpedido $subpedido
* @return SubpedidoResource
*/
public function syncFaltantesYSobrantes(Subpedido $subpedido): SubpedidoResource
{
$valid = request()->validate([
'cantidad' => ['integer', 'required'],
'producto_id' => [
'required',
Rule::in(Producto::all()->pluck('id')),
]
]);
$producto = Producto::find($valid['producto_id']);
if ($producto->bono)
abort(400, "No puede haber faltado un bono");
$cantidad = $valid['cantidad'];
if ($cantidad < 0) { // caso faltantes
$barrio = GrupoDeCompra::find($subpedido->grupo_de_compra_id);
$productoPedido = $barrio->productosPedidos()->where('producto_id', $producto->id)->first();
if (!$productoPedido)
abort(400, "No pueden faltar productos no pedidos");
$cantidadPedida = intval($productoPedido->cantidad_pedida);
if ($cantidadPedida + $cantidad < 0)
abort(400, 'No puede faltar más de lo pedido');
}
$subpedido->syncProducto($producto, $cantidad);
return new SubpedidoResource($subpedido);
}
} }

View file

@ -65,23 +65,6 @@ class ComisionesController
return response()->download($files[0]); return response()->download($files[0]);
} }
public function descargarFaltantesYSobrantes()
{
try {
PedidosExportHelper::faltantesYSobrantes();
} catch (CannotInsertRecord|InvalidArgument|Exception $e) {
return response()->json(['message' => $e->getMessage()], 500);
}
$pattern = storage_path('csv/exports/faltantes-y-sobrantes-*.csv');
$files = glob($pattern);
usort($files, function ($a, $b) {
return filemtime($b) <=> filemtime($a);
});
return response()->download($files[0]);
}
public function descargarNotas() public function descargarNotas()
{ {
try { try {

View file

@ -1,20 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\GrupoDeCompra;
use App\Http\Resources\PedidoFaltantesYSobrantesResource;
use App\TipoPedido;
class FaltantesYSobrantesController extends Controller
{
public function pedido(GrupoDeCompra $gdc)
{
$tipoFaltantesYSobrantes = TipoPedido::firstOrCreate(['nombre' => 'faltantes_y_sobrantes']);
$pedido = $gdc->subpedidos()->firstOrCreate([
'nombre' => 'Faltantes y Sobrantes de ' . $gdc->nombre,
'tipo_pedido_id' => $tipoFaltantesYSobrantes->id,
]);
return response()->json(new PedidoFaltantesYSobrantesResource($pedido));
}
}

View file

@ -15,14 +15,6 @@ class GrupoDeCompraResource extends JsonResource
*/ */
public function toArray($request): array public function toArray($request): array
{ {
$productos_cantidades = [];
$productos_pedidos = $this->productosPedidos();
foreach ($productos_pedidos as $productoPedido) {
$productos_cantidades[] = [
"id" => $productoPedido->producto_id,
"cantidad" => $productoPedido->cantidad_pedida
];
}
return [ return [
'id' => $this->id, 'id' => $this->id,
'nombre' => $this->nombre, 'nombre' => $this->nombre,
@ -37,7 +29,6 @@ class GrupoDeCompraResource extends JsonResource
'total_a_transferir' => number_format($this->totalATransferir(),2), 'total_a_transferir' => number_format($this->totalATransferir(),2),
'total_transporte' => number_format($this->totalTransporte()), 'total_transporte' => number_format($this->totalTransporte()),
'cantidad_transporte' => number_format($this->cantidadTransporte()), 'cantidad_transporte' => number_format($this->cantidadTransporte()),
'productos_cantidades' => $productos_cantidades,
]; ];
} }
} }

View file

@ -1,28 +0,0 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class PedidoFaltantesYSobrantesResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request): array
{
$productos = $this->productos;
foreach ($productos as $producto) {
$producto['pivot']['total'] = number_format($producto->pivot->cantidad * $producto->precio, 2);
}
return [
'id' => $this->id,
'nombre' => $this->nombre,
'productos' => $productos,
];
}
}

View file

@ -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

View file

@ -1,30 +0,0 @@
<?php
use App\TipoPedido;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
TipoPedido::firstOrCreate(['nombre' => 'faltantes_y_sobrantes']);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$faltantesYSobrantes = TipoPedido::where('nombre', 'faltantes_y_sobrantes')->firstOrFail();
$faltantesYSobrantes->delete();
}
};

1
package-lock.json generated
View file

@ -4,6 +4,7 @@
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "www",
"dependencies": { "dependencies": {
"animate.css": "^4.1.1", "animate.css": "^4.1.1",
"bulma": "^0.9.4", "bulma": "^0.9.4",

View file

@ -1,20 +1,10 @@
<template> <template>
<div> <div class="block ml-3 mr-3 is-max-widescreen is-max-desktop">
<pedidos-main v-if="show_faltantes_y_sobrantes"/>
<div class="block ml-3 mr-3 is-max-widescreen is-max-desktop" v-else>
<tabs-secciones :tabs="tabs" :tabInicial="tabActiva"/> <tabs-secciones :tabs="tabs" :tabInicial="tabActiva"/>
<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 pb-6" id="pedidos-tabla-y-dropdown" v-if="hayPedidos"> <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/> <dropdown-descargar/>
</div>
<tabla-pedidos/> <tabla-pedidos/>
</div> </div>
<p class="has-text-centered" v-else> <p class="has-text-centered" v-else>
@ -26,7 +16,6 @@
<caracteristicas-opcionales/> <caracteristicas-opcionales/>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
@ -34,14 +23,10 @@ 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, mapMutations, mapState } from "vuex"; import { mapActions, mapGetters } 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,
@ -57,12 +42,9 @@ export default {
}, },
computed: { computed: {
...mapGetters('admin', ['hayPedidos']), ...mapGetters('admin', ['hayPedidos']),
...mapState('ui', ['show_faltantes_y_sobrantes'])
}, },
methods: { methods: {
...mapActions('admin', ['getGrupoDeCompra', 'abrirFaltantesYSobrantes']), ...mapActions('admin', ['getGrupoDeCompra']),
...mapActions('ui', ['toast']),
...mapMutations('ui', ['toggleFaltantesYSobrantes']),
setSeccionActiva(tabId) { setSeccionActiva(tabId) {
this.tabActiva = tabId; this.tabActiva = tabId;
this.seccionActiva = tabId + "-seccion"; this.seccionActiva = tabId + "-seccion";

View file

@ -2,11 +2,7 @@
<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" <button class="button" aria-haspopup="true" aria-controls="dropdown-menu" :disabled="!hayAprobados" @click="dropdownActivo = !dropdownActivo">
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>

View file

@ -18,25 +18,71 @@
/> />
</tbody> </tbody>
</table> </table>
<tabla-totales/> <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>
</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>

View file

@ -1,69 +0,0 @@
<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>

View file

@ -14,8 +14,17 @@
</div> </div>
<div class="dropdown-menu" id="dropdown-menu" role="menu"> <div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content"> <div class="dropdown-content">
<a v-for="(opcion,i) in opciones" :key="i" :href="opcion.href" class="dropdown-item"> <a href="/comisiones/pedidos/descargar" class="dropdown-item">
{{ opcion.nombre }} Pedidos por barrio en csv
</a>
<a href="/comisiones/pedidos/notas" class="dropdown-item">
Notas por barrio en csv
</a>
<a href="/comisiones/pedidos/pdf" class="dropdown-item">
Pedidos por barrio en pdf
</a>
<a href="/comisiones/pedidos/ollas" class="dropdown-item">
Pedidos de ollas en csv
</a> </a>
</div> </div>
</div> </div>
@ -27,14 +36,7 @@
export default { export default {
data() { data() {
return { return {
dropdownActivo: false, dropdownActivo: false
opciones: [
{ nombre: 'Pedidos por barrio en csv', href: '/comisiones/pedidos/descargar' },
{ nombre: 'Notas por barrio en csv', href: '/comisiones/pedidos/notas' },
{ nombre: 'Pedidos por barrio en pdf', href: '/comisiones/pedidos/pdf' },
{ nombre: 'Pedidos de ollas en csv', href: '/comisiones/pedidos/ollas' },
{ nombre: 'Faltantes y sobrantes en csv', href: '/comisiones/faltantes-y-sobrantes' },
],
} }
}, },
} }

View file

@ -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="mostrarDevoluciones"> <tr v-if="grupo_de_compra.devoluciones_habilitadas && !aprobado">
<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,7 +49,6 @@ 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",
@ -66,9 +65,6 @@ 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"]),

View file

@ -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="!puedeDecrementar" v-if="!aprobado" @click.capture="decrementar();"> <button class="button is-small" :disabled="cantidadControl < 1" 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="!puedeConfirmar" v-if="!aprobado" class="button is-small is-success ml-1" @click="confirmar()"> <button :disabled="!hayCambios || cantidadControl < 0" 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,13 +82,8 @@ 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);
}, },
@ -104,14 +99,6 @@ 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"]),

View file

@ -17,7 +17,6 @@ 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 = {
@ -41,8 +40,6 @@ 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`];
@ -65,14 +62,6 @@ 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({ 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 = {
@ -96,10 +85,6 @@ 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;
} }
}; };

View file

@ -17,7 +17,6 @@ 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 {
@ -32,8 +31,3 @@ export interface Pedido {
devoluciones_total: number, devoluciones_total: number,
devoluciones_notas: string devoluciones_notas: string
} }
export interface ProductoCantidad {
id: number,
cantidad: number,
}

View file

@ -4,7 +4,6 @@ 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' }],
@ -25,9 +24,6 @@ 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;
}, },
@ -45,9 +41,6 @@ const mutations = {
migasOllas(state) { migasOllas(state) {
state.migas.reverse().pop(); state.migas.reverse().pop();
}, },
migasFaltantesYSobrantes(state) {
state.migas[0] = { nombre: 'Administración', action: 'ui/toggleFaltantesYSobrantes' };
}
}; };
const actions = { const actions = {
@ -87,12 +80,6 @@ const actions = {
migasOllas({ commit }) { migasOllas({ commit }) {
commit("migasOllas"); commit("migasOllas");
}, },
toggleFaltantesYSobrantes({ commit }) {
commit("toggleFaltantesYSobrantes");
},
migasFaltantesYSobrantes({ commit }) {
commit("migasFaltantesYSobrantes");
}
}; };
export default { export default {

View file

@ -3,8 +3,6 @@ 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,

View file

@ -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'])->group(function() { Route::middleware(['auth', 'role:barrio'])->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');
@ -38,28 +38,27 @@ Route::middleware(['auth'])->group(function() {
Route::get('/admin/login', 'AdminController@show')->name('admin.login'); Route::get('/admin/login', 'AdminController@show')->name('admin.login');
Route::middleware(['auth', 'role:admin_barrio'])->prefix('admin')->group(function () { Route::middleware(['auth', 'role:admin_barrio'])->group(function () {
Route::get('/', 'RouteController@main')->name('admin'); Route::get('/admin', 'RouteController@main')->name('admin');
Route::get('/exportar-planillas-a-pdf/{gdc}', 'AdminController@exportarPedidosAPdf');
Route::get('/exportar-pedido-a-csv/{gdc}', 'AdminController@exportarPedidoACSV'); Route::get('/admin/exportar-planillas-a-pdf/{gdc}', 'AdminController@exportarPedidosAPdf');
Route::get('/exportar-pedido-con-nucleos-a-csv/{gdc}', 'AdminController@exportarPedidoConNucleosACSV'); Route::get('/admin/exportar-pedido-a-csv/{gdc}', 'AdminController@exportarPedidoACSV');
Route::get('/{gdc}/faltantes-y-sobrantes', 'FaltantesYSobrantesController@pedido'); Route::get('/admin/exportar-pedido-con-nucleos-a-csv/{gdc}', 'AdminController@exportarPedidoConNucleosACSV');
}); });
Route::get('/comisiones/login', 'ComisionesController@show')->name('comisiones.login'); Route::get('/comisiones/login', 'ComisionesController@show')->name('comisiones.login');
Route::middleware(['auth', 'role:comision'])->prefix('comisiones')->group( function() { Route::middleware(['auth', 'role:comision'])->group( function() {
Route::get('/', 'RouteController@main')->name('comisiones'); Route::get('/comisiones', 'RouteController@main')->name('comisiones');
Route::get('/pedidos/descargar', 'ComisionesController@descargarPedidos')->name('comisiones.pedidos.descargar'); Route::get('/comisiones/pedidos/descargar', 'ComisionesController@descargarPedidos')->name('comisiones.pedidos.descargar');
Route::get('/pedidos/notas', 'ComisionesController@descargarNotas')->name('comisiones.pedidos.notas'); Route::get('/comisiones/pedidos/notas', 'ComisionesController@descargarNotas')->name('comisiones.pedidos.notas');
Route::get('/pedidos/pdf', 'ComisionesController@pdf')->name('comisiones.pedidos.pdf'); Route::get('/comisiones/pedidos/pdf', 'ComisionesController@pdf')->name('comisiones.pedidos.pdf');
Route::get('/pedidos/ollas', 'ComisionesController@descargarPedidosDeOllas')->name('comisiones.pedidos.ollas'); Route::get('/comisiones/pedidos/ollas', 'ComisionesController@descargarPedidosDeOllas')->name('comisiones.pedidos.ollas');
Route::get('/canasta/ejemplo', 'ComisionesController@descargarCanastaEjemplo')->name('comisiones.canasta.ejemplo'); Route::get('/comisiones/canasta/ejemplo', 'ComisionesController@descargarCanastaEjemplo')->name('comisiones.canasta.ejemplo');
Route::post('/canasta', 'ComisionesController@cargarCanasta')->name('comisiones.canasta'); Route::post('/comisiones/canasta', 'ComisionesController@cargarCanasta')->name('comisiones.canasta');
Route::get('/saldos/ejemplo', 'ComisionesController@descargarSaldosEjemplo')->name('comisiones.saldos.ejemplo'); Route::get('/comisiones/saldos/ejemplo', 'ComisionesController@descargarSaldosEjemplo')->name('comisiones.saldos.ejemplo');
Route::post('/saldos', 'ComisionesController@cargarSaldos')->name('comisiones.saldos'); Route::post('/comisiones/saldos', 'ComisionesController@cargarSaldos')->name('comisiones.saldos');
Route::put('/parametros/{parametro_id}', 'ComisionesController@modificarParametros')->name('comisiones.parametros.modificar'); Route::put('/comisiones/parametros/{parametro_id}', 'ComisionesController@modificarParametros');
Route::get('/faltantes-y-sobrantes', 'ComisionesController@descargarFaltantesYSobrantes')->name('comisiones.faltantesYsobrantes');
}); });
Route::get('/ollas/login', 'OllasController@show')->name('ollas.login'); Route::get('/ollas/login', 'OllasController@show')->name('ollas.login');