FIX: Fecha terreno
This commit is contained in:
@ -35,18 +35,16 @@ class Facturacion extends Ideal\Controller
|
||||
$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->currentEstado()->fecha->sub(new DateInterval('P2M'));
|
||||
$prevMonth = $venta->currentEstado()->fecha->sub(new DateInterval('P1M'));
|
||||
if ($prevMonth->format('m') === $venta->currentEstado()->fecha->format('m')) {
|
||||
// If sub P1M stays in same month
|
||||
$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'));
|
||||
}
|
||||
if ($prevMonthTerreno->format('Y-m') !== $lastNov->format('Y-m')) {
|
||||
$ipc = $ipcService->get($prevMonthTerreno, $prevMonth);
|
||||
$monthTerreno = $terreno->fecha;
|
||||
if ($monthTerreno->format('Y-m') !== $lastNov->format('Y-m')) {
|
||||
$ipc = $ipcService->get($monthTerreno, $prevMonth);
|
||||
}
|
||||
}
|
||||
$facturas = $facturasService->getByVenta($venta->id);
|
||||
|
Reference in New Issue
Block a user