FIX: IPC en factura
This commit is contained in:
@ -927,7 +927,7 @@
|
||||
date: new Intl.DateTimeFormat('es-CL', {year: 'numeric', month: '2-digit', day: '2-digit'}),
|
||||
pesos: new Intl.NumberFormat('es-CL', {minimumFractionDigits: 0, maximumFractionDigits: 0}),
|
||||
ufs: new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2}),
|
||||
percent: new Intl.NumberFormat('es-CL', {minimumFractionDigits: 2, maximumFractionDigits: 2})
|
||||
percent: new Intl.NumberFormat('es-CL', {minimumFractionDigits: 4, maximumFractionDigits: 4})
|
||||
},
|
||||
draw() {
|
||||
return {
|
||||
|
@ -6,9 +6,10 @@ use DateTimeImmutable;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Facturacion
|
||||
class Facturacion extends Ideal\Controller
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Proyecto $proyectoService, Service\Proyecto\Terreno $terrenoService): ResponseInterface
|
||||
@ -28,8 +29,8 @@ class Facturacion
|
||||
$uf = $ufService->get($venta->currentEstado()->fecha);
|
||||
$terreno = $terrenoService->valor($venta->proyecto()->id);
|
||||
$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 = $venta->currentEstado()->fecha->sub(new DateInterval('P1M'));
|
||||
if ($prevMonth->format('m') === $venta->currentEstado()->fecha->format('m')) {
|
||||
$prevMonth = $prevMonth->sub(new DateInterval('P10D'));
|
||||
}
|
||||
$ipc = $ipcService->get($lastNov, $prevMonth);
|
||||
@ -38,8 +39,11 @@ class Facturacion
|
||||
if ($prevMonthTerreno->format('m') === $terreno->fecha->format('m')) {
|
||||
$prevMonthTerreno = $prevMonthTerreno->sub(new DateInterval('P10D'));
|
||||
}
|
||||
$ipc = $ipcService->get($prevMonthTerreno, $prevMonth);
|
||||
if ($prevMonthTerreno->format('Y-m') !== $lastNov->format('Y-m')) {
|
||||
$ipc = $ipcService->get($prevMonthTerreno, $prevMonth);
|
||||
}
|
||||
}
|
||||
|
||||
return $view->render($response, 'ventas.facturacion.show', compact('venta', 'terreno', 'uf', 'ipc'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user