4 Commits

4 changed files with 16 additions and 7 deletions

View File

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

View File

@ -6,10 +6,15 @@ use Throwable;
class EmptyResult extends Exception 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}"; $message = "Empty results for {$query}";
$code = 700; $code = 700;
parent::__construct($message, $code, $previous); 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/precios/importar">Importar Precios</a>--}}
{{--<a class="item" href="{{$urls->base}}/ventas/cierres/evaluar">Evaluar Cierre</a>--}} {{--<a class="item" href="{{$urls->base}}/ventas/cierres/evaluar">Evaluar Cierre</a>--}}
<a class="item" href="{{$urls->base}}/ventas/facturacion">Facturación</a> <a class="item" href="{{$urls->base}}/ventas/facturacion">Facturación</a>
<div class="divider"></div>
<a class="item" href="{{$urls->base}}/ventas/add"> <a class="item" href="{{$urls->base}}/ventas/add">
Nueva Venta Nueva Venta
<i class="plus icon"></i> <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'] const exportColumns = ['tipo', 'unidad', 'tipologia', 'piso', 'orientacion', 'metros_interior', 'metros_terraza', 'metros', 'metros_total', 'precio_operador', 'promociones']
if (typeof this.columns['promotions'] === 'undefined') { if (typeof this.columns['promotions'] === 'undefined') {
exportColumns.pop() 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) exportColumns.push(name)
}) })
} }
@ -148,6 +148,9 @@
if (typeof data === 'string' && data.includes('<span')) { if (typeof data === 'string' && data.includes('<span')) {
return data.replace(/<span.*>(.*)<\/span>/, '$1') 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'] const formatColumns = ['metros', 'metros_interior', 'metros_terraza', 'metros_total']
if (this.set.titles) { if (this.set.titles) {
this.columns.filter(column => column.includes('.amount') || column.includes('.final')).forEach(name => { this.columns.filter(column => column.includes('.amount') || column.includes('.final')).forEach(name => {