FIX: Banco vacio o con espacio

This commit is contained in:
Juan Pablo Vial
2025-02-04 12:09:34 -03:00
parent 4073b96796
commit 9f56604917
3 changed files with 9 additions and 13 deletions

View File

@ -68,7 +68,6 @@ class Mapper implements Define\Repository\Mapper
}
$value = $data[$column];
if ($this->hasFunction()) {
if ($value !== null and $value !== '') {
try {
$value = ($this->function)($data);
} catch (EmptyResult $exception) {
@ -78,9 +77,6 @@ class Mapper implements Define\Repository\Mapper
throw $exception;
}
}
} elseif ($this->hasDefault()) {
$value = $this->default;
}
}
$model->{$property} = $value;
return true;

View File

@ -35,7 +35,7 @@ class Cuota extends Ideal\Repository
->register('estado', new Implement\Repository\Mapper\Boolean('estado'))
->register('banco', (new Implement\Repository\Mapper())
->setFunction(function($data) {
if ($data['banco'] === null or $data['banco'] === '') {
if ($data['banco'] === null or $data['banco'] === 0 or trim($data['banco']) === '') {
return null;
}
return $this->bancoRepository->fetchById($data['banco']);

View File

@ -24,7 +24,7 @@ class Pago extends Ideal\Repository
$map = (new Implement\Repository\MapperParser(['valor', 'identificador', 'uf', 'pagador']))
->register('banco', (new Implement\Repository\Mapper())
->setFunction(function($data) {
if ($data['banco'] === null or $data['banco'] === 0) {
if ($data['banco'] === null or $data['banco'] === 0 or trim($data['banco']) === '') {
return null;
}
return $this->bancoRepository->fetchById($data['banco']);