Facturacion
This commit is contained in:
36
app/src/Service/Proyecto/Terreno.php
Normal file
36
app/src/Service/Proyecto/Terreno.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Proyecto;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Terreno extends Ideal\Service
|
||||
{
|
||||
public function __construct(LoggerInterface $logger, protected Repository\Proyecto $proyectoRepository,
|
||||
protected Service\Contabilidad\Nubox $nuboxService)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
public function valor(int $proyecto_id): ?Model\Proyecto\Terreno
|
||||
{
|
||||
$terreno = null;
|
||||
try {
|
||||
$proyecto = $this->proyectoRepository->fetchById($proyecto_id);
|
||||
$today = new DateTimeImmutable();
|
||||
$lastDecember = (new DateTimeImmutable($today->modify('-1 year')->format('Y-12-31')));
|
||||
// 1110-02
|
||||
$movimientos = $this->nuboxService->getSaldoCuenta($proyecto->inmobiliaria()->rut, '1110-02', $lastDecember, true);
|
||||
error_log(var_export($movimientos, true).PHP_EOL,3,'/logs/debug');
|
||||
if ($proyecto->terreno->fecha >= $lastDecember) {
|
||||
return $proyecto->terreno;
|
||||
}
|
||||
} catch (Implement\Exception\EmptyResult) {}
|
||||
return $terreno;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user