FIX: findPago sin numero

This commit is contained in:
2024-01-22 12:10:16 -03:00
parent 029cd095cb
commit 9d7857621e
2 changed files with 36 additions and 16 deletions

View File

@ -177,7 +177,7 @@ GROUP BY a.`id`";*/
->from("{$this->getTable()} a")
->joined('JOIN propiedad_unidad pu ON pu.propiedad = a.propiedad')
->joined('JOIN unidad ON unidad.id = pu.unidad AND unidad.pt')
->joined('proyecto_tipo_unidad ptu ON ptu.id = unidad.pt')
->joined('JOIN proyecto_tipo_unidad ptu ON ptu.id = unidad.pt')
->joined('JOIN (SELECT ev1.* FROM estado_venta ev1 JOIN (SELECT MAX(id) AS id, venta FROM estado_venta GROUP BY venta) ev0 ON ev0.id = ev1.id) ev ON ev.venta = a.id')
->joined('JOIN tipo_estado_venta tev ON tev.id = ev.estado')
->where('ptu.proyecto = ? AND tev.activa')
@ -191,7 +191,7 @@ FROM `{$this->getTable()}` a
JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`
WHERE ptu.`proyecto` = ? AND tev.`activa`
GROUP BY a.`id`";*/
return $this->connection->execute($query, [$proyecto_id])->fetchAll(PDO::FETCH_ASSOC);
return $this->fetchIds($query, [$proyecto_id]);
}
public function fetchActivaByProyecto(int $proyecto_id): array
{
@ -253,7 +253,7 @@ WHERE `proyecto`.`descripcion` = ? AND `unidad`.`descripcion` = ? AND tev.`activ
->select('id')
->from($this->getTable())
->where('pie = ?');
return $this->connection->execute($query, [$pie_id])->fetch(PDO::FETCH_ASSOC);
return $this->fetchId($query, [$pie_id]);
}
public function fetchByUnidad(string $unidad, string $tipo): array
{
@ -291,7 +291,7 @@ FROM `{$this->getTable()}` a
JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt`
JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`
WHERE `unidad`.`descripcion` LIKE ? AND tu.`descripcion` = ?";*/
return $this->connection->execute($query, [$unidad, $tipo])->fetchAll(PDO::FETCH_ASSOC);
return $this->fetchIds($query, [$unidad, $tipo]);
}
public function fetchByPrecio(string $precio): array
{
@ -307,7 +307,7 @@ WHERE `unidad`.`descripcion` LIKE ? AND tu.`descripcion` = ?";*/
->select('id')
->from($this->getTable())
->where('valor_uf = ?');
return $this->connection->execute($query, [$precio])->fetchAll(PDO::FETCH_ASSOC);
return $this->fetchIds($query, [$precio]);
}
public function fetchByPropietarioAndPropiedad(int $propietario_rut, int $propiedad_id): Model\Venta
{
@ -349,7 +349,7 @@ FROM `{$this->getTable()}` a
WHERE CONCAT_WS('-', `propietario`.`rut`, `propietario`.`dv`) LIKE :propietario OR `propietario`.`nombres` LIKE :propietario
OR `propietario`.`apellido_paterno` LIKE :propietario OR `propietario`.`apellido_materno` LIKE :propietario
OR CONCAT_WS(' ', `propietario`.`nombres`, `propietario`.`apellido_paterno`, `propietario`.`apellido_materno`) LIKE :propietario";*/
return $this->connection->execute($query, [':propietario' => "%{$propietario}%"])->fetchAll(PDO::FETCH_ASSOC);
return $this->fetchIds($query, [':propietario' => "%{$propietario}%"]);
}
public function fetchByPropietarioNombreCompleto(string $propietario): array
{
@ -393,7 +393,7 @@ GROUP BY a.`id`";*/
->select('id')
->from($this->getTable())
->where('escritura = ?');
return $this->connection->execute($query, [$escritura_id])->fetch(PDO::FETCH_ASSOC);
return $this->fetchId($query, [$escritura_id]);
}
public function fetchIdBySubsidio(int $subsidio_id): array
{
@ -401,7 +401,7 @@ GROUP BY a.`id`";*/
->select('id')
->from($this->getTable())
->where('subsidio = ?');
return $this->connection->execute($query, [$subsidio_id])->fetch(PDO::FETCH_ASSOC);
return $this->fetchId($query, [$subsidio_id]);
}
public function fetchIdByCredito(int $credito_id): array
{
@ -409,7 +409,7 @@ GROUP BY a.`id`";*/
->select('id')
->from($this->getTable())
->where('credito = ?');
return $this->connection->execute($query, [$credito_id])->fetch(PDO::FETCH_ASSOC);
return $this->fetchId($query, [$credito_id]);
}
public function fetchIdByBono(int $bono_id): array
{
@ -417,6 +417,23 @@ GROUP BY a.`id`";*/
->select('id')
->from($this->getTable())
->where('bono_pie = ?');
return $this->connection->execute($query, [$bono_id])->fetch(PDO::FETCH_ASSOC);
return $this->fetchId($query, [$bono_id]);
}
protected function fetchIds(string $query, ?array $data = null): array
{
$results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC);
if ($results === false) {
throw new Implement\Exception\EmptyResult($query);
}
return $results;
}
protected function fetchId(string $query, ?array $data = null): array
{
$results = $this->connection->execute($query, $data)->fetch(PDO::FETCH_ASSOC);
if ($results === false) {
throw new Implement\Exception\EmptyResult($query);
}
return $results;
}
}

