From 4d6a1827a3a279675160b3942060e0f271e232de Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 3 Apr 2025 13:37:17 -0300 Subject: [PATCH 1/6] FIX: calculo de UF nula o 0 --- app/src/Model/Venta/Pago.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/Model/Venta/Pago.php b/app/src/Model/Venta/Pago.php index 8474d11..669955d 100644 --- a/app/src/Model/Venta/Pago.php +++ b/app/src/Model/Venta/Pago.php @@ -24,8 +24,15 @@ class Pago extends Model public function valor(string $moneda = Pago::UF): float { - $uf = $this->uf ?? ($this->uf > 0.0 ? $this->uf : 1); - return $this->valor / (($moneda === Pago::UF) ? $uf : 1); + $multiplier = 1; + if ($moneda === Pago::UF) { + if ($this->uf === null or $this->uf === 0.0) { + return 0; + } + $uf = $this->uf; + $multiplier = 1 / $uf; + } + return $this->valor * $multiplier; } public function estado(?string $tipoEstado = null): ?EstadoPago From 74a2cf730361510aef8b657de41622909d29ea7d Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 3 Apr 2025 13:37:41 -0300 Subject: [PATCH 2/6] Actualizaciones en Format --- app/src/Service/Format.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/Service/Format.php b/app/src/Service/Format.php index 69bde98..c2119c5 100644 --- a/app/src/Service/Format.php +++ b/app/src/Service/Format.php @@ -6,12 +6,12 @@ use IntlDateFormatter; class Format { - public function localDate(string $valor, string $format, bool $print = false): string + public function localDate(string $valor, ?string $format = null, bool $print = false): string { $date = new DateTimeImmutable($valor); $formatter = new IntlDateFormatter('es_ES'); if ($format == null) { - $format = 'DD [de] MMMM [de] YYYY'; + $format = "dd 'de' MMMM 'de' YYYY"; } $formatter->setPattern($format); return $formatter->format($date); @@ -21,9 +21,9 @@ class Format { return number_format($number, $decimal_places, ',', '.'); } - public function percent(float|string $number, int $decimal_places = 2): string + public function percent(float|string $number, int $decimal_places = 2, bool $multiply = false): string { - return "{$this->number($number, $decimal_places)}%"; + return "{$this->number(($multiply) ? $number * 100 : $number, $decimal_places)}%"; } public function pesos(string $valor, int $decimal_places = 0): string { From 6d1782cac62307b93d589e80d0cef18e70d771e8 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 3 Apr 2025 13:38:11 -0300 Subject: [PATCH 3/6] mejora en UX de busqueda --- app/resources/views/search.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/resources/views/search.blade.php b/app/resources/views/search.blade.php index 55bdcd6..198fe62 100644 --- a/app/resources/views/search.blade.php +++ b/app/resources/views/search.blade.php @@ -58,6 +58,7 @@ if (!this.venta.current_estado.tipo_estado_venta.activa) { unidad.html(unidad.html() + ' (I)') } + unidad.html(unidad.html() + ' ') propietario = $('') .attr('href','{{$urls->base}}/search/"' + encodeURIComponent(this.venta.propietario.nombre_completo) + '"/propietario') .html(this.venta.propietario.nombre_completo) From 68e436cd67213a136ce4114c32293f470b1a5360 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 3 Apr 2025 13:38:22 -0300 Subject: [PATCH 4/6] Mostrar porcentajes en venta --- app/resources/views/ventas/show/forma_pago/anticipo.blade.php | 2 +- app/resources/views/ventas/show/forma_pago/bono_pie.blade.php | 2 +- app/resources/views/ventas/show/forma_pago/credito.blade.php | 2 +- app/resources/views/ventas/show/forma_pago/pie.blade.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/resources/views/ventas/show/forma_pago/anticipo.blade.php b/app/resources/views/ventas/show/forma_pago/anticipo.blade.php index d9f3095..5bb9fbf 100644 --- a/app/resources/views/ventas/show/forma_pago/anticipo.blade.php +++ b/app/resources/views/ventas/show/forma_pago/anticipo.blade.php @@ -1,6 +1,6 @@ Anticipo - + {{ $format->percent($anticipo['uf'] / $venta->valor, 2, true) }} {{$format->ufs($anticipo['uf'])}} {{$format->pesos($anticipo['pesos'])}} diff --git a/app/resources/views/ventas/show/forma_pago/bono_pie.blade.php b/app/resources/views/ventas/show/forma_pago/bono_pie.blade.php index adae804..1201915 100644 --- a/app/resources/views/ventas/show/forma_pago/bono_pie.blade.php +++ b/app/resources/views/ventas/show/forma_pago/bono_pie.blade.php @@ -14,7 +14,7 @@ @endif @if ($bonoPie !== null) - + {{ $format->percent($bonoPie->pago->valor() / $venta->valor, 2, true) }} {{$format->ufs($bonoPie->pago->valor())}} {{$format->pesos($bonoPie->pago->valor)}} diff --git a/app/resources/views/ventas/show/forma_pago/credito.blade.php b/app/resources/views/ventas/show/forma_pago/credito.blade.php index 0310043..6a34bb9 100644 --- a/app/resources/views/ventas/show/forma_pago/credito.blade.php +++ b/app/resources/views/ventas/show/forma_pago/credito.blade.php @@ -14,7 +14,7 @@ @endif @if ($credito !== null) - + {{ $format->percent($credito->pago->valor() / $venta->valor, 2, true) }} {{$format->ufs($credito->pago->valor())}} diff --git a/app/resources/views/ventas/show/forma_pago/pie.blade.php b/app/resources/views/ventas/show/forma_pago/pie.blade.php index 6f3df32..5e81861 100644 --- a/app/resources/views/ventas/show/forma_pago/pie.blade.php +++ b/app/resources/views/ventas/show/forma_pago/pie.blade.php @@ -8,7 +8,7 @@ - + {{ $format->percent($pie->valor / $venta->valor, 2, true) }} {{$format->ufs($pie->valor)}} {{$format->pesos($pie->valor * $pie->uf)}} Cuotas @@ -25,7 +25,7 @@ Pagado - + {{$format->percent($pie->pagado() / $venta->valor, 2, true)}} {{$format->ufs($pie->pagado())}} {{$format->pesos($pie->pagado('pesos'))}} From df7f462eadbce9ebbf6e82cb01b51f5117183515 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 3 Apr 2025 13:38:22 -0300 Subject: [PATCH 5/6] Mostrar porcentajes en venta --- app/resources/views/ventas/pies/cuotas.blade.php | 3 ++- app/resources/views/ventas/show/forma_pago/anticipo.blade.php | 2 +- app/resources/views/ventas/show/forma_pago/bono_pie.blade.php | 2 +- app/resources/views/ventas/show/forma_pago/credito.blade.php | 2 +- app/resources/views/ventas/show/forma_pago/pie.blade.php | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/resources/views/ventas/pies/cuotas.blade.php b/app/resources/views/ventas/pies/cuotas.blade.php index 49f734a..ae5c08b 100644 --- a/app/resources/views/ventas/pies/cuotas.blade.php +++ b/app/resources/views/ventas/pies/cuotas.blade.php @@ -167,7 +167,8 @@ }, 0.0))}} - {{$format->number(($total > 0) ? $pagado / $total * 100 : 0, 2)}}% + {{ $format->percent(($total > 0) ? $pagado / $total : 0, 2, true) }} Pie
+ {{ $format->percent($pagado / $venta->valor, 2, true) }} Promesa diff --git a/app/resources/views/ventas/show/forma_pago/anticipo.blade.php b/app/resources/views/ventas/show/forma_pago/anticipo.blade.php index d9f3095..5bb9fbf 100644 --- a/app/resources/views/ventas/show/forma_pago/anticipo.blade.php +++ b/app/resources/views/ventas/show/forma_pago/anticipo.blade.php @@ -1,6 +1,6 @@ Anticipo - + {{ $format->percent($anticipo['uf'] / $venta->valor, 2, true) }} {{$format->ufs($anticipo['uf'])}} {{$format->pesos($anticipo['pesos'])}} diff --git a/app/resources/views/ventas/show/forma_pago/bono_pie.blade.php b/app/resources/views/ventas/show/forma_pago/bono_pie.blade.php index adae804..1201915 100644 --- a/app/resources/views/ventas/show/forma_pago/bono_pie.blade.php +++ b/app/resources/views/ventas/show/forma_pago/bono_pie.blade.php @@ -14,7 +14,7 @@ @endif @if ($bonoPie !== null) - + {{ $format->percent($bonoPie->pago->valor() / $venta->valor, 2, true) }} {{$format->ufs($bonoPie->pago->valor())}} {{$format->pesos($bonoPie->pago->valor)}} diff --git a/app/resources/views/ventas/show/forma_pago/credito.blade.php b/app/resources/views/ventas/show/forma_pago/credito.blade.php index 0310043..6a34bb9 100644 --- a/app/resources/views/ventas/show/forma_pago/credito.blade.php +++ b/app/resources/views/ventas/show/forma_pago/credito.blade.php @@ -14,7 +14,7 @@ @endif @if ($credito !== null) - + {{ $format->percent($credito->pago->valor() / $venta->valor, 2, true) }} {{$format->ufs($credito->pago->valor())}} diff --git a/app/resources/views/ventas/show/forma_pago/pie.blade.php b/app/resources/views/ventas/show/forma_pago/pie.blade.php index 6f3df32..5e81861 100644 --- a/app/resources/views/ventas/show/forma_pago/pie.blade.php +++ b/app/resources/views/ventas/show/forma_pago/pie.blade.php @@ -8,7 +8,7 @@ - + {{ $format->percent($pie->valor / $venta->valor, 2, true) }} {{$format->ufs($pie->valor)}} {{$format->pesos($pie->valor * $pie->uf)}} Cuotas @@ -25,7 +25,7 @@ Pagado - + {{$format->percent($pie->pagado() / $venta->valor, 2, true)}} {{$format->ufs($pie->pagado())}} {{$format->pesos($pie->pagado('pesos'))}} From 3b38b5d3494f85ae48e00d1c885105f8a21a5dd4 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Fri, 4 Apr 2025 13:19:20 -0300 Subject: [PATCH 6/6] Si no existe Pie no muestra reajuste. Mostrar loading mientras se guarda --- .../views/ventas/escriturar.blade.php | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/app/resources/views/ventas/escriturar.blade.php b/app/resources/views/ventas/escriturar.blade.php index feb6786..e61e3f5 100644 --- a/app/resources/views/ventas/escriturar.blade.php +++ b/app/resources/views/ventas/escriturar.blade.php @@ -23,43 +23,45 @@ - @if ($venta->formaPago()->pie->reajuste === null) -

Reajuste

-
-
- -
-
$
- + @if ($venta->formaPago()->pie !== null) + @if ($venta->formaPago()->pie->reajuste === null) +

Reajuste

+
+
+ +
+
$
+ +
-
-
- -
-
- - +
+ +
+
+ + +
-
- @else -

Reajuste

-
-
- -
-
$
- + @else +

Reajuste

+
+
+ +
+
$
+ +
+
+
+ +
+ +
-
- -
- -
-
-
+ @endif @endif @if (!isset($venta->formaPago()->escritura))

Pago en Escritura

@@ -249,6 +251,7 @@ subsidio.watch() $('#escriturar_form').submit(event => { event.preventDefault() + $('.ui.button').addClass('loading') const url = '{{$urls->api}}/venta/{{$venta->id}}/escriturar' const body = new FormData(event.currentTarget) const fecha = $('#fecha').calendar('get date') @@ -268,6 +271,7 @@ } } fetchAPI(url, {method: 'post', body}).then(response => { + $('.ui.button').removeClass('loading') if (response.ok) { return response.json() }