Merge pull request 'funcion/arreglar-planillas' (#44) from funcion/arreglar-planillas into master
Reviewed-on: #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
|
||||
{
|
||||
$productos = $this->productosPedidos(true, true);
|
||||
$productos = $this->productosPedidos(true, true, 'producto_id');
|
||||
$pedido = [];
|
||||
$pedido['productos'] = [];
|
||||
|
||||
|
@ -260,10 +260,7 @@ class GrupoDeCompra extends Model
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function productosPedidos($excluirBarriales = false, $excluirBonos = false): Collection
|
||||
public function productosPedidos($excluirBarriales = false, $excluirBonos = false, $orderBy = 'producto_nombre'): Collection
|
||||
{
|
||||
$query = DB::table('pedidos_aprobados')
|
||||
->where('grupo_de_compra_id', $this->id);
|
||||
|
@ -274,6 +271,7 @@ class GrupoDeCompra extends Model
|
|||
$query = $query->where('producto_es_bono',false);
|
||||
|
||||
return $query
|
||||
->orderBy($orderBy)
|
||||
->get()
|
||||
->keyBy('producto_id');
|
||||
}
|
||||
|
|
|
@ -14,10 +14,12 @@ use Illuminate\Support\Str;
|
|||
class CanastaHelper
|
||||
{
|
||||
const TIPO = "Tipo";
|
||||
const TOTAL = "TOTAL";
|
||||
const PRODUCTO = 'Producto';
|
||||
const PRECIO = 'Precio';
|
||||
const REGEX_BONO = "/^[BF]/i";
|
||||
const ARCHIVO_SUBIDO = 'Archivo subido';
|
||||
const CANASTA_CARGADA = 'Canasta cargada';
|
||||
const TIPOS_BONO = ["B", "F", "BE"];
|
||||
const PRODUCTO_TALLE_COLOR = "PTC";
|
||||
|
||||
public static function guardarCanasta($data, $path): string {
|
||||
$nombre = $data->getClientOriginalName();
|
||||
|
@ -37,10 +39,6 @@ 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);
|
||||
|
@ -53,7 +51,7 @@ class CanastaHelper
|
|||
}
|
||||
|
||||
// obtener categoria si no hay producto
|
||||
if ($registro['Producto'] == '') {
|
||||
if ($registro[self::PRODUCTO] == '') {
|
||||
// no es la pregunta de la copa?
|
||||
if (!Str::contains($registro[self::TIPO],"¿"))
|
||||
$categoria = $registro[self::TIPO];
|
||||
|
@ -64,11 +62,11 @@ class CanastaHelper
|
|||
$toInsert[] = [
|
||||
'fila' => $i,
|
||||
'categoria' => $categoria,
|
||||
'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",
|
||||
'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,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue