Compare commits
	
		
			No commits in common. "e508e71b81407c0eb6cc807a4073c240f5339e82" and "0c322400c2957dbdf4c11d092ae1a6f473bb84f7" have entirely different histories.
		
	
	
		
			e508e71b81
			...
			0c322400c2
		
	
		
					 2 changed files with 17 additions and 13 deletions
				
			
		|  | @ -110,7 +110,7 @@ class GrupoDeCompra extends Model | |||
| 
 | ||||
|     function pedidoParaPdf(): array | ||||
|     { | ||||
|         $productos = $this->productosPedidos(true, true, 'producto_id'); | ||||
|         $productos = $this->productosPedidos(true, true); | ||||
|         $pedido = []; | ||||
|         $pedido['productos'] = []; | ||||
| 
 | ||||
|  | @ -260,7 +260,10 @@ class GrupoDeCompra extends Model | |||
|         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') | ||||
|             ->where('grupo_de_compra_id', $this->id); | ||||
|  | @ -271,7 +274,6 @@ class GrupoDeCompra extends Model | |||
|             $query = $query->where('producto_es_bono',false); | ||||
| 
 | ||||
|         return $query | ||||
|             ->orderBy($orderBy) | ||||
|             ->get() | ||||
|             ->keyBy('producto_id'); | ||||
|     } | ||||
|  |  | |||
|  | @ -14,12 +14,10 @@ use Illuminate\Support\Str; | |||
| class CanastaHelper | ||||
| { | ||||
|     const TIPO = "Tipo"; | ||||
|     const PRODUCTO = 'Producto'; | ||||
|     const PRECIO = 'Precio'; | ||||
|     const REGEX_BONO = "/^[BF]/i"; | ||||
|     const TOTAL = "TOTAL"; | ||||
|     const ARCHIVO_SUBIDO = 'Archivo subido'; | ||||
|     const CANASTA_CARGADA = 'Canasta cargada'; | ||||
|     const PRODUCTO_TALLE_COLOR = "PTC"; | ||||
|     const TIPOS_BONO = ["B", "F", "BE"]; | ||||
| 
 | ||||
|     public static function guardarCanasta($data, $path): string { | ||||
|         $nombre = $data->getClientOriginalName(); | ||||
|  | @ -39,6 +37,10 @@ class CanastaHelper | |||
|         $categoria = ''; | ||||
| 
 | ||||
|         foreach($registros as $i => $registro) { | ||||
|             // finalizar
 | ||||
|             if ($registro[self::TIPO] == self::TOTAL) | ||||
|                 break; | ||||
| 
 | ||||
|             // saltear filas que no tienen tipo
 | ||||
|             if (self::noTieneTipo($registro)) { | ||||
|                 var_dump("no hay tipo en la fila " . $i); | ||||
|  | @ -51,7 +53,7 @@ class CanastaHelper | |||
|             } | ||||
| 
 | ||||
|             // obtener categoria si no hay producto
 | ||||
|             if ($registro[self::PRODUCTO] == '') { | ||||
|             if ($registro['Producto'] == '') { | ||||
|                 // no es la pregunta de la copa?
 | ||||
|                 if (!Str::contains($registro[self::TIPO],"¿")) | ||||
|                     $categoria = $registro[self::TIPO]; | ||||
|  | @ -62,11 +64,11 @@ class CanastaHelper | |||
|             $toInsert[] = [ | ||||
|                 'fila'          => $i, | ||||
|                 'categoria'     => $categoria, | ||||
|                 'nombre'        => trim(str_replace('*', '',$registro[self::PRODUCTO])), | ||||
|                 'precio'        => $registro[self::PRECIO], | ||||
|                 'proveedor_id'  => self::obtenerProveedor($registro[self::PRODUCTO]), | ||||
|                 'bono'          => preg_match(self::REGEX_BONO, $registro[self::TIPO]), | ||||
|                 'requiere_notas'=> $registro[self::TIPO] == self::PRODUCTO_TALLE_COLOR, | ||||
|                 'nombre'        => trim(str_replace('*', '',$registro['Producto'])), | ||||
|                 'precio'        => $registro['Precio'], | ||||
|                 'proveedor_id'  => self::obtenerProveedor($registro['Producto']), | ||||
|                 'bono'          => in_array($registro[self::TIPO], self::TIPOS_BONO), | ||||
|                 'requiere_notas'=> $registro[self::TIPO] =="PTC", | ||||
|             ]; | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue