From ca83472012ebf8e826f68e162015f4b1f2dbbae7 Mon Sep 17 00:00:00 2001 From: Aldarien Date: Thu, 18 Jan 2024 16:41:16 -0300 Subject: [PATCH] Informe escritura --- app/resources/routes/ventas/escrituras.php | 1 + .../views/ventas/escrituras/informe.blade.php | 91 +++++++++++++++++++ .../views/ventas/show/escritura.blade.php | 2 +- app/src/Controller/Ventas/Escrituras.php | 9 +- app/src/Service/Format.php | 8 +- 5 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 app/resources/views/ventas/escrituras/informe.blade.php diff --git a/app/resources/routes/ventas/escrituras.php b/app/resources/routes/ventas/escrituras.php index 7a310a9..a9ecd40 100644 --- a/app/resources/routes/ventas/escrituras.php +++ b/app/resources/routes/ventas/escrituras.php @@ -2,5 +2,6 @@ use Incoviba\Controller\Ventas\Escrituras; $app->group('/escritura/{venta_id}', function($app) { + $app->get('/informe[/]', [Escrituras::class, 'informe']); $app->get('[/]', [Escrituras::class, 'show']); }); diff --git a/app/resources/views/ventas/escrituras/informe.blade.php b/app/resources/views/ventas/escrituras/informe.blade.php new file mode 100644 index 0000000..3c530fb --- /dev/null +++ b/app/resources/views/ventas/escrituras/informe.blade.php @@ -0,0 +1,91 @@ +@extends('layout.base') + +@section('page_content') +
+

+ Escritura - + {{$venta->proyecto()->descripcion}} - + {{$venta->propiedad()->summary()}} +

+
+ El departamento {{$venta->propiedad()->departamentos()[0]->descripcion}}:
+ @php + $estacionamientos = $venta->propiedad()->estacionamientos(); + @endphp + @if (count($estacionamientos) === 0) + no tiene estacionamientos + @else + tiene + {{count($estacionamientos) === 1 ? 'el' : 'los'}} + estacionamiento{{count($estacionamientos) === 1 ? '': 's'}} + {{implode(', ', array_map(function(Incoviba\Model\Venta\Unidad $unidad) { + return $unidad->descripcion; + }, $estacionamientos))}} + @endif + y + @php + $bodegas = $venta->propiedad()->bodegas(); + @endphp + @if (count($bodegas) === 0) + no tiene bodegas + @else + tiene + {{count($bodegas) === 1 ? 'la' : 'las'}} + bodega{{count($bodegas) === 1 ? '' : 's'}} + {{implode(', ', array_map(function(Incoviba\Model\Venta\Unidad $unidad) { + return $unidad->descripcion; + }, $bodegas))}} + @endif +
+
+ PRECIO + {{$format->ufs($venta->valor)}} +
+
+ @if (isset($venta->formaPago()->pie)) + @php($pie = $venta->formaPago()->pie) + PIE + {{$pie->cuotas}} cuotas que suman + {{$format->pesos($pie->pagado('pesos'))}} + equivalente a + {{$format->ufs($pie->pagado())}}. +
+ @endif + @if (isset($venta->formaPago()->escritura)) + @php($escritura = $venta->formaPago()->escritura) + ESCRITURA + {{$format->pesos($escritura->pago->valor)}} + el + {{$escritura->fecha->format('d-m-Y')}} + equivalente a + {{$format->ufs($escritura->pago->valor())}} +
+ @endif +
+ TOTAL ANTICIPO + {{$format->ufs($venta->formaPago()->anticipo())}} +
+ @if (isset($venta->formaPago()->bonoPie)) + @php($bono = $venta->formaPago()->bonoPie) + BONO PIE + {{$format->ufs($bono->pago->valor())}} +
+ @endif + @if (isset($venta->formaPago()->credito)) + @php($credito = $venta->formaPago()->credito) + CRÉDITO + {{$format->ufs($credito->pago->valor())}} + en Banco {{$credito->pago->banco->nombre}} +
+ @endif +
+ TOTAL + {{$format->ufs($venta->formaPago()->total())}} + @if (($venta->formaPago()->total() - $venta->valor) !== 0) +
+
+ Diferencia {{$format->ufs($venta->formaPago()->total() - $venta->valor)}}. ({{$format->percent(($venta->formaPago()->total() - $venta->valor) / $venta->valor * 100)}}) + @endif +
+
+@endsection diff --git a/app/resources/views/ventas/show/escritura.blade.php b/app/resources/views/ventas/show/escritura.blade.php index ace5790..7e2aade 100644 --- a/app/resources/views/ventas/show/escritura.blade.php +++ b/app/resources/views/ventas/show/escritura.blade.php @@ -9,7 +9,7 @@ - + Informe diff --git a/app/src/Controller/Ventas/Escrituras.php b/app/src/Controller/Ventas/Escrituras.php index 9437d9a..feb9f89 100644 --- a/app/src/Controller/Ventas/Escrituras.php +++ b/app/src/Controller/Ventas/Escrituras.php @@ -8,9 +8,16 @@ use Incoviba\Service; class Escrituras { - public function show(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Venta $ventaService, int $venta_id): ResponseInterface + public function show(ServerRequestInterface $request, ResponseInterface $response, View $view, + Service\Venta $ventaService, int $venta_id): ResponseInterface { $venta = $ventaService->getById($venta_id); return $view->render($response, 'ventas.escrituras.show', compact('venta')); } + public function informe(ServerRequestInterface $request, ResponseInterface $response, View $view, + Service\Venta $ventaService, int $venta_id): ResponseInterface + { + $venta = $ventaService->getById($venta_id); + return $view->render($response, 'ventas.escrituras.informe', compact('venta')); + } } diff --git a/app/src/Service/Format.php b/app/src/Service/Format.php index 2af1a3b..21546e0 100644 --- a/app/src/Service/Format.php +++ b/app/src/Service/Format.php @@ -21,12 +21,16 @@ class Format { return number_format($number, $decimal_places, ',', '.'); } + public function percent(float|string $number, int $decimal_places = 2): string + { + return "{$this->number($number, $decimal_places)}%"; + } public function pesos(string $valor): string { - return '$ ' . $this->number($valor); + return "$ {$this->number($valor)}"; } public function ufs(string $valor): string { - return $this->number($valor, 2) . ' UF'; + return "{$this->number($valor, 2)} UF"; } }