Compare commits

..

3 Commits

Author SHA1 Message Date
gitea-actions
0213c0a97d chore: bump version to v0.1.21
All checks were successful
Auto Tag Develop / tag (push) Successful in 4s
Build Release Artefact / build (push) Successful in 1m11s
2026-03-11 07:50:38 +00:00
12def35dda Merge remote-tracking branch 'origin/develop' into develop
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
2026-03-11 08:50:23 +01:00
2d1c1e6e22 fix : api jour férié qui a changé d'url 2026-03-11 08:42:57 +01:00
5 changed files with 33 additions and 19 deletions

View File

@@ -6,7 +6,8 @@
"Bash(php:*)",
"Bash(docker compose:*)",
"Bash(make test:*)",
"Bash(grep:*)"
"Bash(grep:*)",
"Bash(docker exec:*)"
]
}
}

View File

@@ -22,6 +22,10 @@ services:
App\:
resource: '../src/'
App\Service\PublicHolidayService:
arguments:
$holidayUrl: '%env(HOLIDAY_URL)%'
App\Repository\Contract\AbsenceReadRepositoryInterface: '@App\Repository\AbsenceRepository'
App\Repository\Contract\EmployeeContractPeriodReadRepositoryInterface: '@App\Repository\EmployeeContractPeriodRepository'
App\Repository\Contract\EmployeeScopedRepositoryInterface: '@App\Repository\EmployeeRepository'

View File

@@ -1,2 +1,2 @@
parameters:
app.version: '0.1.20'
app.version: '0.1.21'

View File

@@ -13,12 +13,11 @@ use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Throwable;
final class PublicHolidayService implements PublicHolidayServiceInterface
final readonly class PublicHolidayService implements PublicHolidayServiceInterface
{
private const string BASE_URL = 'https://calendrier.api.gouv.fr/jours-feries/';
public function __construct(
private readonly HttpClientInterface $client,
private HttpClientInterface $client,
private string $holidayUrl
) {}
/**
@@ -31,7 +30,7 @@ final class PublicHolidayService implements PublicHolidayServiceInterface
public function getHolidaysDay(string $zone): array
{
$zone = strtolower(trim($zone));
$url = self::BASE_URL."{$zone}.json";
$url = $this->holidayUrl."{$zone}.json";
try {
$response = $this->client->request(
@@ -61,7 +60,7 @@ final class PublicHolidayService implements PublicHolidayServiceInterface
{
$zone = strtolower(trim($zone));
$years = trim($years);
$url = self::BASE_URL."{$zone}/{$years}.json";
$url = $this->holidayUrl."{$zone}/{$years}.json";
try {
$response = $this->client->request('GET', $url);

View File

@@ -168,7 +168,7 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
$carrySaturdays = 0.0;
}
$calculationEnd = $this->resolveCalculationEndDate($leavePolicy['ruleCode'], $year, $to);
$calculationEnd = $this->resolveCalculationEndDate($leavePolicy['ruleCode'], $year, $to, $employee);
$generatedDays = $leavePolicy['accrualPerMonth'] > 0.0
? $this->computeAccruedDaysFromStart(
$leavePolicy['acquiredDays'],
@@ -356,7 +356,8 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
private function resolveCalculationEndDate(
string $ruleCode,
int $year,
DateTimeImmutable $periodEnd
DateTimeImmutable $periodEnd,
Employee $employee
): ?DateTimeImmutable {
$today = new DateTimeImmutable('today');
$currentYear = LeaveRuleCode::FORFAIT_218->value === $ruleCode
@@ -364,18 +365,27 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
: $this->resolveCurrentLeaveYear($today);
if ($year < $currentYear) {
return $periodEnd;
}
if ($year > $currentYear) {
return null;
$end = $periodEnd;
} elseif ($year > $currentYear) {
$end = null;
} else {
$lastDayPreviousMonth = $today
->modify('first day of this month')
->modify('-1 day')
;
$end = $lastDayPreviousMonth < $periodEnd ? $lastDayPreviousMonth : $periodEnd;
}
$lastDayPreviousMonth = $today
->modify('first day of this month')
->modify('-1 day')
;
// Cap at contract end date if the employee has left.
$contractEndRaw = $employee->getCurrentContractEndDate();
if (null !== $end && null !== $contractEndRaw && '' !== trim($contractEndRaw)) {
$contractEnd = DateTimeImmutable::createFromFormat('Y-m-d', $contractEndRaw);
if ($contractEnd instanceof DateTimeImmutable && $contractEnd < $end) {
$end = $contractEnd;
}
}
return $lastDayPreviousMonth < $periodEnd ? $lastDayPreviousMonth : $periodEnd;
return $end;
}
/**