Factura multiple con cambio de fecha
This commit is contained in:
3
app/resources/views/layout/body/scripts/luxon.blade.php
Normal file
3
app/resources/views/layout/body/scripts/luxon.blade.php
Normal file
@ -0,0 +1,3 @@
|
||||
@push('page_scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/luxon@3.4.4/build/global/luxon.min.js" integrity="sha256-7NQm0bhvDJKosL8d+6ZgSi2LxZCIcA/TD087GLEBO9M=" crossorigin="anonymous"></script>
|
||||
@endpush
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
@ -19,10 +21,25 @@ class Facturacion
|
||||
}
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Venta $ventaService, Service\Proyecto\Terreno $terrenoService,
|
||||
Service\IPC $ipcService, Service\UF $ufService,
|
||||
int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->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'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user