FIX: Fetch terreno
This commit is contained in:
@ -175,7 +175,7 @@
|
||||
totales: {},
|
||||
proporcion: 1,
|
||||
precio: {{$UF->transform($venta->currentEstado()->fecha, $venta->valor)}},
|
||||
terreno: {{(isset($venta->proyecto()->terreno->fecha) and $venta->proyecto()->terreno->fecha > $lastDic) ?
|
||||
terreno: {{(isset($venta->proyecto()->terreno->fecha) and $venta->proyecto()->terreno->fecha >= $lastDic) ?
|
||||
$IPC->readjust($venta->proyecto()->terreno->valor, $venta->proyecto()->terreno->fecha, $venta->currentEstado()->fecha) : 0}},
|
||||
uf: {{$UF->get($venta->currentEstado()->fecha)}},
|
||||
unidades: JSON.parse('{!! json_encode(array_map(function(Incoviba\Model\Venta\PropiedadUnidad $unidad) use ($venta, $UF, $format) {
|
||||
|
@ -8,6 +8,7 @@ class Terreno implements JsonSerializable
|
||||
{
|
||||
public float $superficie;
|
||||
public float $valor;
|
||||
public float $valorUnitario;
|
||||
public ?DateTimeInterface $fecha;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
|
@ -38,9 +38,11 @@ class Proyecto extends Ideal\Repository
|
||||
->setFunction(function($data) {
|
||||
$terreno = new Model\Proyecto\Terreno();
|
||||
$terreno->superficie = $data['superficie_terreno'];
|
||||
$terreno->valor = $data['valor_terreno'];
|
||||
$terreno->valorUnitario = $data['valor_unitario_terreno'];
|
||||
$terreno->valor = 0;
|
||||
$terreno->fecha = null;
|
||||
if (isset($data['fecha_terreno']) and $data['fecha_terreno'] !== '') {
|
||||
$terreno->valor = $data['valor_terreno'];
|
||||
$terreno->fecha = new DateTimeImmutable($data['fecha_terreno']);
|
||||
}
|
||||
return $terreno;
|
||||
@ -61,7 +63,7 @@ class Proyecto extends Ideal\Repository
|
||||
['inmobiliaria', 'descripcion', 'direccion', 'superficie_terreno', 'valor_terreno', 'corredor',
|
||||
'superficie_sobre_nivel', 'superficie_bajo_nivel', 'pisos', 'subterraneos'],
|
||||
[$model->inmobiliaria()->rut, $model->descripcion, $model->direccion()->id, $model->terreno->superficie,
|
||||
$model->terreno->valor, $model->corredor, $model->superficie->sobre_nivel,
|
||||
$model->terreno->valorUnitario, $model->corredor, $model->superficie->sobre_nivel,
|
||||
$model->superficie->bajo_nivel, $model->pisos, $model->subterraneos]
|
||||
);
|
||||
return $model;
|
||||
@ -149,7 +151,6 @@ class Proyecto extends Ideal\Repository
|
||||
$proyecto->terreno->fecha = $fecha;
|
||||
$proyecto->terreno->valor = $data['valor'];
|
||||
} catch (PDOException $exception) {
|
||||
error_log($exception);
|
||||
throw new Implement\Exception\EmptyResult($query);
|
||||
}
|
||||
}
|
||||
@ -162,14 +163,13 @@ class Proyecto extends Ideal\Repository
|
||||
|
||||
protected function columns(): string
|
||||
{
|
||||
return "a.id, a.inmobiliaria, a.descripcion, a.direccion, a.superficie_terreno,
|
||||
COALESCE(pt.valor, a.valor_terreno) AS valor_terreno, COALESCE(pt.fecha, '') AS fecha_terreno, a.corredor,
|
||||
return "a.id, a.inmobiliaria, a.descripcion, a.direccion, a.superficie_terreno, valor_terreno AS valor_unitario_terreno,
|
||||
COALESCE(pt.valor, '') AS valor_terreno, COALESCE(pt.fecha, '') AS fecha_terreno, a.corredor,
|
||||
a.superficie_sobre_nivel, a.superficie_bajo_nivel, a.pisos, a.subterraneos";
|
||||
}
|
||||
protected function joinTerreno(): string
|
||||
{
|
||||
return "LEFT OUTER JOIN (SELECT pt1.* FROM proyecto_terreno pt1 JOIN (
|
||||
SELECT MAX(id) AS id, proyecto_id FROM proyecto_terreno) pt0 ON pt0.id = pt1.id) pt ON pt.proyecto_id = a.id";
|
||||
return "LEFT OUTER JOIN (SELECT pt1.* FROM proyecto_terreno pt1 JOIN (SELECT MAX(id) AS id, proyecto_id FROM proyecto_terreno GROUP BY proyecto_id) pt0 ON pt0.id = pt1.id) pt ON pt.proyecto_id = a.id";
|
||||
}
|
||||
protected function joinEstado(): string
|
||||
{
|
||||
|
Reference in New Issue
Block a user