FIX: Fecha terreno

This commit is contained in:
Juan Pablo Vial
2025-01-16 19:30:11 -03:00
parent 44ea8acd39
commit 3262ef9a62
4 changed files with 24 additions and 11 deletions

View File

@ -31,12 +31,13 @@ class Terreno extends Ideal\Service
try {
$proyecto = $this->proyectoRepository->fetchById($proyecto_id);
$today = new DateTimeImmutable();
$lastDecember = (new DateTimeImmutable($today->format('Y-01-31')))->sub(new DateInterval('P1M'));
if ($proyecto->terreno->fecha >= $lastDecember) {
$lastNovember = (new DateTimeImmutable($today->format('Y-01-30')))->sub(new DateInterval('P2M'));
if ($proyecto->terreno->fecha >= $lastNovember) {
return $proyecto->terreno;
}
try {
return $this->getValorContable($proyecto, $lastDecember->add(new DateInterval('P1D')));
// Valor 1o Enero
return $this->getValorContable($proyecto, $lastNovember->add(new DateInterval('P1M'))->add(new DateInterval('P1D')));
} catch (Implement\Exception\EmptyResponse) {}
if ($proyecto->terreno->fecha === null) {
return null;
@ -83,7 +84,7 @@ class Terreno extends Ideal\Service
$novLast = new DateTimeImmutable($lastDecember->format('Y-11-1'));
$ipc = $this->ipcService->get($novPrevTerreno, $novLast);
$terreno = $proyecto->terreno;
$terreno->fecha = $lastDecember;
$terreno->fecha = $novLast;
$terreno->valor *= (1 + $ipc);
return $terreno;
}