FIX: Si no conecta con Nubox solo se reajusta el terreno.
This commit is contained in:
@ -3,10 +3,12 @@ namespace Incoviba\Service\Contabilidad;
|
||||
|
||||
use DateTimeInterface;
|
||||
use DateTimeImmutable;
|
||||
use DateMalformedStringException;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement\Exception;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
@ -81,6 +83,13 @@ class Nubox extends Ideal\Service
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $inmobiliaria_rut
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws Exception\HttpResponse
|
||||
* @throws DateMalformedStringException
|
||||
*/
|
||||
public function getCuentas(int $inmobiliaria_rut): array
|
||||
{
|
||||
$redisKey = "nubox:cuentas:{$inmobiliaria_rut}";
|
||||
@ -98,6 +107,13 @@ class Nubox extends Ideal\Service
|
||||
return $cuentas;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws DateMalformedStringException
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws Exception\HttpResponse
|
||||
* @throws Exception\EmptyResult
|
||||
*/
|
||||
public function getCuenta(int $inmobiliaria_rut, string $cuentaNombre): string
|
||||
{
|
||||
$cuentas = $this->getCuentas($inmobiliaria_rut);
|
||||
@ -109,6 +125,11 @@ class Nubox extends Ideal\Service
|
||||
}
|
||||
return array_values($validas)[0]['codigo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception\HttpResponse
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function getLibroMayor(int $inmobiliaria_rut, DateTimeInterface $from, DateTimeInterface $to): array
|
||||
{
|
||||
$inmobiliaria = $this->nuboxRepository->fetchByInmobiliaria($inmobiliaria_rut);
|
||||
@ -153,6 +174,12 @@ class Nubox extends Ideal\Service
|
||||
$response = $this->send($uri, $inmobiliaria_rut);
|
||||
return json_decode($response->getBody()->getContents(), JSON_OBJECT_AS_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws DateMalformedStringException
|
||||
* @throws Exception\HttpResponse
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function getMesCuenta(int $inmobiliaria_rut, string $cuenta, DateTimeInterface $mes): array
|
||||
{
|
||||
$inmobiliaria = $this->nuboxRepository->fetchByInmobiliaria($inmobiliaria_rut);
|
||||
@ -200,6 +227,10 @@ class Nubox extends Ideal\Service
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception\HttpResponse
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
private function send(string $uri, int $inmobiliaria_rut, string $method = 'GET', ?StreamInterface $body = null): ResponseInterface
|
||||
{
|
||||
$request = $this->requestFactory
|
||||
|
Reference in New Issue
Block a user