feat(overtime-contingent) : contingent d'heures supplémentaires payées (#29)
Auto Tag Develop / tag (push) Successful in 7s

## Résumé
Suivi par **année civile** (Janv–Déc) des heures supplémentaires payées des employés non-forfait (chauffeurs inclus) face au plafond légal (**350 h** chauffeurs / **220 h** autres).

- **Fiche employé** : encart header `Total H.payés {année} : X h / plafond h` (année civile courante, rouge si dépassement), via `GET /employees/{id}/overtime-contingent`.
- **Export PDF** `GET /overtime-contingent/print?year=&siteIds=` (ROLE_USER, périmètre `findScoped`) : groupé par site, colonnes Janv–Déc + colonne `Total payé / payable`. Drawer liste employés (année + sites).
- Heures payées = `base25 + base50` (hors majoration). Mapping exercice→civil : `mois ≥ 6 ? exercice−1 : exercice`.
- Cœur partagé pur `OvertimePaidContingentCalculator`.
- Ajout « Année civile » dans le titre des deux exports PDF (contingent H.supp. et heures de nuit).

## Tests
- 214 tests PHPUnit verts (calculateur : mapping civil, base-only, plafond ; builder : ventilation mensuelle, ligne à zéro).

## Hors périmètre (consigné)
- Bug latent `SalaryRecapPrintProvider` : rattachement des paiements RTT des mois Juin–Déc par année civile sur un stockage par exercice. À traiter séparément.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Reviewed-on: #29
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #29.
This commit is contained in:
2026-06-11 15:47:19 +00:00
committed by Autin
parent ceba1121f0
commit 327c10fda4
21 changed files with 2148 additions and 5 deletions
@@ -2,12 +2,14 @@ import type { Employee } from '~/services/dto/employee'
import { CONTRACT_TYPES } from '~/services/dto/contract'
import { getEmployee } from '~/services/employees'
import { useEmployeeContractPhase } from '~/composables/useEmployeeContractPhase'
import { getEmployeeOvertimeContingent, type OvertimeContingent } from '~/services/employee-overtime-contingent'
export const useEmployeeDetailPage = () => {
const route = useRoute()
const employee = ref<Employee | null>(null)
const isLoading = ref(false)
const activeTab = ref<'contract' | 'leave' | 'rtt' | 'mileage' | 'formation' | 'bonus' | 'observation'>('contract')
const overtimeContingent = ref<OvertimeContingent | null>(null)
const phase = useEmployeeContractPhase(employee)
@@ -28,6 +30,18 @@ export const useEmployeeDetailPage = () => {
return contract.name || '-'
})
const loadOvertimeContingent = async () => {
if (!employee.value || !showRttTab.value) {
overtimeContingent.value = null
return
}
try {
overtimeContingent.value = await getEmployeeOvertimeContingent(employee.value.id)
} catch {
overtimeContingent.value = null
}
}
const loadEmployee = async () => {
const idParam = Array.isArray(route.params.id) ? route.params.id[0] : route.params.id
const employeeId = Number(idParam)
@@ -71,6 +85,7 @@ export const useEmployeeDetailPage = () => {
// qui proviennent du récap congés — nécessaire même quand on ouvre un autre onglet.
await leave.loadLeaveData()
}
await loadOvertimeContingent()
} finally {
isLoading.value = false
}
@@ -94,6 +109,18 @@ export const useEmployeeDetailPage = () => {
if (presence === undefined || presence === null) return ''
return ` (${formatDays(presence)} présence)`
})
const overtimeContingentLabel = computed(() => {
if (!showRttTab.value) return ''
const c = overtimeContingent.value
if (!c) return ''
const h = c.paidMinutes / 60
const hStr = Number.isInteger(h) ? String(h) : (Math.round(h * 10) / 10).toFixed(1).replace('.', ',')
return `Total H.payés ${c.year} : ${hStr} h / ${c.capHours} h`
})
const overtimeContingentExceeded = computed(() => {
const c = overtimeContingent.value
return c ? c.paidMinutes > c.capHours * 60 : false
})
const rtt = useEmployeeRtt(employee, loadEmployee, phase.selectedPhase)
const mileage = useEmployeeMileage(employee, loadEmployee)
const formation = useEmployeeFormation(employee, loadEmployee)
@@ -147,6 +174,8 @@ export const useEmployeeDetailPage = () => {
employeeContractWorkLabel,
forfaitRemainingDaysLabel,
nonForfaitPresenceLabel,
overtimeContingentLabel,
overtimeContingentExceeded,
...phase,
...contract,
...leave,
+12
View File
@@ -643,6 +643,18 @@ export const documentationSections: DocSection[] = [
{ type: 'note', content: 'Export « Contingent H.nuit » : depuis la liste des employés, bouton Export → « Contingent H.nuit » + année. Génère un PDF A4 paysage avec une ligne par employé (groupés par site) et une colonne par mois, chacune avec le total d\'heures de nuit (travail entre 21h et 6h) et le nombre de nuits (jours où au moins 4h ont été travaillées de nuit). Les conducteurs utilisent leurs heures de nuit saisies.' },
],
},
{
id: 'contingent-heures-supp',
title: 'Export Contingent H.supp.',
requiredLevel: 'admin',
blocks: [
{ type: 'paragraph', content: 'L\'encart « Total H.payés {année} : X h / plafond h », affiché dans l\'en-tête de la fiche d\'un employé non-forfait, indique le total d\'heures supplémentaires payées sur l\'année civile en cours face au plafond légal. Il passe en rouge si ce plafond est dépassé.' },
{ type: 'list', content: 'Plafond chauffeur (contrat courant « conducteur ») : 350 h\nPlafond autres salariés non-forfait : 220 h\nSeuls les employés non-forfait disposent de cet encart (FORFAIT exclus)' },
{ type: 'paragraph', content: 'L\'export PDF « Contingent H.supp. » est accessible depuis la liste des employés, via le bouton Export → option « Contingent H.supp. ». Choisissez l\'année civile (par défaut l\'année courante) et éventuellement des sites ; sans sélection de site, tous les sites de votre périmètre sont inclus.' },
{ type: 'list', content: 'PDF A4 paysage, une ligne par employé non-forfait, groupé par site\nTri : ordre d\'affichage du site, puis nom, puis prénom\nColonnes : Janv à Déc (heures payées par mois) + colonne « Total payé / payable »\nLes employés FORFAIT n\'apparaissent pas dans cet export' },
{ type: 'note', content: 'Les heures prises en compte sont les bases payées (25 % et 50 % confondus), hors majorations. Le contingent est calculé sur l\'année civile (janvierdécembre), indépendamment de l\'exercice RTT (juinmai) : un paiement RTT saisi pour le mois de juin est rattaché à l\'année civile précédente.' },
],
},
{
id: 'impression-absences',
title: 'Impression absences',
+7
View File
@@ -28,6 +28,11 @@
<div class="text-right">
<p class="font-bold text-[22px]">{{ contractNatureLabel(employee.currentContractNature) }} {{ employeeContractWorkLabel }}{{ forfaitRemainingDaysLabel }}{{ nonForfaitPresenceLabel }}</p>
<p class="text-[18px]">{{ employee.site?.name ?? '-' }}</p>
<p
v-if="overtimeContingentLabel"
class="text-[16px] font-semibold"
:class="overtimeContingentExceeded ? 'text-red-600' : ''"
>{{ overtimeContingentLabel }}</p>
</div>
</div>
<div v-if="showPicker" class="mt-3 flex items-center gap-3">
@@ -300,6 +305,8 @@ const {
employeeContractWorkLabel,
forfaitRemainingDaysLabel,
nonForfaitPresenceLabel,
overtimeContingentLabel,
overtimeContingentExceeded,
contractForm,
createContractForm,
isContractDrawerOpen,
+28 -3
View File
@@ -240,6 +240,22 @@
/>
</div>
<div v-else-if="exportChoice === 'overtime-contingent'" class="flex flex-col gap-4">
<MalioSelect
:model-value="exportYear"
:options="exportYearOptions"
label="Année *"
min-width=""
@update:model-value="(v) => { if (v !== null) exportYear = Number(v) }"
/>
<MalioSelectCheckbox
v-model="exportSiteIds"
:options="siteOptions"
label="Sites"
min-width=""
/>
</div>
<div class="flex justify-center pt-2">
<MalioButton
label="Valider"
@@ -274,16 +290,18 @@ const isDrawerOpen = ref(false)
const isSubmitting = ref(false)
const isLoading = ref(false)
const isExportDrawerOpen = ref(false)
const exportChoice = ref<'leave-recap' | 'salary-recap' | 'yearly-hours' | 'night-contingent' | ''>('')
const exportChoice = ref<'leave-recap' | 'salary-recap' | 'yearly-hours' | 'night-contingent' | 'overtime-contingent' | ''>('')
const exportYear = ref<number>(new Date().getFullYear())
const exportMonth = ref<number | ''>(new Date().getMonth() + 1)
const exportSalaryMonth = ref<string>(`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, '0')}`)
const exportSiteIds = ref<number[]>([])
const exportTypeOptions = [
{ label: 'Récap. congés', value: 'leave-recap' },
{ label: 'Récap. salaire', value: 'salary-recap' },
{ label: 'Heures annuelles', value: 'yearly-hours' },
{ label: 'Contingent H.nuit', value: 'night-contingent' }
{ label: 'Contingent H.nuit', value: 'night-contingent' },
{ label: 'Contingent H.supp.', value: 'overtime-contingent' }
]
const exportYearOptions = computed(() => {
const current = new Date().getFullYear()
@@ -315,11 +333,14 @@ const isExportValid = computed(() => {
if (exportChoice.value === 'night-contingent') {
return exportYear.value > 0
}
if (exportChoice.value === 'overtime-contingent') {
return exportYear.value > 0
}
return true
})
const onExportChoiceChange = (value: string | number | null) => {
exportChoice.value = (value === null ? '' : String(value)) as 'leave-recap' | 'salary-recap' | 'yearly-hours' | 'night-contingent' | ''
exportChoice.value = (value === null ? '' : String(value)) as 'leave-recap' | 'salary-recap' | 'yearly-hours' | 'night-contingent' | 'overtime-contingent' | ''
}
const { printPdf } = usePdfPrinter()
const sitesInitialized = ref(false)
@@ -619,6 +640,7 @@ const openExportDrawer = () => {
exportYear.value = now.getFullYear()
exportMonth.value = now.getMonth() + 1
exportSalaryMonth.value = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`
exportSiteIds.value = []
isExportDrawerOpen.value = true
}
@@ -634,6 +656,9 @@ const handleExportValidate = async () => {
await printPdf(`/yearly-hours/print-all?year=${exportYear.value}&month=${exportMonth.value}`)
} else if (choice === 'night-contingent') {
await printPdf(`/night-hours-contingent/print?year=${exportYear.value}`)
} else if (choice === 'overtime-contingent') {
const siteParam = exportSiteIds.value.length > 0 ? `&siteIds=${exportSiteIds.value.join(',')}` : ''
await printPdf(`/overtime-contingent/print?year=${exportYear.value}${siteParam}`)
}
}
@@ -0,0 +1,13 @@
export interface OvertimeContingent {
year: number
paidMinutes: number
capHours: number
isDriver: boolean
}
export const getEmployeeOvertimeContingent = async (employeeId: number, year?: number) => {
const api = useApi()
const query: Record<string, number> = {}
if (year) query.year = year
return api.get<OvertimeContingent>(`/employees/${employeeId}/overtime-contingent`, query, { toast: false })
}