FIX: Fecha terreno
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user