2023-09-12

This commit is contained in:
Juan Pablo Vial
2023-09-13 18:51:46 -03:00
parent fa15da1ee2
commit 0cd357b6cb
47 changed files with 1225 additions and 102 deletions

View File

@ -50,7 +50,13 @@ class Propietario extends Ideal\Repository
}
return $this->fetchById($data['representante']);
}))
->register('otro', (new Implement\Repository\Mapper\Boolean('otro'))
->register('otro', (new Implement\Repository\Mapper())
->setFunction(function($data) {
if ($data['otro'] === null or $data['otro'] === 0) {
return null;
}
return $this->fetchById($data['otro']);
})
->setDefault(null));
return $this->parseData(new Model\Venta\Propietario(), $data, $map);
}
@ -58,14 +64,14 @@ class Propietario extends Ideal\Repository
public function save(Define\Model $model): Define\Model
{
$model->rut = $this->saveNew(
['dv', 'nombres', 'apellido_paterno', 'apellido_materno'],
[$model->dv, $model->nombres, $model->apellidos['paterno'], $model->apellidos['materno']]
['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]
);
return $model;
}
public function edit(Define\Model $model, array $new_data): Define\Model
{
return $this->update($model, ['dv', 'nombres', 'apellido_paterno', 'apellido_materno'], $new_data);
return $this->update($model, ['dv', 'nombres', 'apellido_paterno', 'apellido_materno', 'direccion', 'otro', 'representante'], $new_data);
}
}