View File

@ -142,6 +142,9 @@ class Search
}
protected function findPago(string $query): array
{
if ($query != 0) {
return [];
}
$methods = [
'findPie',
'findEscritura',
@ -152,7 +155,7 @@ class Search
$valor = str_replace(['$', '.', ','], ['', '', '.'], $query);
$pagos = [];
try {
$pagos = $this->pagoRepository->fetchByValue($valor);
$pagos = $this->pagoRepository->fetchByValue((int) $valor);
} catch (EmptyResult) {}
$results = [];
foreach ($methods as $method) {
@ -164,7 +167,7 @@ class Search
{
$results = [];
try {
$pies = $this->pieRepository->fetchByValue($query);
$pies = $this->pieRepository->fetchByValue((float) $query);
foreach ($pies as $pie) {
try {
$this->add($results, [$this->ventaRepository->fetchIdByPie($pie->id)]);
@ -180,7 +183,7 @@ class Search
$results = [];
foreach ($pagos as $pago) {
try {
$pie = $this->pieRepository->fetchByReajuste($pago->id);
$pie = $this->pieRepository->fetchByReajuste((int) $pago->id);
$this->add($results, [$this->ventaRepository->fetchIdByPie($pie->id)]);
} catch (EmptyResult) {}
}
@ -201,7 +204,7 @@ class Search
{
$results = [];
try {
$escrituras = $this->escrituraRepository->fetchByValue($query);
$escrituras = $this->escrituraRepository->fetchByValue((int) $query);
foreach ($escrituras as $escritura) {
try {
$this->add($results, [$this->ventaRepository->fetchIdByEscritura($escritura->id)]);
@ -231,7 +234,7 @@ class Search
{
$results = [];
try {
$creditos = $this->creditoRepository->fetchByValue($query);
$creditos = $this->creditoRepository->fetchByValue((int) $query);
foreach ($creditos as $credito) {
try {
$this->add($results, [$this->ventaRepository->fetchIdByCredito($credito->id)]);
@ -256,7 +259,7 @@ class Search
{
$results = [];
try {
$bonos = $this->bonoPieRepository->fetchByValue($query);
$bonos = $this->bonoPieRepository->fetchByValue((float) $query);
foreach ($bonos as $bono) {
try {
$this->add($results, [$this->ventaRepository->fetchIdByBono($bono->id)]);