WIP: funcion/faltantes-y-sobrantes #52
1 changed files with 32 additions and 5 deletions
|
|
@ -35,6 +35,7 @@ class PedidosExportHelper
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidArgument
|
||||
* @throws CannotInsertRecord
|
||||
|
|
@ -43,16 +44,16 @@ class PedidosExportHelper
|
|||
static public function pedidosDeOllas()
|
||||
{
|
||||
$filePath = "csv/exports/pedidos-de-ollas-" . now()->format('Y-m-d') . ".csv";
|
||||
$tipo_olla = self::getTipoId('olla');
|
||||
$barrios = GrupoDeCompra::barriosMenosPrueba()
|
||||
->whereHas('subpedidos', function ($query) {
|
||||
$tipo_olla = self::getTipoId('olla');
|
||||
->whereHas('subpedidos', function ($query) use ($tipo_olla) {
|
||||
$query->where('tipo_pedido_id', $tipo_olla);
|
||||
})
|
||||
->get();
|
||||
|
||||
$contenido = self::generarContenidoCSV($barrios,
|
||||
fn($grupoId) => "subpedidos.grupo_de_compra_id = $grupoId
|
||||
AND subpedidos.tipo_pedido_id = 2");
|
||||
AND subpedidos.tipo_pedido_id = $tipo_olla");
|
||||
$ollas = self::cantidadDeOllasParaCSV($barrios, $contenido);
|
||||
|
||||
self::exportarCSV(
|
||||
|
|
@ -128,6 +129,32 @@ 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 CannotInsertRecord
|
||||
|
|
@ -252,7 +279,7 @@ class PedidosExportHelper
|
|||
*/
|
||||
public static function getTipoId(string $tipo)
|
||||
{
|
||||
$tipo_olla = TipoPedido::where('nombre', $tipo)->first()->id;
|
||||
return $tipo_olla;
|
||||
$tipoPedido = TipoPedido::where('nombre', $tipo)->first()->id;
|
||||
return $tipoPedido;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue