diff --git a/app/resources/views/layout/body/scripts/luxon.blade.php b/app/resources/views/layout/body/scripts/luxon.blade.php
new file mode 100644
index 0000000..b2e9b8e
--- /dev/null
+++ b/app/resources/views/layout/body/scripts/luxon.blade.php
@@ -0,0 +1,3 @@
+@push('page_scripts')
+
+@endpush
diff --git a/app/resources/views/ventas/facturacion/show.blade.php b/app/resources/views/ventas/facturacion/show.blade.php
index 7de3264..98dcb92 100644
--- a/app/resources/views/ventas/facturacion/show.blade.php
+++ b/app/resources/views/ventas/facturacion/show.blade.php
@@ -13,230 +13,889 @@
{{$venta->propiedad()->summary()}}
-
-
-
- Valor Venta: {{$format->ufs($venta->valor)}}
-
-
-
-
- @if ($venta->currentEstado()->fecha->sub(new DateInterval('P1M')) > $terreno?->fecha
- and ($terreno?->valor ?? 0) === 0.0)
-
-
-
- IPC no disponible para este mes.
-
-
- @endif
+
- {{--
-
-
-
-
- {{mb_strtoupper($venta->proyecto()->inmobiliaria()->nombreCompleto())}}
-
- GIRO:
- Dirección: {{$venta->proyecto()->direccion()->simple()}}
-
-
-
-
- RUT: {{$venta->proyecto()->inmobiliaria()->rut()}}
- FACTURA ELECTRÓNICA
- N° #
-
-
-
-
-
-
-
- Señor(es) |
- {{$venta->propietario()->nombreCompleto()}} |
- RUT |
- {{$venta->propietario()->rut()}} |
-
-
- Giro |
- Otras Actividades Profesionales |
- Fecha Emisión |
- {{(new IntlDateFormatter('es-CL', IntlDateFormatter::LONG, IntlDateFormatter::NONE))->format($venta->currentEstado()->fecha)}} |
-
-
- Dirección |
- {{$venta->propietario()->datos->direccion->simple()}} |
- Comuna |
- {{mb_strtoupper($venta->propietario()->datos->direccion->comuna->descripcion)}} |
-
-
-
-
-
-
-
- DETALLES |
-
-
- N° |
- Descripción |
- Cant/Unidad |
- Prec. Unit. |
- Ind |
- Total |
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
- TOTALES |
-
-
-
-
- Monto Neto |
- |
-
-
- Monto Exento |
- |
-
-
- 19% IVA |
- |
-
-
- Monto Total |
- |
-
-
-
-
-
-
-
- --}}
+
@endsection
+@include('layout.body.scripts.luxon')
+
@push('page_scripts')
@endpush
diff --git a/app/src/Controller/Ventas/Facturacion.php b/app/src/Controller/Ventas/Facturacion.php
index b73ddd7..92c4fe7 100644
--- a/app/src/Controller/Ventas/Facturacion.php
+++ b/app/src/Controller/Ventas/Facturacion.php
@@ -1,6 +1,8 @@
getById($venta_id);
+ $uf = $ufService->get($venta->currentEstado()->fecha);
$terreno = $terrenoService->valor($venta->proyecto()->id);
- return $view->render($response, 'ventas.facturacion.show', compact('venta', 'terreno'));
+ $lastNov = new DateTimeImmutable((new DateTimeImmutable())->sub(new DateInterval('P1Y'))->format('Y-11-1'));
+ $prevMonth = $venta->fecha->sub(new DateInterval('P1M'));
+ if ($prevMonth->format('m') === $venta->fecha->format('m')) {
+ $prevMonth = $prevMonth->sub(new DateInterval('P10D'));
+ }
+ $ipc = $ipcService->get($lastNov, $prevMonth);
+ if ($terreno !== null) {
+ $prevMonthTerreno = $terreno->fecha->sub(new DateInterval('P1M'));
+ if ($prevMonthTerreno->format('m') === $terreno->fecha->format('m')) {
+ $prevMonthTerreno = $prevMonthTerreno->sub(new DateInterval('P10D'));
+ }
+ $ipc = $ipcService->get($prevMonthTerreno, $prevMonth);
+ }
+ return $view->render($response, 'ventas.facturacion.show', compact('venta', 'terreno', 'uf', 'ipc'));
}
}