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 |     function pedidoParaPdf(): array | ||||||
|     { |     { | ||||||
|         $productos = $this->productosPedidos(true, true, 'producto_id'); |         $productos = $this->productosPedidos(true, true); | ||||||
|         $pedido = []; |         $pedido = []; | ||||||
|         $pedido['productos'] = []; |         $pedido['productos'] = []; | ||||||
| 
 | 
 | ||||||
|  | @ -260,7 +260,10 @@ 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); | ||||||
|  | @ -271,7 +274,6 @@ 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,12 +14,10 @@ use Illuminate\Support\Str; | ||||||
| class CanastaHelper | class CanastaHelper | ||||||
| { | { | ||||||
|     const TIPO = "Tipo"; |     const TIPO = "Tipo"; | ||||||
|     const PRODUCTO = 'Producto'; |     const TOTAL = "TOTAL"; | ||||||
|     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 PRODUCTO_TALLE_COLOR = "PTC"; |     const TIPOS_BONO = ["B", "F", "BE"]; | ||||||
| 
 | 
 | ||||||
|     public static function guardarCanasta($data, $path): string { |     public static function guardarCanasta($data, $path): string { | ||||||
|         $nombre = $data->getClientOriginalName(); |         $nombre = $data->getClientOriginalName(); | ||||||
|  | @ -39,6 +37,10 @@ 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); | ||||||
|  | @ -51,7 +53,7 @@ class CanastaHelper | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // obtener categoria si no hay producto
 |             // obtener categoria si no hay producto
 | ||||||
|             if ($registro[self::PRODUCTO] == '') { |             if ($registro['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]; | ||||||
|  | @ -62,11 +64,11 @@ class CanastaHelper | ||||||
|             $toInsert[] = [ |             $toInsert[] = [ | ||||||
|                 'fila'          => $i, |                 'fila'          => $i, | ||||||
|                 'categoria'     => $categoria, |                 'categoria'     => $categoria, | ||||||
|                 'nombre'        => trim(str_replace('*', '',$registro[self::PRODUCTO])), |                 'nombre'        => trim(str_replace('*', '',$registro['Producto'])), | ||||||
|                 'precio'        => $registro[self::PRECIO], |                 'precio'        => $registro['Precio'], | ||||||
|                 'proveedor_id'  => self::obtenerProveedor($registro[self::PRODUCTO]), |                 'proveedor_id'  => self::obtenerProveedor($registro['Producto']), | ||||||
|                 'bono'          => preg_match(self::REGEX_BONO, $registro[self::TIPO]), |                 'bono'          => in_array($registro[self::TIPO], self::TIPOS_BONO), | ||||||
|                 'requiere_notas'=> $registro[self::TIPO] == self::PRODUCTO_TALLE_COLOR, |                 'requiere_notas'=> $registro[self::TIPO] =="PTC", | ||||||
|             ]; |             ]; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue