Merge branch 'develop' into feature/cierres

This commit is contained in:
Juan Pablo Vial
2025-03-03 15:32:25 -03:00
58 changed files with 753 additions and 109 deletions

View File

@ -31,11 +31,23 @@ class BonoPie extends Ideal\Repository
);
return $model;
}
/**
* @param Define\Model $model
* @param array $new_data
* @return Define\Model
* @throws Implement\Exception\EmptyResult
*/
public function edit(Define\Model $model, array $new_data): Define\Model
{
return $this->update($model, ['valor', 'pago'], $new_data);
}
/**
* @param float $value
* @return array
* @throws Implement\Exception\EmptyResult
*/
public function fetchByValue(float $value): array
{
$query = $this->connection->getQueryBuilder()
@ -44,6 +56,12 @@ class BonoPie extends Ideal\Repository
->where('valor = ?');
return $this->fetchMany($query, [$value]);
}
/**
* @param int $pago_id
* @return Model\Venta\BonoPie
* @throws Implement\Exception\EmptyResult
*/
public function fetchByPago(int $pago_id): Model\Venta\BonoPie
{
$query = $this->connection->getQueryBuilder()
@ -52,6 +70,12 @@ class BonoPie extends Ideal\Repository
->where('pago = ?');
return $this->fetchOne($query, [$pago_id]);
}
/**
* @param int $venta_id
* @return Model\Venta\BonoPie
* @throws Implement\Exception\EmptyResult
*/
public function fetchByVenta(int $venta_id): Model\Venta\BonoPie
{
$query = $this->connection->getQueryBuilder()

View File

@ -37,6 +37,11 @@ class Credito extends Ideal\Repository
return $this->update($model, ['banco', 'valor', 'fecha', 'uf', 'abonado', 'fecha_abono', 'pago'], $new_data);
}
/**
* @param int $value
* @return array
* @throws Implement\Exception\EmptyResult
*/
public function fetchByValue(int $value): array
{
$query = $this->connection->getQueryBuilder()

View File

@ -198,6 +198,12 @@ GROUP BY p1.`fecha`, v1.`descripcion`
ORDER BY p1.`fecha`, v1.`descripcion`";
return $this->fetchAsArray($query);*/
}
/**
* @param int $pie_id
* @return array
* @throws Implement\Exception\EmptyResult
*/
public function fetchByPie(int $pie_id): array
{
$query = $this->connection->getQueryBuilder()

View File

@ -39,6 +39,11 @@ class Escritura extends Ideal\Repository
return $this->update($model, ['valor', 'fecha', 'uf', 'abonado', 'fecha_abono', 'pago'], $new_data);
}
/**
* @param int $value
* @return array
* @throws Implement\Exception\EmptyResult
*/
public function fetchByValue(int $value): array
{
$query = $this->connection->getQueryBuilder()
@ -55,6 +60,12 @@ class Escritura extends Ideal\Repository
->where('pago = ?');
return $this->fetchOne($query, [$pago_id]);
}
/**
* @param int $venta_id
* @return Model\Venta\Escritura
* @throws Implement\Exception\EmptyResult
*/
public function fetchByVenta(int $venta_id): Model\Venta\Escritura
{
$query = $this->connection->getQueryBuilder()

View File

@ -100,6 +100,12 @@ FROM (
WHERE venta_id = ?";
return $this->fetchMany($query, [$venta_id]);
}
/**
* @param int $value
* @return array
* @throws Implement\Exception\EmptyResult
*/
public function fetchByValue(int $value): array
{
$query = $this->connection->getQueryBuilder()

View File

@ -48,6 +48,11 @@ class Pie extends Ideal\Repository
return $this->update($model, ['fecha', 'valor', 'uf', 'cuotas', 'asociado', 'reajuste'], $new_data);
}
/**
* @param int $pie_id
* @return array
* @throws Implement\Exception\EmptyResult
*/
public function fetchAsociados(int $pie_id): array
{
$query = $this->connection->getQueryBuilder()
@ -56,6 +61,12 @@ class Pie extends Ideal\Repository
->where('asociado = ?');
return $this->fetchMany($query, [$pie_id]);
}
/**
* @param float $value
* @return array
* @throws Implement\Exception\EmptyResult
*/
public function fetchByValue(float $value): array
{
$query = $this->connection->getQueryBuilder()

View File

@ -32,11 +32,23 @@ class Precio extends Ideal\Repository
);
return $model;
}
/**
* @param Define\Model $model
* @param array $new_data
* @return Define\Model
* @throws Implement\Exception\EmptyResult
*/
public function edit(Define\Model $model, array $new_data): Define\Model
{
return $this->update($model, ['unidad', 'valor'], $new_data);
}
/**
* @param int $proyecto_id
* @return array
* @throws Implement\Exception\EmptyResult
*/
public function fetchByProyecto(int $proyecto_id): array
{
$query = "SELECT a.*
@ -50,6 +62,12 @@ WHERE ptu.`proyecto` = ? AND tep.`descripcion` = 'vigente'
ORDER BY tu.`orden`, ptu.`nombre`, `unidad`.`subtipo`, LPAD(`unidad`.`descripcion`, 4, '0')";
return $this->fetchMany($query, [$proyecto_id]);
}
/**
* @param int $unidad_id
* @return array
* @throws Implement\Exception\EmptyResult
*/
public function fetchByUnidad(int $unidad_id): array
{
$query = "SELECT a.*
@ -59,6 +77,12 @@ FROM `{$this->getTable()}` a
WHERE `unidad` = ?";
return $this->fetchMany($query, [$unidad_id]);
}
/**
* @param int $unidad_id
* @return Define\Model
* @throws Implement\Exception\EmptyResult
*/
public function fetchVigenteByUnidad(int $unidad_id): Define\Model
{
$query = "SELECT a.*
@ -68,6 +92,13 @@ FROM `{$this->getTable()}` a
WHERE `unidad` = ? AND tep.`descripcion` = 'vigente'";
return $this->fetchOne($query, [$unidad_id]);
}
/**
* @param int $unidad_id
* @param string $date_time
* @return Define\Model
* @throws Implement\Exception\EmptyResult
*/
public function fetchByUnidadAndDate(int $unidad_id, string $date_time): Define\Model
{
$query = "SELECT a.*

View File

@ -48,11 +48,23 @@ class Propiedad extends Ideal\Repository
);
return $model;
}
/**
* @param Define\Model $model
* @param array $new_data
* @return Model\Venta\Propiedad
* @throws Implement\Exception\EmptyResult
*/
public function edit(Define\Model $model, array $new_data): Model\Venta\Propiedad
{
return $this->update($model, ['unidad_principal', 'estacionamientos', 'bodegas', 'estado'], $new_data);
}
/**
* @param int $unidad_id
* @return Model\Venta\Propiedad
* @throws Implement\Exception\EmptyResult
*/
public function fetchVigenteByUnidad(int $unidad_id): Model\Venta\Propiedad
{
$query = "SELECT * FROM `{$this->getTable()}` WHERE `unidad_principal` = ?";

View File

@ -49,6 +49,12 @@ class Subsidio extends Ideal\Repository
->where('subsidio = ? OR pago = ?');
return $this->fetchOne($query, [$pago_id, $pago_id]);
}
/**
* @param int $venta_id
* @return Model\Venta\Subsidio
* @throws Implement\Exception\EmptyResult
*/
public function fetchByVenta(int $venta_id): Model\Venta\Subsidio
{
$query = $this->connection->getQueryBuilder()

View File

@ -33,6 +33,11 @@ class TipoEstadoVenta extends Ideal\Repository
return $this->update($model, ['descripcion', 'activa'], $new_data);
}
/**
* @param string $descripcion
* @return Model\Venta\TipoEstadoVenta
* @throws Implement\Exception\EmptyResult
*/
public function fetchByDescripcion(string $descripcion): Model\Venta\TipoEstadoVenta
{
$query = "SELECT * FROM `{$this->getTable()}` WHERE `descripcion` = ?";

View File

@ -129,6 +129,13 @@ class Unidad extends Ideal\Repository
->where("a.`descripcion` LIKE ? AND tu.`descripcion` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)");
return $this->fetchMany($query, [$descripcion, $tipo]);
}
/**
* @param string $descripcion
* @param string $tipo
* @return array
* @throws Implement\Exception\EmptyResult
*/
public function fetchDisponiblesIdsByDescripcionAndTipo(string $descripcion, string $tipo): array
{
$query = $this->connection->getQueryBuilder()
@ -141,7 +148,11 @@ class Unidad extends Ideal\Repository
LEFT OUTER JOIN (SELECT ev1.* FROM `estado_venta` ev1 JOIN (SELECT MAX(`id`) as 'id', `venta` FROM `estado_venta`) ev0 ON ev0.`id` = ev1.`id`) ev ON ev.`venta` = `venta`.`id`
LEFT OUTER JOIN `tipo_estado_venta` tev ON tev.`id` = ev.`estado`")
->where("a.`descripcion` LIKE ? AND tu.`descripcion` = ? AND (pu.`id` IS NULL OR `venta`.`id` IS NULL OR tev.`activa` = 0)");
return $this->connection->execute($query, [$descripcion, $tipo])->fetchAll(PDO::FETCH_ASSOC);
try {
return $this->connection->execute($query, [$descripcion, $tipo])->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $exception) {
throw new Implement\Exception\EmptyResult($query, $exception);
}
}
public function fetchByIdForSearch(int $unidad_id): array
{

View File

@ -39,6 +39,11 @@ class Prorrateo extends Ideal\Repository
return $this->update($model, ['unidad_id', 'prorrateo'], $new_data);
}
/**
* @param int $unidad_id
* @return Model\Venta\Unidad\Prorrateo
* @throws Implement\Exception\EmptyResult
*/
public function fetchByUnidad(int $unidad_id): Model\Venta\Unidad\Prorrateo
{
$query = $this->connection->getQueryBuilder()