4 Commits

4 changed files with 16 additions and 7 deletions

View File

@ -189,7 +189,7 @@ abstract class Repository implements Define\Repository
try {
$this->connection->execute($query, $values);
} catch (PDOException $exception) {
throw new EmptyResult($query, $exception);
throw new EmptyResult($query, $exception, $data);
}
return $this->fetchById($this->getIndex($model));
}
@ -205,10 +205,10 @@ abstract class Repository implements Define\Repository
try {
$result = $this->connection->execute($query, $data)->fetch(PDO::FETCH_ASSOC);
if ($result === false) {
throw new EmptyResult($query);
throw new EmptyResult($query, null, $data);
}
} catch (PDOException $exception) {
throw new EmptyResult($query, $exception);
throw new EmptyResult($query, $exception, $data);
}
return $this->load($result);
}
@ -224,7 +224,7 @@ abstract class Repository implements Define\Repository
try {
$results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $exception) {
throw new EmptyResult($query, $exception);
throw new EmptyResult($query, $exception, $data);
}
return array_map([$this, 'load'], $results);
}
@ -240,7 +240,7 @@ abstract class Repository implements Define\Repository
try {
$results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $exception) {
throw new EmptyResult($query, $exception);
throw new EmptyResult($query, $exception, $data);
}
return $results;
}

View File

@ -6,10 +6,15 @@ use Throwable;
class EmptyResult extends Exception
{
public function __construct(public string $query, ?Throwable $previous = null)
public function __construct(public string $query, ?Throwable $previous = null, protected ?array $data = null)
{
$message = "Empty results for {$query}";
$code = 700;
parent::__construct($message, $code, $previous);
}
public function getData(): ?array
{
return $this->data;
}
}

View File

@ -34,6 +34,7 @@
{{--<a class="item" href="{{$urls->base}}/ventas/precios/importar">Importar Precios</a>--}}
{{--<a class="item" href="{{$urls->base}}/ventas/cierres/evaluar">Evaluar Cierre</a>--}}
<a class="item" href="{{$urls->base}}/ventas/facturacion">Facturación</a>
<div class="divider"></div>
<a class="item" href="{{$urls->base}}/ventas/add">
Nueva Venta
<i class="plus icon"></i>

View File

@ -118,7 +118,7 @@
const exportColumns = ['tipo', 'unidad', 'tipologia', 'piso', 'orientacion', 'metros_interior', 'metros_terraza', 'metros', 'metros_total', 'precio_operador', 'promociones']
if (typeof this.columns['promotions'] === 'undefined') {
exportColumns.pop()
this.columns.slice(this.columns.indexOf('UF/m²')).forEach(name => {
this.columns.slice(this.columns.indexOf('UF/m²')+1).forEach(name => {
exportColumns.push(name)
})
}
@ -148,6 +148,9 @@
if (typeof data === 'string' && data.includes('<span')) {
return data.replace(/<span.*>(.*)<\/span>/, '$1')
}
if (typeof data === 'string' && data.includes('UF ')) {
return data.replace('UF ', '').replaceAll('.', '').replaceAll(',', '.')
}
const formatColumns = ['metros', 'metros_interior', 'metros_terraza', 'metros_total']
if (this.set.titles) {
this.columns.filter(column => column.includes('.amount') || column.includes('.final')).forEach(name => {