diff --git a/frontend/composables/useEmployeeDetailPage.ts b/frontend/composables/useEmployeeDetailPage.ts index 05ec0b6..584e2b8 100644 --- a/frontend/composables/useEmployeeDetailPage.ts +++ b/frontend/composables/useEmployeeDetailPage.ts @@ -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(null) const isLoading = ref(false) const activeTab = ref<'contract' | 'leave' | 'rtt' | 'mileage' | 'formation' | 'bonus' | 'observation'>('contract') + const overtimeContingent = ref(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 `Contingent ${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, diff --git a/frontend/pages/employees/[id].vue b/frontend/pages/employees/[id].vue index 6d6b993..573fd8d 100644 --- a/frontend/pages/employees/[id].vue +++ b/frontend/pages/employees/[id].vue @@ -28,6 +28,11 @@

{{ contractNatureLabel(employee.currentContractNature) }} {{ employeeContractWorkLabel }}{{ forfaitRemainingDaysLabel }}{{ nonForfaitPresenceLabel }}

{{ employee.site?.name ?? '-' }}

+

{{ overtimeContingentLabel }}

@@ -300,6 +305,8 @@ const { employeeContractWorkLabel, forfaitRemainingDaysLabel, nonForfaitPresenceLabel, + overtimeContingentLabel, + overtimeContingentExceeded, contractForm, createContractForm, isContractDrawerOpen, diff --git a/frontend/services/employee-overtime-contingent.ts b/frontend/services/employee-overtime-contingent.ts new file mode 100644 index 0000000..628deac --- /dev/null +++ b/frontend/services/employee-overtime-contingent.ts @@ -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 = {} + if (year) query.year = year + return api.get(`/employees/${employeeId}/overtime-contingent`, query, { toast: false }) +}