This commit is contained in:
Juan Pablo Vial
2025-03-03 14:57:22 -03:00
parent d165440483
commit 8f16f33a1e
56 changed files with 749 additions and 105 deletions

View File

@ -2,6 +2,7 @@
namespace Incoviba\Service\Inmobiliaria;
use DateTimeImmutable;
use Incoviba\Exception\ServiceAction\Read;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal\Service;
use Incoviba\Common\Implement;
@ -16,19 +17,37 @@ class Cuenta extends Service
parent::__construct($logger);
}
/**
* @return array
* @throws Read
*/
public function getAllActive(): array
{
$cuentas = array_map([$this, 'process'], $this->cuentaRepository->fetchAll());
return array_values(array_filter($cuentas, function(Model\Inmobiliaria\Cuenta $cuenta) {
return $cuenta->currentEstado()->active;
}));
try {
$cuentas = array_map([$this, 'process'], $this->cuentaRepository->fetchAll());
return array_values(array_filter($cuentas, function(Model\Inmobiliaria\Cuenta $cuenta) {
return $cuenta->currentEstado()->active;
}));
} catch (Implement\Exception\EmptyResult $exception) {
throw new Read(__CLASS__, $exception);
}
}
/**
* @param int $inmobiliaria_rut
* @return array
* @throws Read
*/
public function getAllActiveByInmobiliaria(int $inmobiliaria_rut): array
{
$cuentas = array_map([$this, 'process'], $this->cuentaRepository->fetchByInmobiliaria($inmobiliaria_rut));
return array_values(array_filter($cuentas, function(Model\Inmobiliaria\Cuenta $cuenta) {
return $cuenta->currentEstado()->active;
}));
try {
$cuentas = array_map([$this, 'process'], $this->cuentaRepository->fetchByInmobiliaria($inmobiliaria_rut));
return array_values(array_filter($cuentas, function(Model\Inmobiliaria\Cuenta $cuenta) {
return $cuenta->currentEstado()->active;
}));
} catch (Implement\Exception\EmptyResult $exception) {
throw new Read(__CLASS__, $exception);
}
}
public function add(array $data): Model\Inmobiliaria\Cuenta
{

View File

@ -1,6 +1,7 @@
<?php
namespace Incoviba\Service\Inmobiliaria;
use Incoviba\Exception\ServiceAction\Read;
use PDOException;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal;
@ -73,7 +74,7 @@ class Proveedor extends Ideal\Service
}
$filteredData = $this->proveedorRepository->filterData($data);
return $this->process($this->proveedorRepository->edit($proveedor, $filteredData));
} catch (Implement\Exception\EmptyResult) {
} catch (Read | Implement\Exception\EmptyResult) {
return $proveedor;
}
}
@ -82,7 +83,7 @@ class Proveedor extends Ideal\Service
try {
$this->proveedorRepository->remove($proveedor);
return true;
} catch (Implement\Exception\EmptyResult | PDOException) {
} catch (PDOException) {
return false;
}
}