Facturacion

This commit is contained in:
Juan Pablo Vial
2024-04-15 20:13:15 -04:00
parent 8e4b5eaaf8
commit a33dd341cd
8 changed files with 259 additions and 6 deletions

View 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;
}
}