@@ -409,8 +409,7 @@
},
proyecto: {
direccion: '{{$venta->proyecto()->direccion()->simple()}}',
- terreno: {{(isset($terreno->fecha) and $terreno->fecha >= $lastDic) ?
- $IPC->readjust($terreno->valor, $terreno->fecha, $venta->currentEstado()->fecha) : 0}},
+ terreno: {{$terreno?->valor ?? 0}}
},
estadoVenta: {
fecha: new Date('{{$venta->currentEstado()->fecha->format('Y-m-d')}}')
@@ -758,7 +757,7 @@
this.update().unidades()
this.update().propietarios($(count_propietarios_id).val())
this.draw().propietarios()
- this.unidades.forEach((unidad, idx) => {
+ this.propietarios.forEach((unidad, idx) => {
this.update().proporciones(idx)
})
this.update().facturas()
diff --git a/app/src/Controller/Ventas/Facturacion.php b/app/src/Controller/Ventas/Facturacion.php
index 74ea55e..b73ddd7 100644
--- a/app/src/Controller/Ventas/Facturacion.php
+++ b/app/src/Controller/Ventas/Facturacion.php
@@ -9,9 +9,12 @@ use Incoviba\Service;
class Facturacion
{
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
- Service\Proyecto $proyectoService): ResponseInterface
+ Service\Proyecto $proyectoService, Service\Proyecto\Terreno $terrenoService): ResponseInterface
{
$proyectos = $proyectoService->getEscriturando();
+ foreach ($proyectos as &$proyecto) {
+ $proyecto->terreno = $terrenoService->valor($proyecto->id) ?? $proyecto->terreno;
+ }
return $view->render($response, 'ventas.facturacion', compact('proyectos'));
}
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
diff --git a/app/src/Repository/Venta.php b/app/src/Repository/Venta.php
index ef392f1..9eac6b2 100644
--- a/app/src/Repository/Venta.php
+++ b/app/src/Repository/Venta.php
@@ -171,7 +171,7 @@ class Venta extends Ideal\Repository
->joined('JOIN proyecto_tipo_unidad ptu ON ptu.id = unidad.pt')
->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 = a.id')
->joined('JOIN tipo_estado_venta tev ON tev.id = ev.estado')
- ->where('ptu.proyecto = ? AND tev.activa')
+ ->where('ptu.proyecto = ? AND tev.activa = 1')
->group('a.id');
return $this->fetchIds($query, [$proyecto_id]);
}
@@ -185,7 +185,7 @@ class Venta extends Ideal\Repository
->joined('JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt`')
->joined("JOIN (SELECT e1.* FROM `estado_venta` e1 JOIN (SELECT MAX(`id`) AS 'id', `venta` FROM `estado_venta` GROUP BY `venta`) e0 ON e0.`id` = e1.`id`) ev ON ev.`venta` = a.`id`")
->joined('JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`')
- ->where('ptu.`proyecto` = ? AND tev.`activa`')
+ ->where('ptu.`proyecto` = ? AND tev.`activa` = 1')
->group('a.id');
return $this->fetchMany($query, [$proyecto_id]);
}
diff --git a/app/src/Service/Proyecto/Terreno.php b/app/src/Service/Proyecto/Terreno.php
index 637fc7d..6afa8c5 100644
--- a/app/src/Service/Proyecto/Terreno.php
+++ b/app/src/Service/Proyecto/Terreno.php
@@ -31,8 +31,11 @@ class Terreno extends Ideal\Service
try {
return $this->getValorContable($proyecto, $lastDecember);
} catch (Implement\Exception\EmptyResponse) {}
+ if ($proyecto->terreno->fecha === null) {
+ return null;
+ }
if ($proyecto->terreno->fecha->getTimestamp() > 0) {
- return $this->getValorReajustado($proyecto, $lastDecember);
+ return $this->getValorReajustado($proyecto);
}
$terreno = $proyecto->terreno;
} catch (Implement\Exception\EmptyResult) {}
diff --git a/app/src/Service/Venta.php b/app/src/Service/Venta.php
index f9ebf44..36d9642 100644
--- a/app/src/Service/Venta.php
+++ b/app/src/Service/Venta.php
@@ -46,6 +46,10 @@ class Venta extends Service
$ventas = $this->ventaRepository->fetchActivaByProyecto($proyecto_id);
return array_map([$this, 'process'], $ventas);
}
+ public function getIdsByProyecto(int $proyecto_id): array
+ {
+ return $this->ventaRepository->fetchIdsByProyecto($proyecto_id);
+ }
public function getByProyectoAndUnidad(string $proyecto_nombre, int $unidad_descripcion): Model\Venta
{
$venta = $this->ventaRepository->fetchByProyectoAndUnidad($proyecto_nombre, $unidad_descripcion);