Compare commits
3 commits
45a7688fbd
...
53e75ae357
Author | SHA1 | Date | |
---|---|---|---|
53e75ae357 | |||
bcc4f4a28a | |||
66298228e3 |
3 changed files with 21 additions and 4 deletions
|
@ -43,7 +43,12 @@ class PedidosExportHelper
|
|||
static public function pedidosDeOllas()
|
||||
{
|
||||
$filePath = "csv/exports/pedidos-de-ollas-" . now()->format('Y-m-d') . ".csv";
|
||||
$barrios = GrupoDeCompra::barriosMenosPrueba()->get();
|
||||
$barrios = GrupoDeCompra::barriosMenosPrueba()
|
||||
->whereHas('subpedidos', function ($query) {
|
||||
$tipo_olla = self::getTipoId('olla');
|
||||
$query->where('tipo_pedido_id', $tipo_olla);
|
||||
})
|
||||
->get();
|
||||
|
||||
$contenido = self::generarContenidoCSV($barrios,
|
||||
fn($grupoId) => "subpedidos.grupo_de_compra_id = $grupoId
|
||||
|
@ -62,7 +67,7 @@ class PedidosExportHelper
|
|||
*/
|
||||
public static function cantidadDeOllasParaCSV(Collection $barrios, Collection $contenido)
|
||||
{
|
||||
$tipo_olla = TipoPedido::where('nombre', 'olla')->first()->id;
|
||||
$tipo_olla = self::getTipoId('olla');
|
||||
|
||||
$parametros = collect(CsvHelper::getRecords(resource_path("csv/parametros.csv"), "No se pudo leer el archivo."));
|
||||
$fila = [
|
||||
|
@ -241,4 +246,13 @@ class PedidosExportHelper
|
|||
}
|
||||
return $transporte;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getTipoId(string $tipo)
|
||||
{
|
||||
$tipo_olla = TipoPedido::where('nombre', $tipo)->first()->id;
|
||||
return $tipo_olla;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,11 @@ class OllasController extends Controller
|
|||
$pedido = $gdc->subpedidos()->firstOrCreate([
|
||||
'nombre' => 'Pedido de Ollas de ' . $gdc->nombre,
|
||||
'tipo_pedido_id' => $tipoOlla->id,
|
||||
'cantidad_ollas' => 0,
|
||||
]);
|
||||
if (!$pedido->cantidad_ollas) {
|
||||
$pedido->cantidad_ollas = 0;
|
||||
$pedido->save();
|
||||
}
|
||||
return response()->json(new PedidoOllasResource($pedido));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
id|nombre|valor
|
||||
bono-transporte|'Bono de transporte'|15
|
||||
monto-transporte|'Monto para bono de transporte'|500
|
||||
monto-olla|'Monto por olla'|1200
|
||||
monto-olla|'Monto por olla'|800
|
||||
|
|
|
Loading…
Add table
Reference in a new issue