From 4786ee25521d977ccf014f58caa278c3744846e9 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Sun, 28 Apr 2024 23:01:55 -0400 Subject: [PATCH] Factura multiple con cambio de fecha --- .../views/layout/body/scripts/luxon.blade.php | 3 + .../views/ventas/facturacion/show.blade.php | 1529 ++++++++++------- app/src/Controller/Ventas/Facturacion.php | 19 +- 3 files changed, 972 insertions(+), 579 deletions(-) create mode 100644 app/resources/views/layout/body/scripts/luxon.blade.php 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)}} -
-
-
-
-
- @foreach ($venta->propiedad()->unidades as $unidad) -
- -
- -
UF
-
-
- @endforeach -
-
- @foreach($venta->propiedad()->unidades as $unidad) -
- @if ($unidad->prorrateo === 0.0) - -
- -
%
-
- @endif -
- @endforeach -
-
- @php $lastDic = new DateTimeImmutable((new DateTimeImmutable())->sub(new DateInterval('P1Y'))->format('Y-12-31')); @endphp - @if (!isset($terreno->fecha) or $terreno->fecha->getTimestamp() < 0 or $terreno->fecha < $lastDic) -
- -
-
$
- -
-
- @endif -
- - -
-
-
-
- -
- -
- -
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- - -
-
-
-
-
- @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()}}
GiroOtras Actividades ProfesionalesFecha 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
DescripciónCant/UnidadPrec. Unit.IndTotal
-
-
-
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - -
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')); } }