diff --git a/app/common/Implement/Repository/Mapper.php b/app/common/Implement/Repository/Mapper.php index 0f94b27..909d4b1 100644 --- a/app/common/Implement/Repository/Mapper.php +++ b/app/common/Implement/Repository/Mapper.php @@ -68,18 +68,14 @@ 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) { - if ($this->hasDefault()) { - $value = $this->default; - } else { - throw $exception; - } + try { + $value = ($this->function)($data); + } catch (EmptyResult $exception) { + if ($this->hasDefault()) { + $value = $this->default; + } else { + throw $exception; } - } elseif ($this->hasDefault()) { - $value = $this->default; } } $model->{$property} = $value; diff --git a/app/src/Repository/Venta/Cuota.php b/app/src/Repository/Venta/Cuota.php index 16b2c69..e54baf5 100644 --- a/app/src/Repository/Venta/Cuota.php +++ b/app/src/Repository/Venta/Cuota.php @@ -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']); diff --git a/app/src/Repository/Venta/Pago.php b/app/src/Repository/Venta/Pago.php index 38c2443..cd9991b 100644 --- a/app/src/Repository/Venta/Pago.php +++ b/app/src/Repository/Venta/Pago.php @@ -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']);