Simplificacion de retorno de ventas por unidades

This commit is contained in:
Juan Pablo Vial
2025-04-22 13:08:15 -04:00
parent 5147450ed6
commit eabdab23c3
3 changed files with 48 additions and 4 deletions

View File

@ -7,6 +7,7 @@ use Psr\Log\LoggerInterface;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal\Service;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Exception;
use Incoviba\Repository;
use Incoviba\Model;
@ -21,6 +22,33 @@ class Propiedad extends Service
parent::__construct($logger);
}
/**
* @param int $propiedad_id
* @return Model\Venta\Propiedad
* @throws Exception\ServiceAction\Read
*/
public function getById(int $propiedad_id): Model\Venta\Propiedad
{
try {
return $this->process($this->propiedadRepository->fetchById($propiedad_id));
} catch (EmptyResult $exception) {
throw new Exception\ServiceAction\Read(__CLASS__, $exception);
}
}
/**
* @param int $propiedad_id
* @return array
* @throws Exception\ServiceAction\Read
*/
public function getArrayById(int $propiedad_id): array
{
try {
return $this->propiedadRepository->fetchArrayById($propiedad_id);
} catch (EmptyResult $exception) {
throw new Exception\ServiceAction\Read(__CLASS__, $exception);
}
}
public function addPropiedad(array $ids): Model\Venta\Propiedad
{
$unidades = [];
@ -90,4 +118,8 @@ class Propiedad extends Service
$statement->execute([$propiedad->id, $id]);
}
}
protected function process(Model\Venta\Propiedad $propiedad): Model\Venta\Propiedad
{
return $propiedad;
}
}