Edit Proveedores

This commit is contained in:
Juan Pablo Vial
2024-12-03 17:35:29 -03:00
parent 42e1dcdff7
commit 187b6f6f05
9 changed files with 232 additions and 49 deletions

View File

@ -55,14 +55,22 @@ class Proveedor extends Ideal\Service
}
}
/**
* @TODO Implement
* @param Model\Inmobiliaria\Proveedor $proveedor
* @param array $data
* @return Model\Inmobiliaria\Proveedor
*/
public function edit(Model\Inmobiliaria\Proveedor $proveedor, array $data): Model\Inmobiliaria\Proveedor
{
return $proveedor;
$filteredData = $this->proveedorRepository->filterData($data);
try {
if ($proveedor->contacto->rut !== $data['contacto']['rut']) {
$contacto = $this->contactoService->getById($data['contacto']['rut']);
$this->contactoService->edit($contacto, $data['contacto']);
}
return $this->process($this->proveedorRepository->edit($proveedor, $filteredData));
} catch (Implement\Exception\EmptyResult) {
return $proveedor;
}
}
public function delete(Model\Inmobiliaria\Proveedor $proveedor): bool
{

View File

@ -45,6 +45,17 @@ class Persona extends Ideal\Service
}
return $this->process($persona);
}
public function edit(Model\Persona $persona, array $data): Model\Persona
{
$filteredData = $this->personaRepository->filterData($data);
try {
$datosData = $this->datosPersonaRepository->filterData($data);
$this->datosPersonaRepository->edit($persona->datos(), $datosData);
return $this->personaRepository->edit($persona, $filteredData);
} catch (Implement\Exception\EmptyResult) {
return $persona;
}
}
protected function process(Model\Persona $persona): Model\Persona
{