Compare commits
28 commits
db056e7d34
...
e49c043231
Author | SHA1 | Date | |
---|---|---|---|
e49c043231 | |||
a0ee4131c8 | |||
5a1d95c636 | |||
d261506775 | |||
e58e19bfe1 | |||
d86d52a478 | |||
0e42cf2c14 | |||
200c38cb29 | |||
60c327f74b | |||
309ce637c8 | |||
5c059057b9 | |||
8fa3f78280 | |||
b6cd844ffd | |||
3c14055006 | |||
e37aa25b3d | |||
d87091846d | |||
f520578525 | |||
aaeee70c9e | |||
05dc58710d | |||
5020d406bf | |||
6d6d8d4387 | |||
ee96d89e55 | |||
5d7d533083 | |||
b1b764fd7c | |||
cc6b0f5a6e | |||
db87c38e3b | |||
8fb810c73f | |||
208cb31b53 |
35 changed files with 661 additions and 140 deletions
|
@ -12,6 +12,7 @@ use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use League\Csv\Exception;
|
use League\Csv\Exception;
|
||||||
|
use Mpdf\MpdfException;
|
||||||
|
|
||||||
class GrupoDeCompra extends Model
|
class GrupoDeCompra extends Model
|
||||||
{
|
{
|
||||||
|
@ -37,7 +38,14 @@ class GrupoDeCompra extends Model
|
||||||
|
|
||||||
public function pedidosAprobados()
|
public function pedidosAprobados()
|
||||||
{
|
{
|
||||||
return $this->subpedidos->where('aprobado', 1);
|
return $this->pedidosHogares()
|
||||||
|
->where('aprobado', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pedidosHogares()
|
||||||
|
{
|
||||||
|
return $this->subpedidos
|
||||||
|
->where('tipo_pedido_id', '=', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function totalARecaudar()
|
public function totalARecaudar()
|
||||||
|
@ -120,11 +128,15 @@ class GrupoDeCompra extends Model
|
||||||
return TransporteHelper::cantidadTransporte($this->totalCentralesQuePaganTransporte());
|
return TransporteHelper::cantidadTransporte($this->totalCentralesQuePaganTransporte());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws MpdfException
|
||||||
|
*/
|
||||||
public function exportarPedidosAPdf()
|
public function exportarPedidosAPdf()
|
||||||
{
|
{
|
||||||
$subpedidos = $this->pedidosAprobados();
|
$subpedidos = $this->pedidosAprobados();
|
||||||
$fecha = now()->format('Y-m-d');
|
$fecha = now()->format('Y-m-d');
|
||||||
PdfHelper::exportarPedidos($this->nombre . '-' . $fecha . '.pdf', $subpedidos);
|
$filepath = $this->nombre . '-' . $fecha . '.pdf';
|
||||||
|
PdfHelper::exportarPedidos($filepath, $subpedidos);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pedidoParaPdf(): array
|
function pedidoParaPdf(): array
|
||||||
|
@ -154,11 +166,15 @@ class GrupoDeCompra extends Model
|
||||||
return $view->render();
|
return $view->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws MpdfException
|
||||||
|
*/
|
||||||
public static function exportarPedidosBarrialesAPdf()
|
public static function exportarPedidosBarrialesAPdf()
|
||||||
{
|
{
|
||||||
$barrios = GrupoDeCompra::barriosMenosPrueba()->get();
|
$barrios = GrupoDeCompra::barriosMenosPruebaConPedidosAprobados()->get();
|
||||||
$fecha = now()->format('Y-m-d');
|
$fecha = now()->format('Y-m-d');
|
||||||
PdfHelper::exportarPedidos('pedidos_por_barrio-' . $fecha . '.pdf', $barrios);
|
$filepath = 'pedidos_por_barrio-' . $fecha . '.pdf';
|
||||||
|
PdfHelper::exportarPedidos($filepath, $barrios);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function filaVacia(string $product, int $columns): array
|
static function filaVacia(string $product, int $columns): array
|
||||||
|
@ -276,9 +292,12 @@ class GrupoDeCompra extends Model
|
||||||
return array($records, $i, $cantidad);
|
return array($records, $i, $cantidad);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function barriosMenosPrueba(): Builder
|
public static function barriosMenosPruebaConPedidosAprobados(): Builder
|
||||||
{
|
{
|
||||||
return self::where('nombre', '<>', 'PRUEBA')
|
return self::where('nombre', '<>', 'PRUEBA')
|
||||||
|
->whereHas('subpedidos', function ($query) {
|
||||||
|
$query->where('aprobado', true);
|
||||||
|
})
|
||||||
->orderBy('region')
|
->orderBy('region')
|
||||||
->orderBy('nombre');
|
->orderBy('nombre');
|
||||||
}
|
}
|
||||||
|
@ -286,7 +305,7 @@ class GrupoDeCompra extends Model
|
||||||
public static function transportePorBarrio(): array
|
public static function transportePorBarrio(): array
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
$barrios = GrupoDeCompra::barriosMenosPrueba()->get();
|
$barrios = GrupoDeCompra::barriosMenosPruebaConPedidosAprobados()->get();
|
||||||
|
|
||||||
foreach ($barrios as $barrio) {
|
foreach ($barrios as $barrio) {
|
||||||
$result[] = $barrio->cantidadTransporte();
|
$result[] = $barrio->cantidadTransporte();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\ComisionesController;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Iterator;
|
use Iterator;
|
||||||
|
@ -13,15 +14,13 @@ use League\Csv\Writer;
|
||||||
|
|
||||||
class CsvHelper
|
class CsvHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function getRecords($filePath, $message): Iterator {
|
public static function getRecords($filePath, $message): Iterator {
|
||||||
$csv = Reader::createFromPath($filePath);
|
|
||||||
try {
|
try {
|
||||||
$csv->setDelimiter("|");
|
$csv = self::getReader($filePath);
|
||||||
$csv->setEnclosure("'");
|
|
||||||
$csv->setHeaderOffset(0);
|
|
||||||
return $csv->getRecords();
|
return $csv->getRecords();
|
||||||
} catch (InvalidArgument|Exception $e) {
|
} catch (InvalidArgument|Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
|
@ -29,20 +28,74 @@ class CsvHelper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generarCsv($filePath, $contenido, $headers = null): void
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function cambiarParametro(string $id, string $valor): void
|
||||||
{
|
{
|
||||||
if (!File::exists(storage_path('csv/exports'))) {
|
try {
|
||||||
File::makeDirectory(storage_path('csv/exports'), 0755, true);
|
$updated = false;
|
||||||
|
$filePath = resource_path(ComisionesController::PARAMETROS_PATH);
|
||||||
|
$csv = self::getReader($filePath);
|
||||||
|
$headers = $csv->getHeader();
|
||||||
|
$records = array_map(fn($r) => (array) $r, iterator_to_array($csv->getRecords()));
|
||||||
|
|
||||||
|
foreach ($records as &$record) {
|
||||||
|
if ($record['id'] === $id) {
|
||||||
|
$record['valor'] = $valor;
|
||||||
|
$updated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($record);
|
||||||
|
|
||||||
|
if (!$updated)
|
||||||
|
throw new Exception("Parametro '{$id}' no encontrado.");
|
||||||
|
|
||||||
|
self::generarCsv($filePath, $records, $headers, "|", "'", false);
|
||||||
|
} catch (CannotInsertRecord | InvalidArgument $e) {
|
||||||
|
Log::error("Error al actualizar csv: " . $e->getMessage());
|
||||||
|
throw new Exception("Error al actualizar csv", $e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
/**
|
||||||
$writer = Writer::createFromPath(storage_path($filePath), 'w');
|
* @throws InvalidArgument
|
||||||
if ($headers) {
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
|
public static function generarCsv($filePath, $contenido, $headers = null, $delimiter = null, $enclosure = null, $export = true): void
|
||||||
|
{
|
||||||
|
$path = $filePath;
|
||||||
|
|
||||||
|
if ($export) {
|
||||||
|
if (!File::exists(storage_path('csv/exports')))
|
||||||
|
File::makeDirectory(storage_path('csv/exports'), 0755, true);
|
||||||
|
$path = storage_path($filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$writer = Writer::createFromPath($path, 'w');
|
||||||
|
if ($delimiter)
|
||||||
|
$writer->setDelimiter($delimiter);
|
||||||
|
if ($enclosure)
|
||||||
|
$writer->setEnclosure($enclosure);
|
||||||
|
if ($headers)
|
||||||
$writer->insertOne($headers);
|
$writer->insertOne($headers);
|
||||||
}
|
|
||||||
$writer->insertAll($contenido);
|
$writer->insertAll($contenido);
|
||||||
} catch (CannotInsertRecord $e) {
|
}
|
||||||
Log::error($e->getMessage(), $e->getTrace());
|
|
||||||
}
|
/**
|
||||||
|
* @param string $filePath
|
||||||
|
* @return Reader
|
||||||
|
* @throws InvalidArgument
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private static function getReader(string $filePath): Reader
|
||||||
|
{
|
||||||
|
$csv = Reader::createFromPath($filePath);
|
||||||
|
$csv->setDelimiter("|");
|
||||||
|
$csv->setEnclosure("'");
|
||||||
|
$csv->setHeaderOffset(0);
|
||||||
|
return $csv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\GrupoDeCompra;
|
use App\GrupoDeCompra;
|
||||||
use League\Csv\Exception;
|
use League\Csv\Exception;
|
||||||
|
use Mpdf\MpdfException;
|
||||||
|
|
||||||
class AdminController extends Controller
|
class AdminController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -17,7 +18,12 @@ class AdminController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exportarPedidosAPdf(GrupoDeCompra $gdc) {
|
public function exportarPedidosAPdf(GrupoDeCompra $gdc) {
|
||||||
|
try {
|
||||||
$gdc->exportarPedidosAPdf();
|
$gdc->exportarPedidosAPdf();
|
||||||
|
return response();
|
||||||
|
} catch (MpdfException $e) {
|
||||||
|
return response()->json(['message' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exportarPedidoACSV(GrupoDeCompra $gdc)
|
public function exportarPedidoACSV(GrupoDeCompra $gdc)
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api;
|
|
||||||
|
|
||||||
use App\GrupoDeCompra;
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Http\Resources\SubpedidoResource;
|
|
||||||
use App\TipoPedido;
|
|
||||||
|
|
||||||
class OllasController extends Controller
|
|
||||||
{
|
|
||||||
public function pedido(GrupoDeCompra $gdc)
|
|
||||||
{
|
|
||||||
$tipoOlla = TipoPedido::firstOrCreate(['nombre' => 'olla']);
|
|
||||||
$pedido = $gdc->subpedidos()->firstOrCreate([
|
|
||||||
'nombre' => 'Pedido de Ollas de ' . $gdc->nombre,
|
|
||||||
'tipo_pedido_id' => $tipoOlla->id,
|
|
||||||
]);
|
|
||||||
return response()->json(new SubpedidoResource($pedido));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,10 +10,12 @@ use App\Producto;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use League\Csv\Exception;
|
use League\Csv\Exception;
|
||||||
|
use Mpdf\MpdfException;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
|
||||||
class ComisionesController
|
class ComisionesController
|
||||||
{
|
{
|
||||||
|
const PARAMETROS_PATH = 'csv/parametros.csv';
|
||||||
const CANASTAS_PATH = 'csv/canastas/';
|
const CANASTAS_PATH = 'csv/canastas/';
|
||||||
const BARRIO = "Barrio";
|
const BARRIO = "Barrio";
|
||||||
const SALDO = "Saldo";
|
const SALDO = "Saldo";
|
||||||
|
@ -54,7 +56,12 @@ class ComisionesController
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pdf() {
|
public function pdf() {
|
||||||
|
try {
|
||||||
GrupoDeCompra::exportarPedidosBarrialesAPdf();
|
GrupoDeCompra::exportarPedidosBarrialesAPdf();
|
||||||
|
return response();
|
||||||
|
} catch (MpdfException $e) {
|
||||||
|
return response()->json(['message' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cargarCanasta(Request $request): JsonResponse
|
public function cargarCanasta(Request $request): JsonResponse
|
||||||
|
@ -104,4 +111,42 @@ class ComisionesController
|
||||||
|
|
||||||
return response()->json(GrupoDeCompraResource::collection(GrupoDeCompra::all()));
|
return response()->json(GrupoDeCompraResource::collection(GrupoDeCompra::all()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function obtenerParametros()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$records = self::parametrosRecords();
|
||||||
|
$result = [];
|
||||||
|
foreach ($records as $record)
|
||||||
|
$result[] = $record;
|
||||||
|
return response()->json($result);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return response()->json(['message' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function modificarParametros(string $parametro_id, Request $request) {
|
||||||
|
try {
|
||||||
|
if (collect(self::parametrosRecords())
|
||||||
|
->contains('id', $parametro_id)) {
|
||||||
|
$valid = $request->validate([
|
||||||
|
'valor' => ['required', 'numeric', 'gte:0'],
|
||||||
|
]);
|
||||||
|
CsvHelper::cambiarParametro($parametro_id, $valid['valor']);
|
||||||
|
return response()->noContent();
|
||||||
|
}
|
||||||
|
return response()->json(['message' => 'Parametro no encontrado.'], 404);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return response()->json(['message' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private static function parametrosRecords(): array
|
||||||
|
{
|
||||||
|
$records = CsvHelper::getRecords(resource_path(self::PARAMETROS_PATH), "No se pudo leer el archivo.");
|
||||||
|
return iterator_to_array($records);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,38 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\GrupoDeCompra;
|
||||||
|
use App\Http\Resources\PedidoOllasResource;
|
||||||
|
use App\TipoPedido;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class OllasController extends Controller
|
class OllasController extends Controller
|
||||||
{
|
{
|
||||||
public function show()
|
public function show()
|
||||||
{
|
{
|
||||||
return view('auth/login');
|
return view('auth/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function pedido(GrupoDeCompra $gdc)
|
||||||
|
{
|
||||||
|
$tipoOlla = TipoPedido::firstOrCreate(['nombre' => 'olla']);
|
||||||
|
$pedido = $gdc->subpedidos()->firstOrCreate([
|
||||||
|
'nombre' => 'Pedido de Ollas de ' . $gdc->nombre,
|
||||||
|
'tipo_pedido_id' => $tipoOlla->id,
|
||||||
|
]);
|
||||||
|
return response()->json(new PedidoOllasResource($pedido));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actualizarCantidadOllas(GrupoDeCompra $gdc, Request $request)
|
||||||
|
{
|
||||||
|
$valid = $request->validate([
|
||||||
|
'cantidad' => 'required|numeric|min:0',
|
||||||
|
]);
|
||||||
|
$pedido = $gdc->subpedidos()->where([
|
||||||
|
'nombre' => 'Pedido de Ollas de ' . $gdc->nombre
|
||||||
|
])->first();
|
||||||
|
$pedido->cantidad_ollas = $valid['cantidad'];
|
||||||
|
$pedido->save();
|
||||||
|
return response()->noContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ class GrupoDeCompraResource extends JsonResource
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'nombre' => $this->nombre,
|
'nombre' => $this->nombre,
|
||||||
'devoluciones_habilitadas' => $this->devoluciones_habilitadas,
|
'devoluciones_habilitadas' => $this->devoluciones_habilitadas,
|
||||||
'pedidos' => SubpedidoResource::collection($this->subpedidos),
|
'pedidos' => SubpedidoResource::collection($this->pedidosHogares()),
|
||||||
'total_a_recaudar' => number_format($this->totalARecaudar(),2),
|
'total_a_recaudar' => number_format($this->totalARecaudar(),2),
|
||||||
'saldo' => number_format($this->saldo, 2, ".", ""),
|
'saldo' => number_format($this->saldo, 2, ".", ""),
|
||||||
'total_sin_devoluciones' => number_format($this->totalSinDevoluciones(),2),
|
'total_sin_devoluciones' => number_format($this->totalSinDevoluciones(),2),
|
||||||
|
|
30
app/Http/Resources/PedidoOllasResource.php
Normal file
30
app/Http/Resources/PedidoOllasResource.php
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use App\TipoPedido;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class PedidoOllasResource 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,
|
||||||
|
'total' => number_format($this->totalCentralesSinTransporte(),2),
|
||||||
|
'cantidad_de_ollas' => $this->cantidad_ollas,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,9 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use League\Csv\CannotInsertRecord;
|
||||||
use League\Csv\Exception;
|
use League\Csv\Exception;
|
||||||
|
use League\Csv\InvalidArgument;
|
||||||
|
|
||||||
class Producto extends Model
|
class Producto extends Model
|
||||||
{
|
{
|
||||||
|
@ -19,15 +21,10 @@ class Producto extends Model
|
||||||
|
|
||||||
public function subpedidos(): BelongsToMany
|
public function subpedidos(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Subpedido::class, 'productos_subpedidos')->withPivot(["cantidad", "notas"]);
|
return $this->belongsToMany(Subpedido::class, 'productos_subpedidos')
|
||||||
|
->withPivot(["cantidad", "notas"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function noBarriales()
|
|
||||||
{
|
|
||||||
return self::where('nombre', 'not like', '%barrial%');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Este método permite que se apliquen los filtros al hacer una request (por ejemplo, de búsqueda)
|
|
||||||
public function scopeFiltrar($query, FiltroDeProducto $filtros): Builder
|
public function scopeFiltrar($query, FiltroDeProducto $filtros): Builder
|
||||||
{
|
{
|
||||||
return $filtros->aplicar($query);
|
return $filtros->aplicar($query);
|
||||||
|
@ -35,7 +32,9 @@ class Producto extends Model
|
||||||
|
|
||||||
public static function getPaginar(Request $request): int
|
public static function getPaginar(Request $request): int
|
||||||
{
|
{
|
||||||
return $request->has('paginar') && intval($request->input('paginar')) ? intval($request->input('paginar')) : self::all()->count();
|
return $request->has('paginar') && intval($request->input('paginar')) ?
|
||||||
|
intval($request->input('paginar')) :
|
||||||
|
self::all()->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function productosFilaID()
|
public static function productosFilaID()
|
||||||
|
@ -53,19 +52,30 @@ class Producto extends Model
|
||||||
return self::noBarriales()->pluck('nombre', 'id')->all();
|
return self::noBarriales()->pluck('nombre', 'id')->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function noBarriales()
|
||||||
|
{
|
||||||
|
return self::where('nombre', 'not like', '%barrial%');
|
||||||
|
}
|
||||||
|
|
||||||
static public function cantidadesPorBarrio(): Collection
|
static public function cantidadesPorBarrio(): Collection
|
||||||
{
|
{
|
||||||
$barrios = GrupoDeCompra::barriosMenosPrueba()
|
$barrios = GrupoDeCompra::barriosMenosPruebaConPedidosAprobados()->pluck('id', 'nombre');
|
||||||
->pluck('id', 'nombre');
|
|
||||||
|
|
||||||
$columnasBarrios = $barrios->map(function ($id, $nombre) {
|
$columnasBarrios = $barrios->map(function ($id, $nombre) {
|
||||||
return DB::raw("SUM(CASE WHEN subpedidos.grupo_de_compra_id = $id AND subpedidos.aprobado = 1 THEN producto_subpedido.cantidad ELSE 0 END) as `$nombre`");
|
return DB::raw("
|
||||||
|
SUM(CASE WHEN subpedidos.grupo_de_compra_id = $id
|
||||||
|
AND subpedidos.aprobado = 1
|
||||||
|
AND subpedidos.tipo_pedido_id = 1
|
||||||
|
THEN producto_subpedido.cantidad
|
||||||
|
ELSE 0 END)
|
||||||
|
as `$nombre`");
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
|
||||||
return DB::table('productos')
|
return DB::table('productos')
|
||||||
->where('productos.nombre', 'not like', '%barrial%')
|
->where('productos.nombre', 'not like', '%barrial%')
|
||||||
->leftJoin('producto_subpedido', 'productos.id', '=', 'producto_subpedido.producto_id')
|
->leftJoin('producto_subpedido', 'productos.id', '=', 'producto_subpedido.producto_id')
|
||||||
->leftJoin('subpedidos', 'subpedidos.id', '=', 'producto_subpedido.subpedido_id')
|
->leftJoin('subpedidos', 'subpedidos.id', '=', 'producto_subpedido.subpedido_id')
|
||||||
|
->where('subpedidos.tipo_pedido_id', '=', 1)
|
||||||
->select(array_merge(
|
->select(array_merge(
|
||||||
['productos.fila as fila'],
|
['productos.fila as fila'],
|
||||||
['productos.nombre as producto'],
|
['productos.nombre as producto'],
|
||||||
|
@ -82,8 +92,7 @@ class Producto extends Model
|
||||||
static public function planillaTotales()
|
static public function planillaTotales()
|
||||||
{
|
{
|
||||||
$headers = ['Producto'];
|
$headers = ['Producto'];
|
||||||
$barrios = GrupoDeCompra::barriosMenosPrueba()
|
$barrios = GrupoDeCompra::barriosMenosPruebaConPedidosAprobados()->pluck('nombre')->toArray();
|
||||||
->pluck('nombre')->toArray();
|
|
||||||
$headers = array_merge($headers, $barrios);
|
$headers = array_merge($headers, $barrios);
|
||||||
|
|
||||||
$cantidadesPorBarrio = self::cantidadesPorBarrio();
|
$cantidadesPorBarrio = self::cantidadesPorBarrio();
|
||||||
|
@ -109,21 +118,24 @@ class Producto extends Model
|
||||||
$ultimaFila = $fila;
|
$ultimaFila = $fila;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($transportePorBarrio as $key => $cantidad) {
|
foreach ($transportePorBarrio as $cantidad) {
|
||||||
$planilla[$filaTransporte][] = $cantidad;
|
$planilla[$filaTransporte][] = $cantidad;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fecha = now()->format('Y-m-d');
|
$fecha = now()->format('Y-m-d');
|
||||||
CsvHelper::generarCsv('csv/exports/pedidos-por-barrio- ' . $fecha . '.csv', $planilla, $headers);
|
$filePath = 'csv/exports/pedidos-por-barrio- ' . $fecha . '.csv';
|
||||||
|
CsvHelper::generarCsv($filePath, $planilla, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function notasPorBarrio(): Collection
|
public static function notasPorBarrio(): Collection
|
||||||
{
|
{
|
||||||
return DB::table('productos')
|
return DB::table('productos')
|
||||||
|
->where('productos.nombre', 'not like', '%barrial%')
|
||||||
->join('producto_subpedido', 'productos.id', '=', 'producto_subpedido.producto_id')
|
->join('producto_subpedido', 'productos.id', '=', 'producto_subpedido.producto_id')
|
||||||
->join('subpedidos', 'producto_subpedido.subpedido_id', '=', 'subpedidos.id')
|
->join('subpedidos', 'producto_subpedido.subpedido_id', '=', 'subpedidos.id')
|
||||||
->join('grupos_de_compra', 'subpedidos.grupo_de_compra_id', '=', 'grupos_de_compra.id')
|
->join('grupos_de_compra', 'subpedidos.grupo_de_compra_id', '=', 'grupos_de_compra.id')
|
||||||
->where('productos.requiere_notas', 1)
|
->where('productos.requiere_notas', 1)
|
||||||
|
->where('subpedidos.tipo_pedido_id', '=', 1)
|
||||||
->select(
|
->select(
|
||||||
'productos.nombre as producto',
|
'productos.nombre as producto',
|
||||||
'grupos_de_compra.nombre as barrio',
|
'grupos_de_compra.nombre as barrio',
|
||||||
|
@ -133,9 +145,13 @@ class Producto extends Model
|
||||||
->groupBy('producto');
|
->groupBy('producto');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws InvalidArgument
|
||||||
|
* @throws CannotInsertRecord
|
||||||
|
*/
|
||||||
static public function planillaNotas() {
|
static public function planillaNotas() {
|
||||||
$headers = ['Producto'];
|
$headers = ['Producto'];
|
||||||
$barrios = GrupoDeCompra::barriosMenosPrueba()
|
$barrios = GrupoDeCompra::barriosMenosPruebaConPedidosAprobados()
|
||||||
->pluck('nombre')->toArray();
|
->pluck('nombre')->toArray();
|
||||||
$headers = array_merge($headers, $barrios);
|
$headers = array_merge($headers, $barrios);
|
||||||
|
|
||||||
|
@ -145,13 +161,16 @@ class Producto extends Model
|
||||||
foreach ($notasPorBarrio as $producto => $notasGrupo) {
|
foreach ($notasPorBarrio as $producto => $notasGrupo) {
|
||||||
$fila = [$producto];
|
$fila = [$producto];
|
||||||
foreach ($barrios as $barrio) {
|
foreach ($barrios as $barrio) {
|
||||||
$notas = $notasGrupo->where('barrio', $barrio)->pluck('notas')->implode('; ');
|
$notas = $notasGrupo->where('barrio', $barrio)
|
||||||
|
->pluck('notas')
|
||||||
|
->implode('; ');
|
||||||
$fila[] = $notas ?: '';
|
$fila[] = $notas ?: '';
|
||||||
}
|
}
|
||||||
$planilla[] = $fila;
|
$planilla[] = $fila;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fecha = now()->format('Y-m-d');
|
$fecha = now()->format('Y-m-d');
|
||||||
CsvHelper::generarCsv('csv/exports/notas-por-barrio-' . $fecha . '.csv', $planilla, $headers);
|
$filePath = 'csv/exports/notas-por-barrio-' . $fecha . '.csv';
|
||||||
|
CsvHelper::generarCsv($filePath, $planilla, $headers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,15 @@ use App\Filtros\FiltroDeSubpedido;
|
||||||
|
|
||||||
class Subpedido extends Model
|
class Subpedido extends Model
|
||||||
{
|
{
|
||||||
protected $fillable = ['grupo_de_compra_id', 'aprobado', 'nombre', 'devoluciones_total', 'devoluciones_notas', 'tipo_pedido_id'];
|
protected $fillable = [
|
||||||
|
'grupo_de_compra_id',
|
||||||
|
'aprobado',
|
||||||
|
'nombre',
|
||||||
|
'devoluciones_total',
|
||||||
|
'devoluciones_notas',
|
||||||
|
'tipo_pedido_id',
|
||||||
|
'cantidad_ollas'
|
||||||
|
];
|
||||||
|
|
||||||
public function productos(): BelongsToMany
|
public function productos(): BelongsToMany
|
||||||
{
|
{
|
||||||
|
@ -57,7 +65,11 @@ class Subpedido extends Model
|
||||||
|
|
||||||
public function totalCentral()
|
public function totalCentral()
|
||||||
{
|
{
|
||||||
return $this->totalCentralesQueNoPaganTransporte() + $this->totalCentralesQuePaganTransporte() + $this->totalTransporte();
|
return $this->totalCentralesSinTransporte() + $this->totalTransporte();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function totalCentralesSinTransporte() {
|
||||||
|
return $this->totalCentralesQueNoPaganTransporte() + $this->totalCentralesQuePaganTransporte();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function totalCentralesQueNoPaganTransporte()
|
public function totalCentralesQueNoPaganTransporte()
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Subpedido;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CantidadOllasPedidos extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('subpedidos', function (Blueprint $table) {
|
||||||
|
$table->integer('cantidad_ollas')->nullable();
|
||||||
|
});
|
||||||
|
Subpedido::where('tipo_pedido_id', 1)->update(['cantidad_ollas' => 0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('subpedidos', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('cantidad_ollas');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
0
resources/csv/exports/.gitignore
vendored
0
resources/csv/exports/.gitignore
vendored
3
resources/csv/parametros.csv
Normal file
3
resources/csv/parametros.csv
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
id|nombre|valor
|
||||||
|
bono-transporte|'Bono de transporte'|15
|
||||||
|
monto-olla|'Monto por olla'|1200
|
|
|
@ -1,10 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations, mapState } from "vuex";
|
import { mapGetters, mapMutations, mapState } from "vuex";
|
||||||
import Burger from "../comunes/Burger.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "AdminNavBar",
|
name: "AdminNavBarBrand",
|
||||||
components: { Burger },
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('ui', ["burger_activa"]),
|
...mapState('ui', ["burger_activa"]),
|
||||||
...mapGetters('admin', ["barrio"])
|
...mapGetters('admin', ["barrio"])
|
||||||
|
@ -20,7 +18,6 @@ export default {
|
||||||
<p>
|
<p>
|
||||||
{{`Barrio: ${barrio}`}}
|
{{`Barrio: ${barrio}`}}
|
||||||
</p>
|
</p>
|
||||||
<burger/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -18,6 +18,11 @@
|
||||||
:class="seccionActiva === 'saldos-comisiones-seccion' ? 'is-active' : 'is-hidden'">
|
:class="seccionActiva === 'saldos-comisiones-seccion' ? 'is-active' : 'is-hidden'">
|
||||||
<saldos-seccion/>
|
<saldos-seccion/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="block pb-6"
|
||||||
|
id="parametros-comisiones-seccion"
|
||||||
|
:class="seccionActiva === 'parametros-comisiones-seccion' ? 'is-active' : 'is-hidden'">
|
||||||
|
<parametros-seccion/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -27,11 +32,12 @@ import DropdownDescargar from "./DropdownDescargar.vue";
|
||||||
import InputFileButton from "../comunes/InputFileButton.vue";
|
import InputFileButton from "../comunes/InputFileButton.vue";
|
||||||
import CanastaSeccion from "./canasta/CanastaSeccion.vue";
|
import CanastaSeccion from "./canasta/CanastaSeccion.vue";
|
||||||
import SaldosSeccion from "./saldos/SaldosSeccion.vue";
|
import SaldosSeccion from "./saldos/SaldosSeccion.vue";
|
||||||
import { mapActions } from "vuex";
|
import ParametrosSeccion from "./parametros/ParametrosSeccion.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ComisionesBody",
|
name: "ComisionesBody",
|
||||||
components: {
|
components: {
|
||||||
|
ParametrosSeccion,
|
||||||
SaldosSeccion,
|
SaldosSeccion,
|
||||||
CanastaSeccion,
|
CanastaSeccion,
|
||||||
TabsSecciones,
|
TabsSecciones,
|
||||||
|
@ -44,6 +50,7 @@ export default {
|
||||||
{ id: "pedidos-comisiones", nombre: "Pedidos" },
|
{ id: "pedidos-comisiones", nombre: "Pedidos" },
|
||||||
{ id: "canasta-comisiones", nombre: "Canasta" },
|
{ id: "canasta-comisiones", nombre: "Canasta" },
|
||||||
{ id: "saldos-comisiones", nombre: "Saldos" },
|
{ id: "saldos-comisiones", nombre: "Saldos" },
|
||||||
|
{ id: "parametros-comisiones", nombre: "Parámetros" },
|
||||||
],
|
],
|
||||||
tabActiva: "pedidos-comisiones",
|
tabActiva: "pedidos-comisiones",
|
||||||
seccionActiva: "pedidos-comisiones-seccion",
|
seccionActiva: "pedidos-comisiones-seccion",
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
import { mapMutations, mapState } from "vuex";
|
import { mapMutations, mapState } from "vuex";
|
||||||
import Burger from "../comunes/Burger.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ComisionesNavBar",
|
name: "ComisionesNavBarBrand",
|
||||||
components: { Burger },
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('ui', ["burger_activa"])
|
...mapState('ui', ["burger_activa"])
|
||||||
},
|
},
|
||||||
|
@ -26,7 +24,6 @@ export default {
|
||||||
<template>
|
<template>
|
||||||
<div class="navbar-item hide-below-1024">
|
<div class="navbar-item hide-below-1024">
|
||||||
<p>{{ nombre }}</p>
|
<p>{{ nombre }}</p>
|
||||||
<burger/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
<script>
|
||||||
|
import {mapActions, mapGetters} from "vuex";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
parametro: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
control: this.parametro.valor,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
hayCambios() {
|
||||||
|
return this.control !== this.parametro.valor;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions("comisiones", ["cambiarParametro"]),
|
||||||
|
modificar() {
|
||||||
|
this.cambiarParametro({
|
||||||
|
parametro_id: this.parametro.id,
|
||||||
|
valor: this.control,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<tr>
|
||||||
|
<td>{{ parametro.nombre }}</td>
|
||||||
|
<td>
|
||||||
|
<div class="field">
|
||||||
|
<input :type="parametro.tipo"
|
||||||
|
:id="'input-' + parametro.id"
|
||||||
|
v-model="control"
|
||||||
|
class="has-text-right">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="has-text-centered">
|
||||||
|
<div class="control">
|
||||||
|
<button class="button is-small is-success"
|
||||||
|
@click="modificar"
|
||||||
|
:disabled="!hayCambios">
|
||||||
|
<span class="icon">
|
||||||
|
<i class="fas fa-check"></i>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="has-text-centered">
|
||||||
|
<div class="control">
|
||||||
|
<button class="button is-small is-danger"
|
||||||
|
@click="control = parametro.valor"
|
||||||
|
:disabled="!hayCambios">
|
||||||
|
<span class="icon">
|
||||||
|
<i class="fa fa-undo" aria-hidden="true"></i>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
|
@ -0,0 +1,41 @@
|
||||||
|
<script>
|
||||||
|
import FilaCaracteristica from "../../admin/FilaCaracteristica.vue";
|
||||||
|
import FilaParametro from "./FilaParametro.vue";
|
||||||
|
import { mapActions, mapState } from "vuex";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name:"ParametrosSeccion",
|
||||||
|
components: { FilaParametro, FilaCaracteristica },
|
||||||
|
methods: {
|
||||||
|
...mapActions("comisiones", ["getParametros"]),
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState("comisiones", ["parametros"]),
|
||||||
|
},
|
||||||
|
async mounted() {
|
||||||
|
await this.getParametros();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<table class="table is-striped is-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> Parámetro </th>
|
||||||
|
<th> Valor $ </th>
|
||||||
|
<th> Cambiar </th>
|
||||||
|
<th> Deshacer </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<fila-parametro v-for="(p,i) in parametros"
|
||||||
|
:key="i"
|
||||||
|
:parametro="p"/>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
|
@ -7,13 +7,20 @@
|
||||||
<a class="navbar-item" href="https://mps.org.uy">
|
<a class="navbar-item" href="https://mps.org.uy">
|
||||||
<img src="/assets/logoMPS.png" height="28" alt="Logo del MPS">
|
<img src="/assets/logoMPS.png" height="28" alt="Logo del MPS">
|
||||||
</a>
|
</a>
|
||||||
<pedidos-nav-bar v-if="rol === 'barrio'"/>
|
<pedidos-nav-bar-brand v-if="rol === 'barrio'"/>
|
||||||
<ollas-nav-bar v-else-if="rol === 'ollas'"/>
|
<ollas-nav-bar-brand v-else-if="rol === 'ollas'"/>
|
||||||
<admin-nav-bar v-else-if="rol === 'admin_barrio'"/>
|
<admin-nav-bar-brand v-else-if="rol === 'admin_barrio'"/>
|
||||||
<comisiones-nav-bar v-else/>
|
<comisiones-nav-bar-brand v-else/>
|
||||||
|
<burger/>
|
||||||
|
</div>
|
||||||
|
<div class="navbar-menu" :class="{'is-active': burger_activa}">
|
||||||
|
<div class="navbar-start is-flex is-justify-content-center is-flex-grow-1">
|
||||||
|
<div v-if="mostrarAviso" class="is-absolute-center is-flex is-align-items-center navbar-item">
|
||||||
|
<span class="tag is-warning is-size-6">
|
||||||
|
Monto superado
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="navbar-menu"
|
|
||||||
:class="{'is-active': burger_activa}">
|
|
||||||
<div class="navbar-end">
|
<div class="navbar-end">
|
||||||
<buscador v-if="pedidoDefinido"/>
|
<buscador v-if="pedidoDefinido"/>
|
||||||
<chismosa-dropdown v-if="pedidoDefinido"
|
<chismosa-dropdown v-if="pedidoDefinido"
|
||||||
|
@ -32,18 +39,23 @@
|
||||||
<script>
|
<script>
|
||||||
import ChismosaDropdown from '../pedidos/ChismosaDropdown.vue';
|
import ChismosaDropdown from '../pedidos/ChismosaDropdown.vue';
|
||||||
import { mapGetters, mapState } from "vuex";
|
import { mapGetters, mapState } from "vuex";
|
||||||
import PedidosNavBar from "../pedidos/PedidosNavBar.vue";
|
import PedidosNavBarBrand from "../pedidos/PedidosNavBarBrand.vue";
|
||||||
import ComisionesNavBar from "../comisiones/ComisionesNavBar.vue";
|
import ComisionesNavBarBrand from "../comisiones/ComisionesNavBarBrand.vue";
|
||||||
import AdminNavBar from "../admin/AdminNavBar.vue";
|
import AdminNavBarBrand from "../admin/AdminNavBarBrand.vue";
|
||||||
import OllasNavBar from "../ollas/OllasNavBar.vue";
|
import OllasNavBarBrand from "../ollas/OllasNavBarBrand.vue";
|
||||||
import Buscador from "../pedidos/Buscador.vue";
|
import Buscador from "../pedidos/Buscador.vue";
|
||||||
|
import Burger from "./Burger.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { Buscador, OllasNavBar, AdminNavBar, ComisionesNavBar, PedidosNavBar, ChismosaDropdown },
|
components: { Burger, Buscador, OllasNavBarBrand, AdminNavBarBrand, ComisionesNavBarBrand, PedidosNavBarBrand, ChismosaDropdown },
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters('pedido', ["pedidoDefinido"]),
|
...mapGetters('pedido', ["pedidoDefinido"]),
|
||||||
|
...mapGetters('ollas', ["montoSuperado"]),
|
||||||
...mapState('login', ["rol"]),
|
...mapState('login', ["rol"]),
|
||||||
...mapState('ui', ["burger_activa"])
|
...mapState('ui', ["burger_activa"]),
|
||||||
|
mostrarAviso() {
|
||||||
|
return this.pedidoDefinido && this.rol === 'ollas' && this.montoSuperado;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
logOut() {
|
logOut() {
|
||||||
|
@ -55,4 +67,9 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.is-absolute-center {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
71
resources/js/components/ollas/CantidadOllas.vue
Normal file
71
resources/js/components/ollas/CantidadOllas.vue
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<script>
|
||||||
|
import { mapActions, mapMutations, mapState } from "vuex";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "CantidadOllas",
|
||||||
|
methods: {
|
||||||
|
...mapActions("ollas", ["actualizarCantidadOllas"]),
|
||||||
|
...mapMutations("pedido", ["setCantidadOllas"]),
|
||||||
|
incrementar() {
|
||||||
|
this.control += 1;
|
||||||
|
this.actualizarDebounced();
|
||||||
|
},
|
||||||
|
decrementar() {
|
||||||
|
this.control -= 1;
|
||||||
|
this.actualizarDebounced();
|
||||||
|
},
|
||||||
|
async actualizarDebounced() {
|
||||||
|
const params = { cantidad: this.control };
|
||||||
|
clearTimeout(this.debounceTimer);
|
||||||
|
this.debounceTimer = setTimeout(() => {
|
||||||
|
this.setCantidadOllas(params);
|
||||||
|
this.actualizarCantidadOllas(params);
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState("pedido", ["cantidad_de_ollas"])
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
debounceTimer: null,
|
||||||
|
control: 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
cantidad_de_ollas() {
|
||||||
|
this.control = this.cantidad_de_ollas;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="notification has-text-centered">
|
||||||
|
<label class="label">Cantidad de ollas:</label>
|
||||||
|
<div class="field has-addons is-justify-content-center contador">
|
||||||
|
<div class="control">
|
||||||
|
<button class="button is-small"
|
||||||
|
:disabled="control < 1"
|
||||||
|
@click.capture="decrementar">
|
||||||
|
<i class="fa fa-solid fa-minus"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
<input id="cantidad"
|
||||||
|
v-model="control"
|
||||||
|
class="input is-small has-text-centered"
|
||||||
|
type="number"
|
||||||
|
@input="actualizarDebounced">
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
<button class="button is-small" @click="incrementar">
|
||||||
|
<i class="fa fa-solid fa-plus"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
|
@ -1,10 +1,11 @@
|
||||||
<script>
|
<script>
|
||||||
import PedidosMain from "../pedidos/PedidosMain.vue";
|
import PedidosMain from "../pedidos/PedidosMain.vue";
|
||||||
import { mapActions, mapMutations } from "vuex";
|
import { mapActions, mapMutations } from "vuex";
|
||||||
|
import CantidadOllas from "./CantidadOllas.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "OllasBody",
|
name: "OllasBody",
|
||||||
components: { PedidosMain },
|
components: { CantidadOllas, PedidosMain },
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('pedido', ["getPedidoDeOllas", "getGrupoDeCompra"]),
|
...mapActions('pedido', ["getPedidoDeOllas", "getGrupoDeCompra"]),
|
||||||
...mapMutations('ui', ["migasOllas"])
|
...mapMutations('ui', ["migasOllas"])
|
||||||
|
@ -19,7 +20,11 @@ export default {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div id="ollas-body" class="pb-6 mb-6">
|
<div id="ollas-body" class="pb-6 mb-6">
|
||||||
<pedidos-main></pedidos-main>
|
<pedidos-main>
|
||||||
|
<template v-slot:cartel>
|
||||||
|
<cantidad-ollas/>
|
||||||
|
</template>
|
||||||
|
</pedidos-main>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,33 @@
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations, mapState } from "vuex";
|
import { mapActions, mapGetters, mapMutations, mapState } from "vuex";
|
||||||
import Burger from "../comunes/Burger.vue";
|
|
||||||
import ChismosaDropdown from "../pedidos/ChismosaDropdown.vue";
|
import ChismosaDropdown from "../pedidos/ChismosaDropdown.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "OllasNavBar",
|
name: "OllasNavBarBrand",
|
||||||
components: { Burger, ChismosaDropdown },
|
components: { ChismosaDropdown },
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters('pedido', ["pedidoDefinido"]),
|
...mapGetters('pedido', ["pedidoDefinido"]),
|
||||||
|
...mapGetters('ollas', ["montoTotal"]),
|
||||||
|
...mapState('ui', ["burger_activa"]),
|
||||||
...mapState('pedido', ["nombre"]),
|
...mapState('pedido', ["nombre"]),
|
||||||
...mapState('ui', ["burger_activa"])
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapActions('ollas', ["getMontoPorOlla"]),
|
||||||
...mapMutations('ui', ["toggleBurger"]),
|
...mapMutations('ui', ["toggleBurger"]),
|
||||||
},
|
},
|
||||||
|
async mounted() {
|
||||||
|
await this.getMontoPorOlla();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="navbar-item hide-below-1024">
|
<div class="navbar-item hide-below-1024">
|
||||||
<p v-if="pedidoDefinido">{{ nombre }}</p>
|
<p v-if="pedidoDefinido">{{ `${nombre} - Monto total: ${montoTotal}` }}</p>
|
||||||
<chismosa-dropdown
|
<chismosa-dropdown
|
||||||
v-if="pedidoDefinido"
|
v-if="pedidoDefinido"
|
||||||
class="hide-above-1023"
|
class="hide-above-1023"
|
||||||
ariaControls="mobile"/>
|
ariaControls="mobile"/>
|
||||||
<burger/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="pedidos-body" class="pb-6 mb-6">
|
<div id="pedidos-body" class="pb-6 mb-6">
|
||||||
<pedido-select v-if="!pedidoDefinido"/>
|
<pedido-select v-if="!pedidoDefinido"/>
|
||||||
<pedidos-main v-else/>
|
<pedidos-main v-else>
|
||||||
|
<template v-slot:cartel>
|
||||||
|
<cartel-pedido-aprobado/>
|
||||||
|
</template>
|
||||||
|
</pedidos-main>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -9,10 +13,11 @@
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
import PedidoSelect from "./PedidoSelect.vue";
|
import PedidoSelect from "./PedidoSelect.vue";
|
||||||
import PedidosMain from "./PedidosMain.vue";
|
import PedidosMain from "./PedidosMain.vue";
|
||||||
|
import CartelPedidoAprobado from "./CartelPedidoAprobado.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "PedidosBody",
|
name: "PedidosBody",
|
||||||
components: { PedidosMain, PedidoSelect },
|
components: { CartelPedidoAprobado, PedidosMain, PedidoSelect },
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters('pedido', ["pedidoDefinido"]),
|
...mapGetters('pedido', ["pedidoDefinido"]),
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<span class="icon is-small mr-1">
|
<span class="icon is-small mr-1">
|
||||||
<img src="/assets/chismosa.png">
|
<img src="/assets/chismosa.png">
|
||||||
</span>
|
</span>
|
||||||
<span v-text="'$' + total"></span>
|
<span v-text="'$' + total"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<nav class="breadcrumb is-centered has-background-danger-light is-fixed-top"
|
<nav class="breadcrumb is-centered has-background-danger-light is-fixed-top"
|
||||||
aria-label="breadcrumbs" v-show="visible">
|
aria-label="breadcrumbs">
|
||||||
<ul class="mt-4">
|
<ul class="mt-4">
|
||||||
<li v-for="(miga, i) in migas" :key="i" :class="{'is-active': i === migaActiva}">
|
<li v-for="(miga, i) in migas" :key="i" :class="{'is-active': i === migaActiva}">
|
||||||
<a @click="clickMiga({ miga: miga })"
|
<a @click="clickMiga({ miga: miga })"
|
||||||
|
@ -17,15 +17,11 @@ import { mapActions, mapMutations, mapState } from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('productos', ["getProductos"]),
|
|
||||||
...mapActions('ui', ["clickMiga"]),
|
...mapActions('ui', ["clickMiga"]),
|
||||||
...mapMutations('ui', ["addMiga"]),
|
...mapMutations('ui', ["addMiga"]),
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('ui', ["migas"]),
|
...mapState('ui', ["migas"]),
|
||||||
visible() {
|
|
||||||
return this.migas.length > 0;
|
|
||||||
},
|
|
||||||
migaActiva() {
|
migaActiva() {
|
||||||
return this.migas.length - 1;
|
return this.migas.length - 1;
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,13 +2,12 @@
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import Canasta from "./Canasta.vue";
|
import Canasta from "./Canasta.vue";
|
||||||
import Chismosa from "./Chismosa.vue";
|
import Chismosa from "./Chismosa.vue";
|
||||||
import CartelPedidoAprobado from "./CartelPedidoAprobado.vue";
|
|
||||||
import NavMigas from "./NavMigas.vue";
|
import NavMigas from "./NavMigas.vue";
|
||||||
import { mapActions, mapState } from "vuex";
|
import { mapActions, mapState } from "vuex";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "PedidosMain",
|
name: "PedidosMain",
|
||||||
components: { NavMigas, CartelPedidoAprobado, Chismosa, Canasta },
|
components: { NavMigas, Chismosa, Canasta },
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('ui', ["show_chismosa"]),
|
...mapState('ui', ["show_chismosa"]),
|
||||||
},
|
},
|
||||||
|
@ -26,7 +25,7 @@ export default defineComponent({
|
||||||
<nav-migas/>
|
<nav-migas/>
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column" :class="{ 'is-two-thirds-desktop is-hidden-touch': show_chismosa }">
|
<div class="column" :class="{ 'is-two-thirds-desktop is-hidden-touch': show_chismosa }">
|
||||||
<cartel-pedido-aprobado/>
|
<slot name="cartel"></slot>
|
||||||
<canasta/>
|
<canasta/>
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-full-touch" v-if="show_chismosa">
|
<div class="column is-full-touch" v-if="show_chismosa">
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations, mapState } from "vuex";
|
import { mapGetters, mapMutations, mapState } from "vuex";
|
||||||
import ChismosaDropdown from "./ChismosaDropdown.vue";
|
import ChismosaDropdown from "./ChismosaDropdown.vue";
|
||||||
import Burger from "../comunes/Burger.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "PedidosNavBar",
|
name: "PedidosNavBarBrand",
|
||||||
components: { Burger, ChismosaDropdown },
|
components: { ChismosaDropdown },
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters('pedido', ["pedidoDefinido"]),
|
...mapGetters('pedido', ["pedidoDefinido"]),
|
||||||
...mapState('pedido', ["nombre", "grupo_de_compra"]),
|
...mapState('pedido', ["nombre", "grupo_de_compra"]),
|
||||||
|
@ -26,7 +25,6 @@ export default {
|
||||||
v-if="pedidoDefinido"
|
v-if="pedidoDefinido"
|
||||||
class="hide-above-1023"
|
class="hide-above-1023"
|
||||||
ariaControls="mobile"/>
|
ariaControls="mobile"/>
|
||||||
<burger/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
2
resources/js/store/index.js
vendored
2
resources/js/store/index.js
vendored
|
@ -6,6 +6,7 @@ import login from "./modules/login";
|
||||||
import pedido from "./modules/pedido";
|
import pedido from "./modules/pedido";
|
||||||
import productos from "./modules/productos";
|
import productos from "./modules/productos";
|
||||||
import ui from "./modules/ui";
|
import ui from "./modules/ui";
|
||||||
|
import ollas from "./modules/ollas";
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
|
@ -17,5 +18,6 @@ export default new Vuex.Store({
|
||||||
pedido,
|
pedido,
|
||||||
productos,
|
productos,
|
||||||
ui,
|
ui,
|
||||||
|
ollas,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
26
resources/js/store/modules/comisiones.js
vendored
26
resources/js/store/modules/comisiones.js
vendored
|
@ -3,6 +3,7 @@ import axios from "axios";
|
||||||
const state = {
|
const state = {
|
||||||
lastFetch: undefined,
|
lastFetch: undefined,
|
||||||
grupos_de_compra: [],
|
grupos_de_compra: [],
|
||||||
|
parametros: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
|
@ -10,6 +11,15 @@ const mutations = {
|
||||||
state.grupos_de_compra = data;
|
state.grupos_de_compra = data;
|
||||||
state.lastFetch = new Date();
|
state.lastFetch = new Date();
|
||||||
},
|
},
|
||||||
|
setParametros(state, parametros) {
|
||||||
|
state.parametros = parametros;
|
||||||
|
state.parametros.forEach(
|
||||||
|
p => p.valor = Number.parseInt(p.valor)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
actualizarParametro(state, { parametro_id, valor }) {
|
||||||
|
state.parametros.find(p => p.id === parametro_id).valor = valor;
|
||||||
|
},
|
||||||
setSaldo(state, { gdc_id, saldo }) {
|
setSaldo(state, { gdc_id, saldo }) {
|
||||||
const barrio = state.grupos_de_compra.find(gdc => gdc.id === gdc_id);
|
const barrio = state.grupos_de_compra.find(gdc => gdc.id === gdc_id);
|
||||||
const i = state.grupos_de_compra.indexOf(barrio);
|
const i = state.grupos_de_compra.indexOf(barrio);
|
||||||
|
@ -22,6 +32,22 @@ const actions = {
|
||||||
const response = await axios.get('/api/grupos-de-compra/saldos');
|
const response = await axios.get('/api/grupos-de-compra/saldos');
|
||||||
commit('setGruposDeCompra', response.data);
|
commit('setGruposDeCompra', response.data);
|
||||||
},
|
},
|
||||||
|
async getParametros({ commit }) {
|
||||||
|
const response = await axios.get('/api/parametros');
|
||||||
|
commit('setParametros', response.data);
|
||||||
|
},
|
||||||
|
async cambiarParametro({ commit, dispatch }, { parametro_id, valor }) {
|
||||||
|
try {
|
||||||
|
await axios.put(
|
||||||
|
`/comisiones/parametros/${parametro_id}`,
|
||||||
|
{ valor: valor }
|
||||||
|
);
|
||||||
|
commit('actualizarParametro', { parametro_id, valor });
|
||||||
|
dispatch("ui/toast", { mensaje: 'Parámetro modificado con éxito' }, { root: true });
|
||||||
|
} catch (error) {
|
||||||
|
dispatch("ui/error", { error: error }, { root: true });
|
||||||
|
}
|
||||||
|
},
|
||||||
async setSaldo({ commit, dispatch }, { gdc_id, saldo }) {
|
async setSaldo({ commit, dispatch }, { gdc_id, saldo }) {
|
||||||
try {
|
try {
|
||||||
await axios.post(
|
await axios.post(
|
||||||
|
|
2
resources/js/store/modules/login.js
vendored
2
resources/js/store/modules/login.js
vendored
|
@ -103,7 +103,7 @@ const getters = {
|
||||||
};
|
};
|
||||||
case 'comisiones':
|
case 'comisiones':
|
||||||
return {
|
return {
|
||||||
fondo: "has-background-grey-light",
|
fondo: "",
|
||||||
texto: "",
|
texto: "",
|
||||||
botones: "is-dark"
|
botones: "is-dark"
|
||||||
};
|
};
|
||||||
|
|
40
resources/js/store/modules/ollas.js
vendored
Normal file
40
resources/js/store/modules/ollas.js
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
monto_por_olla: undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
const mutations = {
|
||||||
|
setMontoPorOlla(state, parametros) {
|
||||||
|
state.monto_por_olla = Number.parseInt(parametros.find(p => p.id === 'monto-olla').valor);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
async getMontoPorOlla({ commit }) {
|
||||||
|
const response = await axios.get('/api/parametros');
|
||||||
|
commit('setMontoPorOlla', response.data);
|
||||||
|
},
|
||||||
|
async actualizarCantidadOllas({ rootState }, { cantidad: cantidad}) {
|
||||||
|
const barrio = rootState.pedido.grupo_de_compra.id;
|
||||||
|
const params = { cantidad : cantidad };
|
||||||
|
await axios.put(`/ollas/${barrio}/cantidad`, params);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getters = {
|
||||||
|
montoTotal(state, _, rootState) {
|
||||||
|
return state.monto_por_olla * rootState.pedido.cantidad_de_ollas;
|
||||||
|
},
|
||||||
|
montoSuperado: (_, getters, rootState) => {
|
||||||
|
return rootState.pedido.total > getters.montoTotal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state,
|
||||||
|
mutations,
|
||||||
|
actions,
|
||||||
|
getters,
|
||||||
|
};
|
53
resources/js/store/modules/pedido.js
vendored
53
resources/js/store/modules/pedido.js
vendored
|
@ -3,16 +3,17 @@ import axios from "axios";
|
||||||
const state = {
|
const state = {
|
||||||
lastFetch: null,
|
lastFetch: null,
|
||||||
grupo_de_compra: null,
|
grupo_de_compra: null,
|
||||||
pedido_id: null,
|
pedido_id: 0,
|
||||||
nombre: null,
|
nombre: "",
|
||||||
productos: null,
|
productos: [],
|
||||||
aprobado: null,
|
aprobado: false,
|
||||||
total: null,
|
total: 0,
|
||||||
total_transporte: null,
|
total_transporte: 0,
|
||||||
cantidad_transporte: null,
|
cantidad_transporte: 0,
|
||||||
total_sin_devoluciones: null,
|
total_sin_devoluciones: 0,
|
||||||
devoluciones_total: null,
|
devoluciones_total: 0,
|
||||||
devoluciones_notas: null,
|
devoluciones_notas: "",
|
||||||
|
cantidad_de_ollas: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
|
@ -25,13 +26,27 @@ const mutations = {
|
||||||
state.nombre = pedido.nombre;
|
state.nombre = pedido.nombre;
|
||||||
state.productos = pedido.productos;
|
state.productos = pedido.productos;
|
||||||
state.aprobado = pedido.aprobado;
|
state.aprobado = pedido.aprobado;
|
||||||
state.total = pedido.total;
|
state.total = Number.parseFloat(pedido.total.replace(',',''));
|
||||||
state.total_transporte = pedido.total_transporte;
|
state.total_transporte = Number.parseInt(pedido.total_transporte?.replace(',',''));
|
||||||
state.cantidad_transporte = pedido.cantidad_transporte;
|
state.cantidad_transporte = Number.parseInt(pedido.cantidad_transporte?.replace(',',''));
|
||||||
state.total_sin_devoluciones = pedido.total_sin_devoluciones;
|
state.total_sin_devoluciones = Number.parseFloat(pedido.total_sin_devoluciones?.replace(',',''));
|
||||||
state.devoluciones_total = pedido.devoluciones_total;
|
state.devoluciones_total = Number.parseFloat(pedido.devoluciones_total?.replace(',',''));
|
||||||
state.devoluciones_notas = pedido.devoluciones_notas;
|
state.devoluciones_notas = pedido.devoluciones_notas;
|
||||||
},
|
},
|
||||||
|
setPedidoDeOllas(state, pedido) {
|
||||||
|
state.lastFetch = new Date();
|
||||||
|
state.pedido_id = pedido.id;
|
||||||
|
state.nombre = pedido.nombre;
|
||||||
|
state.productos = pedido.productos;
|
||||||
|
state.total = Number.parseFloat(pedido.total.replace(',',''));
|
||||||
|
state.cantidad_de_ollas = Number.parseInt(pedido.cantidad_de_ollas);
|
||||||
|
delete state.aprobado;
|
||||||
|
delete state.total_transporte;
|
||||||
|
delete state.cantidad_transporte;
|
||||||
|
delete state.total_sin_devoluciones;
|
||||||
|
delete state.devoluciones_total;
|
||||||
|
delete state.devoluciones_notas;
|
||||||
|
},
|
||||||
reset(state) {
|
reset(state) {
|
||||||
state.lastFetch = null;
|
state.lastFetch = null;
|
||||||
state.pedido_id = null;
|
state.pedido_id = null;
|
||||||
|
@ -44,6 +59,9 @@ const mutations = {
|
||||||
state.total_sin_devoluciones = null;
|
state.total_sin_devoluciones = null;
|
||||||
state.devoluciones_total = null;
|
state.devoluciones_total = null;
|
||||||
state.devoluciones_notas = null;
|
state.devoluciones_notas = null;
|
||||||
|
},
|
||||||
|
setCantidadOllas(state, { cantidad }) {
|
||||||
|
state.cantidad_de_ollas = cantidad;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,9 +113,8 @@ const actions = {
|
||||||
commit('reset');
|
commit('reset');
|
||||||
},
|
},
|
||||||
async getPedidoDeOllas({ commit }) {
|
async getPedidoDeOllas({ commit }) {
|
||||||
const response = await axios.get(`/api/ollas/${state.grupo_de_compra.id}`);
|
const response = await axios.get(`/ollas/${state.grupo_de_compra.id}`);
|
||||||
console.log(response);
|
commit('setPedidoDeOllas', response.data);
|
||||||
commit('setPedido', response.data);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,5 @@ Route::middleware('api')->group(function() {
|
||||||
Route::get('/','Api\ProductoController@index');
|
Route::get('/','Api\ProductoController@index');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('ollas')->group(function() {
|
Route::get('/parametros', 'ComisionesController@obtenerParametros');
|
||||||
Route::get('/{gdc}','Api\OllasController@pedido');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -56,10 +56,13 @@ Route::middleware(['auth', 'role:comision'])->group( function() {
|
||||||
Route::get('/comisiones/canasta/ejemplo', 'ComisionesController@descargarCanastaEjemplo')->name('comisiones.canasta.ejemplo');
|
Route::get('/comisiones/canasta/ejemplo', 'ComisionesController@descargarCanastaEjemplo')->name('comisiones.canasta.ejemplo');
|
||||||
Route::post('/comisiones/canasta', 'ComisionesController@cargarCanasta')->name('comisiones.canasta');
|
Route::post('/comisiones/canasta', 'ComisionesController@cargarCanasta')->name('comisiones.canasta');
|
||||||
Route::post('/comisiones/saldos', 'ComisionesController@cargarSaldos')->name('comisiones.saldos');
|
Route::post('/comisiones/saldos', 'ComisionesController@cargarSaldos')->name('comisiones.saldos');
|
||||||
|
Route::put('/comisiones/parametros/{parametro_id}', 'ComisionesController@modificarParametros');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/ollas/login', 'OllasController@show')->name('ollas.login');
|
Route::get('/ollas/login', 'OllasController@show')->name('ollas.login');
|
||||||
|
|
||||||
Route::middleware(['auth', 'role:ollas'])->group( function() {
|
Route::middleware(['auth', 'role:ollas'])->prefix('ollas')->group( function() {
|
||||||
Route::get('/ollas', 'RouteController@main')->name('ollas');
|
Route::get('/', 'RouteController@main')->name('ollas');
|
||||||
|
Route::get('/{gdc}','OllasController@pedido');
|
||||||
|
Route::put('/{gdc}/cantidad','OllasController@actualizarCantidadOllas');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue