fix(contracts) : hide contract phases entirely before RTT_START_DATE
EmployeeContractPhaseResolver now accepts the data-start date and filters out phases whose endDate is strictly before it. No work-hour or absence data exists before the application launch date, so legacy contract periods that ended before that date would surface meaningless RTT/CP figures in the phase picker. For employees who joined long before the software (typical legacy 35h contracts, in production since 2014), only the current phase remains visible — which also collapses the picker (threshold ≥ 2 phases). The Employee entity reads RTT_START_DATE from $_SERVER/$_ENV directly since it has no DI. The resolver service is wired via services.yaml. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -446,7 +446,10 @@ class Employee
|
||||
#[Groups(['employee:read'])]
|
||||
public function getContractPhases(): array
|
||||
{
|
||||
$resolver = new EmployeeContractPhaseResolver();
|
||||
// Read RTT_START_DATE directly here: the entity has no DI but must filter
|
||||
// out contract phases that ended before the application's data start.
|
||||
$rawDate = $_SERVER['RTT_START_DATE'] ?? $_ENV['RTT_START_DATE'] ?? '';
|
||||
$resolver = new EmployeeContractPhaseResolver(is_string($rawDate) ? $rawDate : '');
|
||||
|
||||
return array_map(
|
||||
static fn (ContractPhase $phase): array => [
|
||||
|
||||
@@ -12,6 +12,21 @@ use LogicException;
|
||||
|
||||
final readonly class EmployeeContractPhaseResolver
|
||||
{
|
||||
private ?DateTimeImmutable $dataStartDate;
|
||||
|
||||
public function __construct(string $dataStartDate = '')
|
||||
{
|
||||
$trimmed = trim($dataStartDate);
|
||||
if ('' === $trimmed) {
|
||||
$this->dataStartDate = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$parsed = DateTimeImmutable::createFromFormat('!Y-m-d', $trimmed);
|
||||
$this->dataStartDate = $parsed instanceof DateTimeImmutable ? $parsed : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<ContractPhase>
|
||||
*/
|
||||
@@ -42,6 +57,17 @@ final readonly class EmployeeContractPhaseResolver
|
||||
$phases[] = $this->buildPhase($group, $today);
|
||||
}
|
||||
|
||||
// Hide phases entirely before the application's data start date: no usable
|
||||
// work-hour or absence data exists before that date, so exposing them would
|
||||
// confuse HR (e.g. legacy contract periods predating the software launch).
|
||||
if (null !== $this->dataStartDate) {
|
||||
$dataStart = $this->dataStartDate;
|
||||
$phases = array_values(array_filter(
|
||||
$phases,
|
||||
static fn (ContractPhase $phase): bool => null === $phase->endDate || $phase->endDate >= $dataStart,
|
||||
));
|
||||
}
|
||||
|
||||
// Most recent first.
|
||||
return array_reverse($phases);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user