forked from nathalie/pedi2
Merge pull request 'funcion/arreglar-planillas' (#44) from funcion/arreglar-planillas into master
Reviewed-on: nathalie/pedi2#44
This commit is contained in:
commit
e508e71b81
2 changed files with 13 additions and 17 deletions
|
@ -110,7 +110,7 @@ class GrupoDeCompra extends Model
|
||||||
|
|
||||||
function pedidoParaPdf(): array
|
function pedidoParaPdf(): array
|
||||||
{
|
{
|
||||||
$productos = $this->productosPedidos(true, true);
|
$productos = $this->productosPedidos(true, true, 'producto_id');
|
||||||
$pedido = [];
|
$pedido = [];
|
||||||
$pedido['productos'] = [];
|
$pedido['productos'] = [];
|
||||||
|
|
||||||
|
@ -260,10 +260,7 @@ class GrupoDeCompra extends Model
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function productosPedidos($excluirBarriales = false, $excluirBonos = false, $orderBy = 'producto_nombre'): Collection
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
public function productosPedidos($excluirBarriales = false, $excluirBonos = false): Collection
|
|
||||||
{
|
{
|
||||||
$query = DB::table('pedidos_aprobados')
|
$query = DB::table('pedidos_aprobados')
|
||||||
->where('grupo_de_compra_id', $this->id);
|
->where('grupo_de_compra_id', $this->id);
|
||||||
|
@ -274,6 +271,7 @@ class GrupoDeCompra extends Model
|
||||||
$query = $query->where('producto_es_bono',false);
|
$query = $query->where('producto_es_bono',false);
|
||||||
|
|
||||||
return $query
|
return $query
|
||||||
|
->orderBy($orderBy)
|
||||||
->get()
|
->get()
|
||||||
->keyBy('producto_id');
|
->keyBy('producto_id');
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,12 @@ use Illuminate\Support\Str;
|
||||||
class CanastaHelper
|
class CanastaHelper
|
||||||
{
|
{
|
||||||
const TIPO = "Tipo";
|
const TIPO = "Tipo";
|
||||||
const TOTAL = "TOTAL";
|
const PRODUCTO = 'Producto';
|
||||||
|
const PRECIO = 'Precio';
|
||||||
|
const REGEX_BONO = "/^[BF]/i";
|
||||||
const ARCHIVO_SUBIDO = 'Archivo subido';
|
const ARCHIVO_SUBIDO = 'Archivo subido';
|
||||||
const CANASTA_CARGADA = 'Canasta cargada';
|
const CANASTA_CARGADA = 'Canasta cargada';
|
||||||
const TIPOS_BONO = ["B", "F", "BE"];
|
const PRODUCTO_TALLE_COLOR = "PTC";
|
||||||
|
|
||||||
public static function guardarCanasta($data, $path): string {
|
public static function guardarCanasta($data, $path): string {
|
||||||
$nombre = $data->getClientOriginalName();
|
$nombre = $data->getClientOriginalName();
|
||||||
|
@ -37,10 +39,6 @@ class CanastaHelper
|
||||||
$categoria = '';
|
$categoria = '';
|
||||||
|
|
||||||
foreach($registros as $i => $registro) {
|
foreach($registros as $i => $registro) {
|
||||||
// finalizar
|
|
||||||
if ($registro[self::TIPO] == self::TOTAL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// saltear filas que no tienen tipo
|
// saltear filas que no tienen tipo
|
||||||
if (self::noTieneTipo($registro)) {
|
if (self::noTieneTipo($registro)) {
|
||||||
var_dump("no hay tipo en la fila " . $i);
|
var_dump("no hay tipo en la fila " . $i);
|
||||||
|
@ -53,7 +51,7 @@ class CanastaHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
// obtener categoria si no hay producto
|
// obtener categoria si no hay producto
|
||||||
if ($registro['Producto'] == '') {
|
if ($registro[self::PRODUCTO] == '') {
|
||||||
// no es la pregunta de la copa?
|
// no es la pregunta de la copa?
|
||||||
if (!Str::contains($registro[self::TIPO],"¿"))
|
if (!Str::contains($registro[self::TIPO],"¿"))
|
||||||
$categoria = $registro[self::TIPO];
|
$categoria = $registro[self::TIPO];
|
||||||
|
@ -64,11 +62,11 @@ class CanastaHelper
|
||||||
$toInsert[] = [
|
$toInsert[] = [
|
||||||
'fila' => $i,
|
'fila' => $i,
|
||||||
'categoria' => $categoria,
|
'categoria' => $categoria,
|
||||||
'nombre' => trim(str_replace('*', '',$registro['Producto'])),
|
'nombre' => trim(str_replace('*', '',$registro[self::PRODUCTO])),
|
||||||
'precio' => $registro['Precio'],
|
'precio' => $registro[self::PRECIO],
|
||||||
'proveedor_id' => self::obtenerProveedor($registro['Producto']),
|
'proveedor_id' => self::obtenerProveedor($registro[self::PRODUCTO]),
|
||||||
'bono' => in_array($registro[self::TIPO], self::TIPOS_BONO),
|
'bono' => preg_match(self::REGEX_BONO, $registro[self::TIPO]),
|
||||||
'requiere_notas'=> $registro[self::TIPO] =="PTC",
|
'requiere_notas'=> $registro[self::TIPO] == self::PRODUCTO_TALLE_COLOR,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue