Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7dc9b6988 | ||
| b0de877b27 | |||
| 59f05717bf | |||
|
|
f96fd64767 | ||
| 523d4f296b | |||
|
|
3994be6556 | ||
| f46eeaa893 | |||
|
|
eb703272c7 | ||
| 6629eb98cb | |||
|
|
029bc03a5a | ||
| 82e575fff0 | |||
|
|
0213c0a97d | ||
| 12def35dda | |||
| 2d1c1e6e22 |
@@ -6,7 +6,8 @@
|
||||
"Bash(php:*)",
|
||||
"Bash(docker compose:*)",
|
||||
"Bash(make test:*)",
|
||||
"Bash(grep:*)"
|
||||
"Bash(grep:*)",
|
||||
"Bash(docker exec:*)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
parameters:
|
||||
app.version: '0.1.20'
|
||||
app.version: '0.1.26'
|
||||
|
||||
@@ -198,13 +198,16 @@ Tous les filtres checkbox sont cochés par défaut à l'ouverture du drawer.
|
||||
- lecture des compteurs:
|
||||
- `acquis` = droits reportés de l'exercice N-1 (après application des règles de soldé)
|
||||
- `en cours d'acquisition` = total droits générés sur l'exercice N (jours + samedis en cours), sans detail séparé en UI
|
||||
- `en cours d'acquisition` est arrêté au dernier jour du mois précédent
|
||||
- règle de consommation:
|
||||
- les absences s'imputent d'abord sur `acquis`, puis sur `en cours d'acquisition`
|
||||
- la prise sur `en cours d'acquisition` est autorisée (usage anticipé)
|
||||
- `en cours d'acquisition` peut devenir négatif si la prise dépasse le généré (ex: `2.08 - 3 = -0.92`), puis se reconstitue avec les acquisitions suivantes
|
||||
- date d'arret de calcul:
|
||||
- les compteurs sont calculés jusqu'au dernier jour du mois précédent (le mois en cours est exclu)
|
||||
- exemple: au `04/03/2026`, l'arret de calcul est le `28/02/2026` (ou `29/02` en année bissextile)
|
||||
- `reste à prendre` est calculé en prévisionnel jusqu'à la fin de l'exercice
|
||||
- les absences futures déjà posées sur l'exercice sont déduites du `reste à prendre`
|
||||
- `en cours d'acquisition` reste calculé jusqu'au dernier jour du mois précédent
|
||||
- exemple: au `11/03/2026`, l'exercice `2026` déduit les absences posées jusqu'au `31/05/2026`, mais l'acquisition reste arrêtée au `28/02/2026`
|
||||
- hors périmètre phase 1: `INTERIM` (retour non supporté)
|
||||
- onglet `RTT`:
|
||||
- endpoint de synthèse: `GET /api/employees/{id}/rtt-summary?year=YYYY`
|
||||
|
||||
@@ -162,9 +162,9 @@
|
||||
<input id="create-contract-start-date" v-model="createContractForm.startDate" type="date" :class="createContractStartDateFieldClass" />
|
||||
</div>
|
||||
|
||||
<div v-if="requiresCreateContractEndDate">
|
||||
<div v-if="showsCreateContractEndDate">
|
||||
<label class="text-md font-semibold text-neutral-700" for="create-contract-end-date">
|
||||
Fin contrat <span class="text-red-600">*</span>
|
||||
Fin contrat <span v-if="requiresCreateContractEndDate" class="text-red-600">*</span>
|
||||
</label>
|
||||
<input id="create-contract-end-date" v-model="createContractForm.endDate" type="date" :class="createContractEndDateFieldClass" />
|
||||
</div>
|
||||
@@ -235,6 +235,7 @@ defineProps<{
|
||||
createContractNatureFieldClass: string
|
||||
createContractFieldClass: string
|
||||
createContractStartDateFieldClass: string
|
||||
showsCreateContractEndDate: boolean
|
||||
requiresCreateContractEndDate: boolean
|
||||
createContractEndDateFieldClass: string
|
||||
isCreateContractFormValid: boolean
|
||||
|
||||
@@ -11,7 +11,7 @@ import { getEmployeeRttSummary, createRttPayment } from '~/services/employee-rtt
|
||||
import { getEmployee, updateEmployee } from '~/services/employees'
|
||||
import { listPublicHolidays } from '~/services/public-holidays'
|
||||
import { formatNullableYmdToFr, getTodayYmd, shiftYmd } from '~/utils/date'
|
||||
import { contractNatureLabel, isContractNature, requiresContractEndDate } from '~/utils/contract'
|
||||
import { contractNatureLabel, isContractNature, requiresContractEndDate, showsContractEndDate } from '~/utils/contract'
|
||||
|
||||
export const useEmployeeDetailPage = () => {
|
||||
const route = useRoute()
|
||||
@@ -99,6 +99,7 @@ export const useEmployeeDetailPage = () => {
|
||||
const isContractEndDateValid = computed(() => contractForm.endDate !== '')
|
||||
const showContractEndDateError = computed(() => validationTouched.endDate && !isContractEndDateValid.value)
|
||||
|
||||
const showsCreateContractEndDate = computed(() => showsContractEndDate(createContractForm.contractNature))
|
||||
const requiresCreateContractEndDate = computed(() => requiresContractEndDate(createContractForm.contractNature))
|
||||
const isCreateContractValid = computed(() => createContractForm.contractId !== '')
|
||||
const isCreateContractNatureValid = computed(() => isContractNature(createContractForm.contractNature))
|
||||
@@ -314,8 +315,8 @@ export const useEmployeeDetailPage = () => {
|
||||
await loadEmployee()
|
||||
}
|
||||
|
||||
watch(requiresCreateContractEndDate, (required) => {
|
||||
if (!required) {
|
||||
watch(showsCreateContractEndDate, (shows) => {
|
||||
if (!shows) {
|
||||
createContractForm.endDate = ''
|
||||
}
|
||||
})
|
||||
@@ -353,6 +354,7 @@ export const useEmployeeDetailPage = () => {
|
||||
createContractNatureFieldClass,
|
||||
createContractFieldClass,
|
||||
createContractStartDateFieldClass,
|
||||
showsCreateContractEndDate,
|
||||
requiresCreateContractEndDate,
|
||||
createContractEndDateFieldClass,
|
||||
isCreateContractFormValid,
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
:create-contract-nature-field-class="createContractNatureFieldClass"
|
||||
:create-contract-field-class="createContractFieldClass"
|
||||
:create-contract-start-date-field-class="createContractStartDateFieldClass"
|
||||
:shows-create-contract-end-date="showsCreateContractEndDate"
|
||||
:requires-create-contract-end-date="requiresCreateContractEndDate"
|
||||
:create-contract-end-date-field-class="createContractEndDateFieldClass"
|
||||
:is-create-contract-form-valid="isCreateContractFormValid"
|
||||
@@ -131,6 +132,7 @@ const {
|
||||
createContractNatureFieldClass,
|
||||
createContractFieldClass,
|
||||
createContractStartDateFieldClass,
|
||||
showsCreateContractEndDate,
|
||||
requiresCreateContractEndDate,
|
||||
createContractEndDateFieldClass,
|
||||
isCreateContractFormValid,
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
La date de début est obligatoire.
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="requiresContractEndDateComputed">
|
||||
<div v-if="showsContractEndDateComputed">
|
||||
<label class="text-md font-semibold text-neutral-700" for="contract-end-date">
|
||||
Fin contrat
|
||||
<span v-if="requiresContractEndDateComputed" class="text-red-600">*</span>
|
||||
@@ -166,7 +166,7 @@
|
||||
:class="contractEndDateFieldClass"
|
||||
/>
|
||||
<p v-if="showContractEndDateError" class="mt-1 text-sm text-red-600">
|
||||
La date de fin est obligatoire pour un CDD ou un intérim.
|
||||
La date de fin est obligatoire pour un CDD.
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -199,7 +199,7 @@ import {listContracts} from '~/services/contracts'
|
||||
import {createEmployee, deleteEmployee, listEmployees, updateEmployee} from '~/services/employees'
|
||||
import {listSites} from '~/services/sites'
|
||||
import SiteFilterSelector from '~/components/SiteFilterSelector.vue'
|
||||
import {contractNatureLabel, isContractNature, requiresContractEndDate} from '~/utils/contract'
|
||||
import {contractNatureLabel, isContractNature, requiresContractEndDate, showsContractEndDate} from '~/utils/contract'
|
||||
|
||||
useHead({
|
||||
title: 'Employés'
|
||||
@@ -264,6 +264,7 @@ const isSiteValid = computed(() => form.siteId !== '')
|
||||
const isContractValid = computed(() => form.contractId !== '')
|
||||
const isContractNatureValid = computed(() => isContractNature(form.contractNature))
|
||||
const isContractStartDateValid = computed(() => form.contractStartDate !== '')
|
||||
const showsContractEndDateComputed = computed(() => showsContractEndDate(form.contractNature))
|
||||
const requiresContractEndDateComputed = computed(() => requiresContractEndDate(form.contractNature))
|
||||
const isContractEndDateValid = computed(() => {
|
||||
if (!requiresContractEndDateComputed.value) return true
|
||||
@@ -429,7 +430,7 @@ const handleSubmit = async () => {
|
||||
contractId: Number(form.contractId),
|
||||
contractNature: form.contractNature,
|
||||
contractStartDate: form.contractStartDate,
|
||||
contractEndDate: requiresContractEndDateComputed.value ? form.contractEndDate : null
|
||||
contractEndDate: form.contractEndDate || null
|
||||
})
|
||||
}
|
||||
|
||||
@@ -460,8 +461,8 @@ watch(isDrawerOpen, (isOpen) => {
|
||||
}
|
||||
})
|
||||
|
||||
watch(requiresContractEndDateComputed, (required) => {
|
||||
if (!required) {
|
||||
watch(showsContractEndDateComputed, (shows) => {
|
||||
if (!shows) {
|
||||
form.contractEndDate = ''
|
||||
}
|
||||
})
|
||||
|
||||
@@ -8,10 +8,14 @@ export const contractNatureLabel = (value?: ContractNature) => {
|
||||
return 'CDI'
|
||||
}
|
||||
|
||||
export const requiresContractEndDate = (nature: ContractNature) => {
|
||||
export const showsContractEndDate = (nature: ContractNature) => {
|
||||
return nature === 'CDD' || nature === 'INTERIM'
|
||||
}
|
||||
|
||||
export const requiresContractEndDate = (nature: ContractNature) => {
|
||||
return nature === 'CDD'
|
||||
}
|
||||
|
||||
export const isContractNature = (value: string): value is ContractNature => {
|
||||
return (CONTRACT_NATURES as readonly string[]).includes(value)
|
||||
}
|
||||
|
||||
@@ -349,14 +349,25 @@ final readonly class LeaveBalanceComputationService
|
||||
}
|
||||
|
||||
for ($cursor = $rangeStart; $cursor <= $rangeEnd; $cursor = $cursor->modify('+1 day')) {
|
||||
$dayOfWeek = (int) $cursor->format('N');
|
||||
|
||||
if ($splitSaturdays) {
|
||||
if (7 === $dayOfWeek) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if ($dayOfWeek >= 6) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
[$am, $pm] = $this->resolveSegmentsForDate($absence, $cursor->format('Y-m-d'));
|
||||
$dayAmount = ($am ? 0.5 : 0.0) + ($pm ? 0.5 : 0.0);
|
||||
if ($dayAmount <= 0.0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$isSaturday = $splitSaturdays && '6' === $cursor->format('N');
|
||||
if ($isSaturday) {
|
||||
if ($splitSaturdays && 6 === $dayOfWeek) {
|
||||
$takenSaturdays += $dayAmount;
|
||||
} else {
|
||||
$takenDays += $dayAmount;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -163,18 +163,19 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
|
||||
|
||||
$effectiveFrom = $this->resolveEffectivePeriodStart($employee, $from, $to);
|
||||
$hasShiftedStart = $effectiveFrom > $from;
|
||||
if ($hasShiftedStart) {
|
||||
if ($hasShiftedStart && null === $openingBalance) {
|
||||
$carryDays = 0.0;
|
||||
$carrySaturdays = 0.0;
|
||||
}
|
||||
|
||||
$calculationEnd = $this->resolveCalculationEndDate($leavePolicy['ruleCode'], $year, $to);
|
||||
$generatedDays = $leavePolicy['accrualPerMonth'] > 0.0
|
||||
$accrualCalculationEnd = $this->resolveAccrualCalculationEndDate($leavePolicy['ruleCode'], $year, $to, $employee);
|
||||
$takenCalculationEnd = $this->resolveTakenCalculationEndDate($to, $employee);
|
||||
$generatedDays = $leavePolicy['accrualPerMonth'] > 0.0
|
||||
? $this->computeAccruedDaysFromStart(
|
||||
$leavePolicy['acquiredDays'],
|
||||
$leavePolicy['accrualPerMonth'],
|
||||
$effectiveFrom,
|
||||
$calculationEnd
|
||||
$accrualCalculationEnd
|
||||
)
|
||||
: 0.0;
|
||||
$generatedSaturdays = $leavePolicy['saturdayAccrualPerMonth'] > 0.0
|
||||
@@ -182,14 +183,14 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
|
||||
$leavePolicy['acquiredSaturdays'],
|
||||
$leavePolicy['saturdayAccrualPerMonth'],
|
||||
$effectiveFrom,
|
||||
$calculationEnd
|
||||
$accrualCalculationEnd
|
||||
)
|
||||
: 0.0;
|
||||
$absences = $this->absenceRepository->findByEmployeeAndOverlappingDateRange($employee, $from, $to);
|
||||
[$takenDays, $takenSaturdays] = $this->computeTakenAbsences(
|
||||
$absences,
|
||||
$effectiveFrom,
|
||||
$calculationEnd,
|
||||
$takenCalculationEnd,
|
||||
$leavePolicy['countOnlyCp'],
|
||||
$leavePolicy['splitSaturdays']
|
||||
);
|
||||
@@ -353,10 +354,11 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
|
||||
return min($acquiredDays, $monthsElapsed * $accrualPerMonth);
|
||||
}
|
||||
|
||||
private function resolveCalculationEndDate(
|
||||
private function resolveAccrualCalculationEndDate(
|
||||
string $ruleCode,
|
||||
int $year,
|
||||
DateTimeImmutable $periodEnd
|
||||
DateTimeImmutable $periodEnd,
|
||||
Employee $employee
|
||||
): ?DateTimeImmutable {
|
||||
$today = new DateTimeImmutable('today');
|
||||
$currentYear = LeaveRuleCode::FORFAIT_218->value === $ruleCode
|
||||
@@ -364,18 +366,45 @@ 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;
|
||||
}
|
||||
|
||||
private function resolveTakenCalculationEndDate(
|
||||
DateTimeImmutable $periodEnd,
|
||||
Employee $employee
|
||||
): ?DateTimeImmutable {
|
||||
$end = $periodEnd;
|
||||
|
||||
// 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 $end;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -622,14 +651,27 @@ final readonly class EmployeeLeaveSummaryProvider implements ProviderInterface
|
||||
}
|
||||
|
||||
for ($cursor = $rangeStart; $cursor <= $rangeEnd; $cursor = $cursor->modify('+1 day')) {
|
||||
$dayOfWeek = (int) $cursor->format('N');
|
||||
|
||||
if ($splitSaturdays) {
|
||||
// Mode CDI/CDD : dimanche ignoré, samedi compté séparément.
|
||||
if (7 === $dayOfWeek) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// Mode forfait : seuls les jours ouvrés (lun-ven) comptent.
|
||||
if ($dayOfWeek >= 6) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
[$am, $pm] = $this->resolveSegmentsForDate($absence, $cursor->format('Y-m-d'));
|
||||
$dayAmount = ($am ? 0.5 : 0.0) + ($pm ? 0.5 : 0.0);
|
||||
if ($dayAmount <= 0.0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$isSaturday = $splitSaturdays && '6' === $cursor->format('N');
|
||||
if ($isSaturday && $splitSaturdays) {
|
||||
if ($splitSaturdays && 6 === $dayOfWeek) {
|
||||
$takenSaturdays += $dayAmount;
|
||||
} else {
|
||||
$takenDays += $dayAmount;
|
||||
|
||||
Reference in New Issue
Block a user