FIX: venta sin departamentos
This commit is contained in:
@ -48,6 +48,9 @@ class Propiedad extends Ideal\Model
|
||||
protected float $vendible;
|
||||
public function vendible(): float
|
||||
{
|
||||
if (count($this->departamentos()) === 0) {
|
||||
return $this->principal()->proyectoTipoUnidad->vendible();
|
||||
}
|
||||
return array_reduce($this->departamentos(), function(float $sum, Unidad $unidad) {
|
||||
return $sum + $unidad->proyectoTipoUnidad->vendible();
|
||||
}, 0);
|
||||
|
@ -372,7 +372,7 @@ class Venta extends Ideal\Repository
|
||||
->joined('JOIN tipo_unidad tu ON tu.id = ptu.tipo')
|
||||
->joined('JOIN (SELECT ev1.* FROM estado_venta ev1 JOIN (SELECT MAX(id) AS id, venta FROM estado_venta GROUP BY venta) ev0 ON ev0.id = ev1.id) ev ON ev.venta = venta.id')
|
||||
->joined('JOIN tipo_estado_venta tev ON ev.estado = tev.id')
|
||||
->where('venta.id = ? AND tu.descripcion = "departamento"')
|
||||
->where('venta.id = ?')
|
||||
->group('venta.id');
|
||||
return $this->connection->execute($query, [$venta_id])->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
Reference in New Issue
Block a user