Identificar movimientos nuevos y obsoletos

This commit is contained in:
Juan Pablo Vial
2024-12-16 23:05:38 -03:00
parent c4b9ca5ab7
commit e2284314bd
3 changed files with 53 additions and 8 deletions

View File

@ -99,4 +99,18 @@ class Movimiento extends Ideal\Repository
}
return $this->fetchMany($query, [$sociedad_rut, $mes->format('Y-m-01'), $mes->format('Y-m-t')]);
}
public function fetchMissingInDateRange(int $cuenta_id, DateTimeInterface $startDate, DateTimeInterface $endDate, array $idList = []): array
{
$query = $this->connection->getQueryBuilder()
->select()
->from($this->getTable())
->where('cuenta_id = ? AND fecha BETWEEN ? AND ?');
if (count($idList) > 0) {
$idString = implode(', ', array_map(function(int $id) {
return $this->connection->getPDO()->quote($id);
}, $idList));
$query->where("id NOT IN ({$idString})");
}
return $this->fetchMany($query, [$cuenta_id, $startDate->format('Y-m-d'), $endDate->format('Y-m-d')]);
}
}