Implemented repository mapper, and venta show

This commit is contained in:
Juan Pablo Vial
2023-08-08 23:53:49 -04:00
parent ef30ae67d2
commit 59825259b6
111 changed files with 2766 additions and 612 deletions

View File

@ -4,8 +4,8 @@ namespace Incoviba\Repository\Venta;
use DateTimeImmutable;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal;
use Incoviba\Common\Implement;
use Incoviba\Model;
use Incoviba\Repository;
class Pie extends Ideal\Repository
{
@ -17,32 +17,22 @@ class Pie extends Ideal\Repository
public function create(?array $data = null): Define\Model
{
$map = [
'fecha' => [
'function' => function($data) {
return new DateTimeImmutable($data['fecha']);
}
],
'valor' => [],
'uf' => [],
'cuotas' => [],
'asociado' => [
'function' => function($data) {
$map = (new Implement\Repository\MapperParser(['valor', 'uf', 'cuotas']))
->register('fecha', new Implement\Repository\Mapper\DateTime('fecha'))
->register('asociado', (new Implement\Repository\Mapper())
->setFunction(function($data) {
if ($data['asociado'] === null or $data['asociado'] === 0) {
return null;
}
return $this->fetchById($data['asociado']);
}
],
'reajuste' => [
'function' => function($data) {
}))
->register('reajuste', (new Implement\Repository\Mapper())
->setFunction(function($data) {
if ($data['reajuste'] === null or $data['reajuste'] === 0) {
return null;
}
return $this->pagoRepository->fetchById($data['reajuste']);
}
]
];
}));
return $this->parseData(new Model\Venta\Pie(), $data, $map);
}
public function save(Define\Model $model): Define\Model