5 Commits

Author SHA1 Message Date
8b8aa79b6d FIX: Mapeo de columnas faltante 2025-01-07 22:10:52 -03:00
e2d670a38c FIX: Index Respository 2025-01-07 21:44:23 -03:00
4d85b39cab FIX: Detalle movimiento->id 2025-01-07 21:43:00 -03:00
33c90f06dd FIX: Index Respository 2025-01-07 21:42:40 -03:00
3771af0282 FIX: Index Respository 2025-01-07 21:29:48 -03:00
3 changed files with 29 additions and 4 deletions

View File

@ -25,7 +25,7 @@ abstract class Repository implements Define\Repository
public function load(array $data_row): Define\Model
{
$model = $this->create($data_row);
$model->{$this->getKey()} = $data_row[$this->getKey()];
$this->setIndex($model, $data_row[$this->getKey()]);
return $model;
}
@ -34,7 +34,7 @@ abstract class Repository implements Define\Repository
$query = $this->connection->getQueryBuilder()
->delete()->from($this->getTable())
->where("{$this->getKey()} = ?");
$this->connection->execute($query, [$model->{$this->getKey()}]);
$this->connection->execute($query, [$this->getIndex($model)]);
}
/**
@ -73,6 +73,17 @@ abstract class Repository implements Define\Repository
{
return $this->key;
}
protected function setIndex(Define\Model &$model, mixed $value): Repository
{
$model->{$this->getKey()} = $value;
return $this;
}
protected function getIndex(Define\Model $model): mixed
{
return $model->id;
}
protected function parseData(Define\Model $model, ?array $data, Implement\Repository\MapperParser $data_map): Define\Model
{
if ($data === null) {
@ -146,9 +157,9 @@ abstract class Repository implements Define\Repository
->update($this->getTable())
->set($columns_string)
->where("{$this->getKey()} = ?");
$values []= $model->{$this->getKey()};
$values []= $this->getIndex($model);
$this->connection->execute($query, $values);
return $this->fetchById($model->{$this->getKey()});
return $this->fetchById($this->getIndex($model));
}
protected function fetchOne(string $query, ?array $data = null): Define\Model
{

View File

@ -73,4 +73,16 @@ class Detalle extends Ideal\Repository
{
return 'movimiento_id';
}
protected function setIndex(Define\Model &$model, mixed $value): Ideal\Repository
{
if (!isset($model->movimiento)) {
$model->movimiento = $this->movimientoRepository->fetchById($value);
}
return $this;
}
protected function getIndex(Define\Model $model): string
{
return $model->movimiento->id;
}
}

View File

@ -16,6 +16,7 @@ class Santander extends Banco
'Descripción' => 'glosa',
'Nº Docu' => 'documento',
'Cheques y Otros Cargos' => 'cargo',
'Cheques y Cargos' => 'cargo',
'Depósitos y Abonos' => 'abono',
'Saldo' => 'saldo',
'Categoría' => 'categoria',
@ -56,6 +57,7 @@ class Santander extends Banco
$valueColumns = [
'Cheques y Otros Cargos',
'Cheques y Cargos',
'Depósitos y Abonos',
'Saldo'
];