FIX: Precio Unidad no existe en venta y facturacion
This commit is contained in:
@ -187,7 +187,7 @@
|
|||||||
$IPC->readjust($venta->proyecto()->terreno->valor, $venta->proyecto()->terreno->fecha, $venta->currentEstado()->fecha) : 0}},
|
$IPC->readjust($venta->proyecto()->terreno->valor, $venta->proyecto()->terreno->fecha, $venta->currentEstado()->fecha) : 0}},
|
||||||
uf: {{$UF->get($venta->currentEstado()->fecha)}},
|
uf: {{$UF->get($venta->currentEstado()->fecha)}},
|
||||||
unidades: JSON.parse('{!! json_encode(array_map(function(Incoviba\Model\Venta\PropiedadUnidad $unidad) use ($venta, $UF, $format) {
|
unidades: JSON.parse('{!! json_encode(array_map(function(Incoviba\Model\Venta\PropiedadUnidad $unidad) use ($venta, $UF, $format) {
|
||||||
$precio = ($unidad->valor > 0) ? $unidad->valor : $unidad->precio($venta->currentEstado()->fecha)->valor;
|
$precio = ($unidad->valor > 0) ? $unidad->valor : ($unidad->precio($venta->currentEstado()->fecha) ? $unidad->precio($venta->currentEstado()->fecha)->valor : 0);
|
||||||
return [
|
return [
|
||||||
'id' => $unidad->id,
|
'id' => $unidad->id,
|
||||||
'pid' => $unidad->pu_id,
|
'pid' => $unidad->pu_id,
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach($venta->propiedad()->unidades as $unidad)
|
@foreach($venta->propiedad()->unidades as $unidad)
|
||||||
|
@php
|
||||||
|
$precio = $unidad->precio($venta->fecha) ? $unidad->precio($venta->fecha)->valor : 0;
|
||||||
|
@endphp
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}}
|
{{ucwords($unidad->proyectoTipoUnidad->tipoUnidad->descripcion)}}
|
||||||
@ -40,14 +43,14 @@
|
|||||||
{{$format->number($unidad->proyectoTipoUnidad->vendible(), 2)}} m²
|
{{$format->number($unidad->proyectoTipoUnidad->vendible(), 2)}} m²
|
||||||
</td>
|
</td>
|
||||||
<td class="right aligned">
|
<td class="right aligned">
|
||||||
{{$format->ufs($unidad->precio($venta->fecha)->valor)}}
|
{{$format->ufs($precio)}}
|
||||||
</td>
|
</td>
|
||||||
<td class="right aligned">
|
<td class="right aligned">
|
||||||
{{$format->ufs($unidad->valor)}}
|
{{$format->ufs($unidad->valor)}}
|
||||||
</td>
|
</td>
|
||||||
<td class="right aligned">
|
<td class="right aligned">
|
||||||
@if ($unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento')
|
@if ($unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento')
|
||||||
{{$format->number(($unidad->valor ?? ($unidad->precio($venta->fecha)->valor ?? 0)) / $unidad->proyectoTipoUnidad->vendible(), 2)}} UF/m²
|
{{$format->number(($unidad->valor ?? $precio) / $unidad->proyectoTipoUnidad->vendible(), 2)}} UF/m²
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td class="center aligned">
|
<td class="center aligned">
|
||||||
|
@ -18,7 +18,7 @@ class Unidad extends Ideal\Model
|
|||||||
public array $precios = [];
|
public array $precios = [];
|
||||||
public ?Precio $currentPrecio = null;
|
public ?Precio $currentPrecio = null;
|
||||||
|
|
||||||
public function precio(DateTimeInterface $dateTime): Precio
|
public function precio(DateTimeInterface $dateTime): ?Precio
|
||||||
{
|
{
|
||||||
if ($this->currentPrecio !== null and $dateTime > $this->currentPrecio->current->fecha) {
|
if ($this->currentPrecio !== null and $dateTime > $this->currentPrecio->current->fecha) {
|
||||||
return $this->currentPrecio;
|
return $this->currentPrecio;
|
||||||
@ -41,9 +41,6 @@ class Unidad extends Ideal\Model
|
|||||||
return $min->current->fecha < $precio->current->fecha ? $min : $precio;
|
return $min->current->fecha < $precio->current->fecha ? $min : $precio;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($precio === null) {
|
|
||||||
throw new EmptyResult('SELECT * FROM precio WHERE unidad = ? AND fecha = ?');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $precio;
|
return $precio;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user