Implement search pago

This commit is contained in:
2024-01-08 17:33:42 -03:00
parent bc2333bc95
commit d225011ae9
10 changed files with 288 additions and 22 deletions

View File

@ -202,6 +202,11 @@ WHERE `proyecto`.`descripcion` = ? AND `unidad`.`descripcion` = ? AND tev.`activ
$query = "SELECT * FROM `{$this->getTable()}` WHERE `pie` = ?";
return $this->fetchOne($query, [$pie_id]);
}
public function fetchIdByPie(int $pie_id): array
{
$query = "SELECT `id` FROM `{$this->getTable()}` WHERE `pie` = ?";
return $this->connection->execute($query, [$pie_id])->fetch(PDO::FETCH_ASSOC);
}
public function fetchByUnidad(string $unidad, string $tipo): array
{
$query = "SELECT a.*
@ -275,4 +280,36 @@ WHERE ptu.`proyecto` = ? AND tev.`descripcion` IN ('firmado por inmobiliaria', '
GROUP BY a.`id`";
return $this->fetchMany($query, [$proyecto_id]);
}
public function fetchIdByEscritura(int $escritura_id): array
{
$query = $this->connection->getQueryBuilder()
->select('id')
->from($this->getTable())
->where('escritura = ?');
return $this->connection->execute($query, [$escritura_id])->fetch(PDO::FETCH_ASSOC);
}
public function fetchIdBySubsidio(int $subsidio_id): array
{
$query = $this->connection->getQueryBuilder()
->select('id')
->from($this->getTable())
->where('subsidio = ?');
return $this->connection->execute($query, [$subsidio_id])->fetch(PDO::FETCH_ASSOC);
}
public function fetchIdByCredito(int $credito_id): array
{
$query = $this->connection->getQueryBuilder()
->select('id')
->from($this->getTable())
->where('credito = ?');
return $this->connection->execute($query, [$credito_id])->fetch(PDO::FETCH_ASSOC);
}
public function fetchIdByBono(int $bono_id): array
{
$query = $this->connection->getQueryBuilder()
->select('id')
->from($this->getTable())
->where('bono_pie = ?');
return $this->connection->execute($query, [$bono_id])->fetch(PDO::FETCH_ASSOC);
}
}

View File

@ -35,4 +35,21 @@ class BonoPie extends Ideal\Repository
{
return $this->update($model, ['valor', 'pago'], $new_data);
}
public function fetchByValue(float $value): array
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('valor = ?');
return $this->fetchMany($query, [$value]);
}
public function fetchByPago(int $pago_id): Model\Venta\BonoPie
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('pago = ?');
return $this->fetchOne($query, [$pago_id]);
}
}

View File

@ -36,4 +36,21 @@ class Credito extends Ideal\Repository
{
return $this->update($model, ['banco', 'valor', 'fecha', 'uf', 'abonado', 'fecha_abono', 'pago'], $new_data);
}
public function fetchByValue(int $value): array
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('valor = ?');
return $this->fetchMany($query, [$value]);
}
public function fetchByPago(int $pago_id): Model\Venta\Credito
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('pago = ?');
return $this->fetchOne($query, [$pago_id]);
}
}

View File

@ -182,7 +182,8 @@ ORDER BY p1.`fecha`, v1.`descripcion`";
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('pie = ?');
->where('pie = ?')
->group('id');
return $this->fetchMany($query, [$pie_id]);
}
public function fetchVigenteByPie(int $pie_id): array
@ -192,7 +193,16 @@ FROM `{$this->getTable()}` a
JOIN `pago` ON `pago`.`id` = a.`pago`
JOIN (SELECT e1.* FROM `estado_pago` e1 JOIN (SELECT MAX(`id`) AS 'id', `pago` FROM `estado_pago` GROUP BY `pago`) e0 ON e0.`id` = e1.`id`) ep ON ep.`pago` = `pago`.`id`
JOIN `tipo_estado_pago` tep ON tep.`id` = ep.`estado`
WHERE a.`pie` = ? AND tep.`active` = 1";
WHERE a.`pie` = ? AND tep.`active` = 1
GROUP BY a.`id`";
return $this->fetchMany($query, [$pie_id]);
}
public function fetchByPago(int $pago_id): Model\Venta\Cuota
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('pago = ?');
return $this->fetchOne($query, [$pago_id]);
}
}

View File

@ -38,4 +38,21 @@ class Escritura extends Ideal\Repository
{
return $this->update($model, ['valor', 'fecha', 'uf', 'abonado', 'fecha_abono', 'pago'], $new_data);
}
public function fetchByValue(int $value): array
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('valor = ?');
return $this->fetchMany($query, [$value]);
}
public function fetchByPago(int $pago_id): Model\Venta\Escritura
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('pago = ?');
return $this->fetchOne($query, [$pago_id]);
}
}

View File

@ -100,4 +100,12 @@ FROM (
WHERE venta_id = ?";
return $this->fetchMany($query, [$venta_id]);
}
public function fetchByValue(int $value): array
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('valor = ? OR ROUND(valor/uf, 3) = ?');
return $this->fetchMany($query, [$value, $value]);
}
}

View File

@ -56,4 +56,20 @@ class Pie extends Ideal\Repository
->where('asociado = ?');
return $this->fetchMany($query, [$pie_id]);
}
public function fetchByValue(float $value): array
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('valor = ?');
return $this->fetchMany($query, [$value]);
}
public function fetchByReajuste(int $reajuste_id): Model\Venta\Pie
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('reajuste = ?');
return $this->fetchOne($query, [$reajuste_id]);
}
}

View File

@ -40,4 +40,13 @@ class Subsidio extends Ideal\Repository
{
return $this->update($model, ['pago', 'subsidio'], $new_data);
}
public function fetchByPago(int $pago_id): Model\Venta\Subsidio
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('subsidio = ? OR pago = ?');
return $this->fetchOne($query, [$pago_id, $pago_id]);
}
}