From fc543729d268ab28742ee9468359be54fec19c25 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Thu, 4 Jul 2024 16:28:01 -0400 Subject: [PATCH] FIX: Propietario no tomaba en consideracion comuna para direccion --- app/src/Repository/Direccion.php | 6 +++--- app/src/Service/Venta/Propietario.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/Repository/Direccion.php b/app/src/Repository/Direccion.php index e2396b4..0d55e98 100644 --- a/app/src/Repository/Direccion.php +++ b/app/src/Repository/Direccion.php @@ -40,9 +40,9 @@ class Direccion extends Ideal\Repository $query = "SELECT * FROM `{$this->getTable()}` WHERE `calle` = ? AND `numero` = ?"; return $this->fetchMany($query, [$calle, $numero]); } - public function fetchByCalleAndNumeroAndExtra(string $calle, int $numero, string $extra): Model\Direccion + public function fetchByCalleAndNumeroAndExtraAndComuna(string $calle, int $numero, string $extra, int $comuna_id): Model\Direccion { - $query = "SELECT * FROM `{$this->getTable()}` WHERE `calle` = ? AND `numero` = ? AND `extra` = ?"; - return $this->fetchOne($query, [$calle, $numero, $extra]); + $query = "SELECT * FROM `{$this->getTable()}` WHERE `calle` = ? AND `numero` = ? AND `extra` = ? AND `comuna` = ?"; + return $this->fetchOne($query, [$calle, $numero, $extra, $comuna_id]); } } diff --git a/app/src/Service/Venta/Propietario.php b/app/src/Service/Venta/Propietario.php index 4227292..0882104 100644 --- a/app/src/Service/Venta/Propietario.php +++ b/app/src/Service/Venta/Propietario.php @@ -114,7 +114,7 @@ class Propietario extends Service ], 0); $filtered_data = array_intersect_key($data, $fields); try { - $direccion = $this->direccionRepository->fetchByCalleAndNumeroAndExtra($filtered_data['calle'], $filtered_data['numero'], $filtered_data['extra']); + $direccion = $this->direccionRepository->fetchByCalleAndNumeroAndExtraAndComuna($filtered_data['calle'], $filtered_data['numero'], $filtered_data['extra'], $filtered_data['comuna']); } catch (EmptyResult) { $direccion = $this->direccionRepository->create($filtered_data); $direccion = $this->direccionRepository->save($direccion);