FIX: Venta nueva no se ingresaba

This commit is contained in:
Juan Pablo Vial
2024-02-13 17:59:46 -03:00
parent ba0d4073d7
commit e542615128
5 changed files with 51 additions and 16 deletions

View File

@ -240,6 +240,15 @@ GROUP BY a.`id`";*/
->where('`unidad`.`descripcion` LIKE ? AND tu.`descripcion` = ?');
return $this->fetchMany($query, [$unidad, $tipo]);
}
public function fetchByUnidadId(int $unidad_id): Model\Venta
{
$query = $this->connection->getQueryBuilder()
->select('a.*')
->from("{$this->getTable()} a")
->joined('JOIN propiedad_unidad pu ON pu.propiedad = a.propiedad')
->where('pu.unidad = ?');
return $this->fetchOne($query, [$unidad_id]);
}
public function fetchIdsByUnidad(string $unidad, string $tipo): array
{
$query = $this->connection->getQueryBuilder()

View File

@ -22,7 +22,7 @@ class Propietario extends Ideal\Repository
public function create(?array $data = null): Define\Model
{
$map = (new Implement\Repository\MapperParser(['dv', 'nombres']))
$map = (new Implement\Repository\MapperParser(['rut', 'dv', 'nombres']))
->register('apellido_paterno', (new Implement\Repository\Mapper())
->setProperty('apellidos')
->setFunction(function($data) {
@ -64,8 +64,8 @@ class Propietario extends Ideal\Repository
public function save(Define\Model $model): Define\Model
{
$model->rut = $this->saveNew(
['dv', 'nombres', 'apellido_paterno', 'apellido_materno', 'direccion', 'otro', 'representante'],
[$model->dv, $model->nombres, $model->apellidos['paterno'], $model->apellidos['materno'], $model->datos->direccion->id, $model->otro->rut ?? 0, $model->representante->rut ?? 0]
['rut', 'dv', 'nombres', 'apellido_paterno', 'apellido_materno', 'direccion', 'otro', 'representante'],
[$model->rut, $model->dv, $model->nombres, $model->apellidos['paterno'], $model->apellidos['materno'], $model->datos->direccion->id, $model->otro->rut ?? 0, $model->representante->rut ?? 0]
);
return $model;
}