Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a17d6a67cf | ||
| 29db3b5025 | |||
|
|
6df9110187 | ||
| f0dfb30566 | |||
| 049e64288e | |||
|
|
9577a70ea3 | ||
| e85f7b6f4c | |||
|
|
834b4cb695 | ||
| 17f871e82d |
@@ -43,9 +43,15 @@
|
|||||||
## Overtime Rules
|
## Overtime Rules
|
||||||
- Contracts <= 35h: +25% from 35h to 43h, +50% beyond
|
- Contracts <= 35h: +25% from 35h to 43h, +50% beyond
|
||||||
- Contracts >= 39h: +25% from 39h to 43h, +50% beyond
|
- Contracts >= 39h: +25% from 39h to 43h, +50% beyond
|
||||||
|
- CUSTOM contracts (weeklyHours ≠ 35 and ≠ 39, not INTERIM/FORFAIT): reference = actual contractual hours, no 25%/50% bonuses (1h overtime = 1h recovery), deficit doesn't impact balance
|
||||||
- INTERIM: no overtime bonuses, no recovery time
|
- INTERIM: no overtime bonuses, no recovery time
|
||||||
- Driver contracts: no overtime calculation
|
- Driver contracts: no overtime calculation
|
||||||
|
|
||||||
|
## Frais (MileageAllowance)
|
||||||
|
- Onglet "Frais" (anciennement "Frais Kms") sur la fiche employé
|
||||||
|
- Validation: mois obligatoire + au moins `kilometers > 0` ou `amount > 0`
|
||||||
|
- Les deux champs km et montant sont optionnels individuellement mais au moins un requis
|
||||||
|
|
||||||
## Frontend Patterns
|
## Frontend Patterns
|
||||||
|
|
||||||
### Table styling (standard across all pages)
|
### Table styling (standard across all pages)
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
parameters:
|
parameters:
|
||||||
app.version: '0.1.55'
|
app.version: '0.1.59'
|
||||||
|
|||||||
@@ -122,6 +122,10 @@ Documents complementaires:
|
|||||||
- Semaine en déficit (heures travaillées < heures contrat):
|
- Semaine en déficit (heures travaillées < heures contrat):
|
||||||
- le déficit est déduit du cumul RTT : d'abord des heures à 50%, puis des heures à 25%
|
- le déficit est déduit du cumul RTT : d'abord des heures à 50%, puis des heures à 25%
|
||||||
- si aucun solde 50% ni 25%, les heures à 25% deviennent négatives
|
- si aucun solde 50% ni 25%, les heures à 25% deviennent négatives
|
||||||
|
- Contrats CUSTOM (heures hebdo ≠ 35h et ≠ 39h, hors INTERIM/FORFAIT):
|
||||||
|
- référence heures sup = heures contractuelles réelles (ex: 4h → référence 4h)
|
||||||
|
- pas de bonus 25% ni 50% : 1 heure sup = 1 heure de récupération
|
||||||
|
- le déficit (travail < contrat) ne génère pas de récup mais n'impacte pas le solde
|
||||||
- Nature `INTERIM`:
|
- Nature `INTERIM`:
|
||||||
- pas de bonus 25%
|
- pas de bonus 25%
|
||||||
- pas de bonus 50%
|
- pas de bonus 50%
|
||||||
@@ -274,6 +278,7 @@ Tous les filtres checkbox sont cochés par défaut à l'ouverture du drawer.
|
|||||||
- base identique aux calculs d'heures supplémentaires de la vue semaine Heures
|
- base identique aux calculs d'heures supplémentaires de la vue semaine Heures
|
||||||
- minutes de récupération hebdomadaires = `HS totales + bonus 25% + bonus 50%`
|
- minutes de récupération hebdomadaires = `HS totales + bonus 25% + bonus 50%`
|
||||||
- contrats `INTERIM` et suivi `PRESENCE`: récupération à `0`
|
- contrats `INTERIM` et suivi `PRESENCE`: récupération à `0`
|
||||||
|
- date limite de calcul: uniquement les semaines terminées (jusqu'au dernier dimanche), **ou** la semaine en cours si tous les jours existants sont validés RH (`isValid = true`). En cas de fin de contrat en milieu de semaine, seuls les jours jusqu'à la date de fin sont vérifiés.
|
||||||
- compteur global:
|
- compteur global:
|
||||||
- affiché en **jours** (1 jour = 7h = 420 minutes)
|
- affiché en **jours** (1 jour = 7h = 420 minutes)
|
||||||
- report:
|
- report:
|
||||||
@@ -353,13 +358,17 @@ Tous les filtres checkbox sont cochés par défaut à l'ouverture du drawer.
|
|||||||
- `kilometers` (nombre de km, optionnel)
|
- `kilometers` (nombre de km, optionnel)
|
||||||
- `amount` (montant en €, optionnel)
|
- `amount` (montant en €, optionnel)
|
||||||
- `comment` (commentaire, optionnel)
|
- `comment` (commentaire, optionnel)
|
||||||
- `receiptPath` / `receiptName` (justificatif PDF)
|
- `receiptPath` / `receiptName` (justificatif Km, PDF)
|
||||||
|
- `amountReceiptPath` / `amountReceiptName` (justificatif Montant, PDF)
|
||||||
- Règle de validation:
|
- Règle de validation:
|
||||||
- le mois est obligatoire
|
- le mois est obligatoire
|
||||||
- au moins un des deux champs `kilometers` ou `amount` doit être > 0
|
- au moins un des deux champs `kilometers` ou `amount` doit être > 0
|
||||||
- les deux peuvent être remplis simultanément
|
- les deux peuvent être remplis simultanément
|
||||||
- Tableau: colonnes Mois, Nombre de Km, Montant €, Commentaire, Justificatif
|
- Tableau: colonnes Mois, Nombre de Km, Montant €, Commentaire, Justif. Km, Justif. Montant
|
||||||
- Justificatif: upload PDF uniquement, téléchargement via endpoint dédié
|
- Deux justificatifs distincts (upload PDF uniquement):
|
||||||
|
- Justificatif Km : upload via `/mileage_allowances/{id}/receipt`, téléchargement via GET même URL
|
||||||
|
- Justificatif Montant : upload via `/mileage_allowances/{id}/amount-receipt`, téléchargement via GET même URL
|
||||||
|
- La suppression d'un frais supprime les deux fichiers justificatifs du disque
|
||||||
|
|
||||||
## 13) Notifications
|
## 13) Notifications
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
<section class="mt-8">
|
<section class="mt-8">
|
||||||
<div class="overflow-hidden bg-white">
|
<div class="overflow-hidden bg-white">
|
||||||
<div
|
<div
|
||||||
class="grid grid-cols-5 border border-black bg-tertiary-500 px-6 py-3 text-[20px] font-semibold text-black rounded-t-md">
|
class="grid grid-cols-6 border border-black bg-tertiary-500 px-6 py-3 text-[20px] font-semibold text-black rounded-t-md">
|
||||||
<p>Mois</p>
|
<p>Mois</p>
|
||||||
<p>Nombre de Km</p>
|
<p>Nombre de Km</p>
|
||||||
<p>Montant €</p>
|
<p>Montant €</p>
|
||||||
<p>Commentaire</p>
|
<p>Commentaire</p>
|
||||||
<p>Justificatif</p>
|
<p>Justif. Km</p>
|
||||||
|
<p>Justif. Montant</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="allowances.length === 0" class="px-6 py-4 text-[20px] font-bold text-primary-500 border-x border-b border-primary-500 rounded-b-md">
|
<div v-if="allowances.length === 0" class="px-6 py-4 text-[20px] font-bold text-primary-500 border-x border-b border-primary-500 rounded-b-md">
|
||||||
Aucun frais kilométrique.
|
Aucun frais kilométrique.
|
||||||
@@ -16,23 +17,36 @@
|
|||||||
<div
|
<div
|
||||||
v-for="item in allowances"
|
v-for="item in allowances"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="grid grid-cols-5 border-b border-primary-500 px-6 py-3 text-md font-bold text-primary-500 last:border-b-0 cursor-pointer hover:bg-tertiary-500"
|
class="grid grid-cols-6 border-b border-primary-500 px-6 py-3 text-md font-bold text-primary-500 last:border-b-0 cursor-pointer hover:bg-tertiary-500"
|
||||||
@click="onOpenEditDrawer(item)"
|
@click="onOpenEditDrawer(item)"
|
||||||
>
|
>
|
||||||
<p>{{ formatMonth(item.month) }}</p>
|
<p>{{ formatMonth(item.month) }}</p>
|
||||||
<p>{{ item.kilometers }}</p>
|
<p>{{ item.kilometers }}</p>
|
||||||
<p>{{ item.amount ? item.amount + ' €' : '-' }}</p>
|
<p>{{ item.amount ? item.amount + ' €' : '-' }}</p>
|
||||||
<p>{{ item.comment ?? '-' }}</p>
|
<p>{{ item.comment ?? '-' }}</p>
|
||||||
<p>
|
<p class="min-w-0">
|
||||||
<a
|
<a
|
||||||
v-if="item.receiptPath"
|
v-if="item.receiptPath"
|
||||||
:href="getReceiptUrl(props.apiBase, item.id)"
|
:href="getKmReceiptUrl(props.apiBase, item.id)"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="text-primary-500 hover:text-secondary-500 flex gap-2 items-center"
|
class="text-primary-500 hover:text-secondary-500 flex gap-2 items-center"
|
||||||
@click.stop
|
@click.stop
|
||||||
>
|
>
|
||||||
<Icon name="mdi:file-download-outline" size="20"/>
|
<Icon name="mdi:file-download-outline" size="20" class="shrink-0"/>
|
||||||
<span>{{ item.receiptName ?? 'Télécharger' }}</span>
|
<span class="truncate">{{ item.receiptName ?? 'Télécharger' }}</span>
|
||||||
|
</a>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</p>
|
||||||
|
<p class="min-w-0">
|
||||||
|
<a
|
||||||
|
v-if="item.amountReceiptPath"
|
||||||
|
:href="getAmountReceiptUrl(props.apiBase, item.id)"
|
||||||
|
target="_blank"
|
||||||
|
class="text-primary-500 hover:text-secondary-500 flex gap-2 items-center"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<Icon name="mdi:file-download-outline" size="20" class="shrink-0"/>
|
||||||
|
<span class="truncate">{{ item.amountReceiptName ?? 'Télécharger' }}</span>
|
||||||
</a>
|
</a>
|
||||||
<span v-else>-</span>
|
<span v-else>-</span>
|
||||||
</p>
|
</p>
|
||||||
@@ -94,20 +108,38 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="text-md font-semibold text-neutral-700" for="mileage-receipt">
|
<label class="text-md font-semibold text-neutral-700" for="mileage-km-receipt">
|
||||||
Justificatif
|
Justificatif Km
|
||||||
</label>
|
</label>
|
||||||
<div v-if="isEditing && editingItem?.receiptName" class="mt-1 text-sm text-neutral-500">
|
<div v-if="isEditing && editingItem?.receiptName" class="mt-1 text-sm text-neutral-500">
|
||||||
Fichier actuel : {{ editingItem.receiptName }}
|
Fichier actuel : {{ editingItem.receiptName }}
|
||||||
</div>
|
</div>
|
||||||
<input
|
<input
|
||||||
id="mileage-receipt"
|
id="mileage-km-receipt"
|
||||||
ref="fileInput"
|
ref="kmFileInput"
|
||||||
type="file"
|
type="file"
|
||||||
class="mt-2 w-full rounded-md border border-neutral-300 px-3 py-2 text-base text-neutral-900 file:mr-3 file:rounded file:border-0 file:bg-primary-500 file:px-3 file:py-1 file:text-sm file:text-white"
|
class="mt-2 w-full rounded-md border border-neutral-300 px-3 py-2 text-base text-neutral-900 file:mr-3 file:rounded file:border-0 file:bg-primary-500 file:px-3 file:py-1 file:text-sm file:text-white"
|
||||||
@change="onFileChange"
|
@change="onKmFileChange"
|
||||||
/>
|
/>
|
||||||
<p v-if="fileError" class="mt-1 text-sm text-red-600">{{ fileError }}</p>
|
<p v-if="kmFileError" class="mt-1 text-sm text-red-600">{{ kmFileError }}</p>
|
||||||
|
<p v-else class="mt-1 text-sm text-neutral-500">Fichier au format pdf</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="text-md font-semibold text-neutral-700" for="mileage-amount-receipt">
|
||||||
|
Justificatif Montant
|
||||||
|
</label>
|
||||||
|
<div v-if="isEditing && editingItem?.amountReceiptName" class="mt-1 text-sm text-neutral-500">
|
||||||
|
Fichier actuel : {{ editingItem.amountReceiptName }}
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
id="mileage-amount-receipt"
|
||||||
|
ref="amountFileInput"
|
||||||
|
type="file"
|
||||||
|
class="mt-2 w-full rounded-md border border-neutral-300 px-3 py-2 text-base text-neutral-900 file:mr-3 file:rounded file:border-0 file:bg-primary-500 file:px-3 file:py-1 file:text-sm file:text-white"
|
||||||
|
@change="onAmountFileChange"
|
||||||
|
/>
|
||||||
|
<p v-if="amountFileError" class="mt-1 text-sm text-red-600">{{ amountFileError }}</p>
|
||||||
<p v-else class="mt-1 text-sm text-neutral-500">Fichier au format pdf</p>
|
<p v-else class="mt-1 text-sm text-neutral-500">Fichier au format pdf</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -156,7 +188,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type {MileageAllowance} from '~/services/dto/mileage-allowance'
|
import type {MileageAllowance} from '~/services/dto/mileage-allowance'
|
||||||
import {getReceiptUrl} from '~/services/mileage-allowances'
|
import {getKmReceiptUrl, getAmountReceiptUrl} from '~/services/mileage-allowances'
|
||||||
import AppDrawer from '~/components/AppDrawer.vue'
|
import AppDrawer from '~/components/AppDrawer.vue'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -165,17 +197,20 @@ const props = defineProps<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: 'create', data: { month: string; kilometers: number; amount: number; comment?: string }, file?: File): void
|
(event: 'create', data: { month: string; kilometers: number; amount: number; comment?: string }, kmFile?: File, amountFile?: File): void
|
||||||
(event: 'update', id: number, data: { month: string; kilometers: number; amount: number; comment?: string }, file?: File): void
|
(event: 'update', id: number, data: { month: string; kilometers: number; amount: number; comment?: string }, kmFile?: File, amountFile?: File): void
|
||||||
(event: 'delete', id: number): void
|
(event: 'delete', id: number): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const isDrawerOpen = ref(false)
|
const isDrawerOpen = ref(false)
|
||||||
const isEditing = ref(false)
|
const isEditing = ref(false)
|
||||||
const editingItem = ref<MileageAllowance | null>(null)
|
const editingItem = ref<MileageAllowance | null>(null)
|
||||||
const selectedFile = ref<File | undefined>(undefined)
|
const selectedKmFile = ref<File | undefined>(undefined)
|
||||||
const fileInput = ref<HTMLInputElement | null>(null)
|
const selectedAmountFile = ref<File | undefined>(undefined)
|
||||||
const fileError = ref('')
|
const kmFileInput = ref<HTMLInputElement | null>(null)
|
||||||
|
const amountFileInput = ref<HTMLInputElement | null>(null)
|
||||||
|
const kmFileError = ref('')
|
||||||
|
const amountFileError = ref('')
|
||||||
|
|
||||||
const currentYearMonth = () => {
|
const currentYearMonth = () => {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
@@ -190,7 +225,7 @@ const form = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const isFormValid = computed(() => {
|
const isFormValid = computed(() => {
|
||||||
return form.month && (form.kilometers > 0 || form.amount > 0) && !fileError.value
|
return form.month && (form.kilometers > 0 || form.amount > 0) && !kmFileError.value && !amountFileError.value
|
||||||
})
|
})
|
||||||
|
|
||||||
const monthLabels: Record<number, string> = {
|
const monthLabels: Record<number, string> = {
|
||||||
@@ -221,10 +256,15 @@ const resetForm = () => {
|
|||||||
form.kilometers = 0
|
form.kilometers = 0
|
||||||
form.amount = 0
|
form.amount = 0
|
||||||
form.comment = ''
|
form.comment = ''
|
||||||
selectedFile.value = undefined
|
selectedKmFile.value = undefined
|
||||||
fileError.value = ''
|
selectedAmountFile.value = undefined
|
||||||
if (fileInput.value) {
|
kmFileError.value = ''
|
||||||
fileInput.value.value = ''
|
amountFileError.value = ''
|
||||||
|
if (kmFileInput.value) {
|
||||||
|
kmFileInput.value.value = ''
|
||||||
|
}
|
||||||
|
if (amountFileInput.value) {
|
||||||
|
amountFileInput.value.value = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,24 +283,41 @@ const onOpenEditDrawer = (item: MileageAllowance) => {
|
|||||||
form.kilometers = item.kilometers
|
form.kilometers = item.kilometers
|
||||||
form.amount = item.amount
|
form.amount = item.amount
|
||||||
form.comment = item.comment ?? ''
|
form.comment = item.comment ?? ''
|
||||||
selectedFile.value = undefined
|
selectedKmFile.value = undefined
|
||||||
if (fileInput.value) {
|
selectedAmountFile.value = undefined
|
||||||
fileInput.value.value = ''
|
if (kmFileInput.value) {
|
||||||
|
kmFileInput.value.value = ''
|
||||||
|
}
|
||||||
|
if (amountFileInput.value) {
|
||||||
|
amountFileInput.value.value = ''
|
||||||
}
|
}
|
||||||
isDrawerOpen.value = true
|
isDrawerOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const onFileChange = (event: Event) => {
|
const onKmFileChange = (event: Event) => {
|
||||||
const target = event.target as HTMLInputElement
|
const target = event.target as HTMLInputElement
|
||||||
const file = target.files?.[0]
|
const file = target.files?.[0]
|
||||||
if (file && file.type !== 'application/pdf') {
|
if (file && file.type !== 'application/pdf') {
|
||||||
fileError.value = 'Seuls les fichiers PDF sont acceptés.'
|
kmFileError.value = 'Seuls les fichiers PDF sont acceptés.'
|
||||||
selectedFile.value = undefined
|
selectedKmFile.value = undefined
|
||||||
target.value = ''
|
target.value = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fileError.value = ''
|
kmFileError.value = ''
|
||||||
selectedFile.value = file ?? undefined
|
selectedKmFile.value = file ?? undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const onAmountFileChange = (event: Event) => {
|
||||||
|
const target = event.target as HTMLInputElement
|
||||||
|
const file = target.files?.[0]
|
||||||
|
if (file && file.type !== 'application/pdf') {
|
||||||
|
amountFileError.value = 'Seuls les fichiers PDF sont acceptés.'
|
||||||
|
selectedAmountFile.value = undefined
|
||||||
|
target.value = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
amountFileError.value = ''
|
||||||
|
selectedAmountFile.value = file ?? undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
@@ -272,9 +329,9 @@ const onSubmit = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isEditing.value && editingItem.value) {
|
if (isEditing.value && editingItem.value) {
|
||||||
emit('update', editingItem.value.id, data, selectedFile.value)
|
emit('update', editingItem.value.id, data, selectedKmFile.value, selectedAmountFile.value)
|
||||||
} else {
|
} else {
|
||||||
emit('create', data, selectedFile.value)
|
emit('create', data, selectedKmFile.value, selectedAmountFile.value)
|
||||||
}
|
}
|
||||||
isDrawerOpen.value = false
|
isDrawerOpen.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,26 +67,26 @@
|
|||||||
<tr v-if="showCarryRow" class="bg-tertiary-500">
|
<tr v-if="showCarryRow" class="bg-tertiary-500">
|
||||||
<td class="px-5 py-[10px] font-bold text-primary-500 border border-primary-500">Report</td>
|
<td class="px-5 py-[10px] font-bold text-primary-500 border border-primary-500">Report</td>
|
||||||
<td class="px-4 py-[10px] text-center text-neutral-500 border border-primary-500 border-r-2">-</td>
|
<td class="px-4 py-[10px] text-center text-neutral-500 border border-primary-500 border-r-2">-</td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(summary!.carryBase25Minutes) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(summary!.carryBase25Minutes) }} <span class="text-neutral-400">/ {{ formatCentiemes(summary!.carryBase25Minutes) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(summary!.carryBonus25Minutes) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(summary!.carryBonus25Minutes) }} <span class="text-neutral-400">/ {{ formatCentiemes(summary!.carryBonus25Minutes) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(summary!.carryBase25Minutes + summary!.carryBonus25Minutes) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(summary!.carryBase25Minutes + summary!.carryBonus25Minutes) }} <span class="text-neutral-400">/ {{ formatCentiemes(summary!.carryBase25Minutes + summary!.carryBonus25Minutes) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(summary!.carryBase50Minutes) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(summary!.carryBase50Minutes) }} <span class="text-neutral-400">/ {{ formatCentiemes(summary!.carryBase50Minutes) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(summary!.carryBonus50Minutes) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(summary!.carryBonus50Minutes) }} <span class="text-neutral-400">/ {{ formatCentiemes(summary!.carryBonus50Minutes) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(summary!.carryBase50Minutes + summary!.carryBonus50Minutes) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(summary!.carryBase50Minutes + summary!.carryBonus50Minutes) }} <span class="text-neutral-400">/ {{ formatCentiemes(summary!.carryBase50Minutes + summary!.carryBonus50Minutes) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(summary!.carryFromPreviousYearMinutes) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(summary!.carryFromPreviousYearMinutes) }} <span class="text-neutral-400">/ {{ formatCentiemes(summary!.carryFromPreviousYearMinutes) }}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<!-- Report mois précédent (cumulated balance from previous months, July+) -->
|
<!-- Report mois précédent (cumulated balance from previous months, July+) -->
|
||||||
<tr v-if="showMonthReportRow" class="bg-tertiary-500">
|
<tr v-if="showMonthReportRow" class="bg-tertiary-500">
|
||||||
<td class="px-5 py-[10px] font-bold text-primary-500 border border-primary-500">Report</td>
|
<td class="px-5 py-[10px] font-bold text-primary-500 border border-primary-500">Report</td>
|
||||||
<td class="px-4 py-[10px] text-center text-neutral-500 border border-primary-500 border-r-2">-</td>
|
<td class="px-4 py-[10px] text-center text-neutral-500 border border-primary-500 border-r-2">-</td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(monthReport.base25) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(monthReport.base25) }} <span class="text-neutral-400">/ {{ formatCentiemes(monthReport.base25) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(monthReport.bonus25) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(monthReport.bonus25) }} <span class="text-neutral-400">/ {{ formatCentiemes(monthReport.bonus25) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(monthReport.total25) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(monthReport.total25) }} <span class="text-neutral-400">/ {{ formatCentiemes(monthReport.total25) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(monthReport.base50) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(monthReport.base50) }} <span class="text-neutral-400">/ {{ formatCentiemes(monthReport.base50) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(monthReport.bonus50) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(monthReport.bonus50) }} <span class="text-neutral-400">/ {{ formatCentiemes(monthReport.bonus50) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(monthReport.total50) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(monthReport.total50) }} <span class="text-neutral-400">/ {{ formatCentiemes(monthReport.total50) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(monthReport.total) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(monthReport.total) }} <span class="text-neutral-400">/ {{ formatCentiemes(monthReport.total) }}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<!-- Week rows (always 5) -->
|
<!-- Week rows (always 5) -->
|
||||||
@@ -162,13 +162,13 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="px-5 py-[10px] font-bold text-primary-500 border border-primary-500">Reste</td>
|
<td class="px-5 py-[10px] font-bold text-primary-500 border border-primary-500">Reste</td>
|
||||||
<td class="px-4 py-[10px] text-center text-neutral-500 border border-primary-500 border-r-2">-</td>
|
<td class="px-4 py-[10px] text-center text-neutral-500 border border-primary-500 border-r-2">-</td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(reste.base25) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(reste.base25) }} <span class="text-neutral-400">/ {{ formatCentiemes(reste.base25) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(reste.bonus25) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(reste.bonus25) }} <span class="text-neutral-400">/ {{ formatCentiemes(reste.bonus25) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(reste.total25) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(reste.total25) }} <span class="text-neutral-400">/ {{ formatCentiemes(reste.total25) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(reste.base50) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(reste.base50) }} <span class="text-neutral-400">/ {{ formatCentiemes(reste.base50) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(reste.bonus50) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(reste.bonus50) }} <span class="text-neutral-400">/ {{ formatCentiemes(reste.bonus50) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(reste.total50) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500 border-r-2">{{ formatMinutes(reste.total50) }} <span class="text-neutral-400">/ {{ formatCentiemes(reste.total50) }}</span></td>
|
||||||
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(reste.total) }}</td>
|
<td class="px-4 py-[10px] text-center font-bold text-primary-500 border border-primary-500">{{ formatMinutes(reste.total) }} <span class="text-neutral-400">/ {{ formatCentiemes(reste.total) }}</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -481,6 +481,11 @@ const formatMinutes = (minutes: number): string => {
|
|||||||
return `${sign}${hours} h ${rest} m`
|
return `${sign}${hours} h ${rest} m`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatCentiemes = (minutes: number): string => {
|
||||||
|
const value = minutes / 60
|
||||||
|
return value.toFixed(2).replace('.', ',')
|
||||||
|
}
|
||||||
|
|
||||||
// --- Payment drawer ---
|
// --- Payment drawer ---
|
||||||
|
|
||||||
const isPaymentDrawerOpen = ref(false)
|
const isPaymentDrawerOpen = ref(false)
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import {
|
|||||||
createMileageAllowance,
|
createMileageAllowance,
|
||||||
updateMileageAllowance,
|
updateMileageAllowance,
|
||||||
deleteMileageAllowance,
|
deleteMileageAllowance,
|
||||||
uploadReceipt
|
uploadKmReceipt,
|
||||||
|
uploadAmountReceipt
|
||||||
} from '~/services/mileage-allowances'
|
} from '~/services/mileage-allowances'
|
||||||
|
|
||||||
export const useEmployeeMileage = (employee: Ref<Employee | null>, reloadEmployee: () => Promise<void>) => {
|
export const useEmployeeMileage = (employee: Ref<Employee | null>, reloadEmployee: () => Promise<void>) => {
|
||||||
@@ -32,7 +33,7 @@ export const useEmployeeMileage = (employee: Ref<Employee | null>, reloadEmploye
|
|||||||
mileageDataLoaded.value = false
|
mileageDataLoaded.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitCreateMileage = async (data: { month: string; kilometers: number; amount: number; comment?: string }, file?: File) => {
|
const submitCreateMileage = async (data: { month: string; kilometers: number; amount: number; comment?: string }, kmFile?: File, amountFile?: File) => {
|
||||||
if (!employee.value) return
|
if (!employee.value) return
|
||||||
const result = await createMileageAllowance({
|
const result = await createMileageAllowance({
|
||||||
employeeId: employee.value.id,
|
employeeId: employee.value.id,
|
||||||
@@ -41,16 +42,24 @@ export const useEmployeeMileage = (employee: Ref<Employee | null>, reloadEmploye
|
|||||||
amount: data.amount,
|
amount: data.amount,
|
||||||
comment: data.comment
|
comment: data.comment
|
||||||
})
|
})
|
||||||
if (file && result?.id) {
|
if (result?.id) {
|
||||||
await uploadReceipt(apiBase, result.id, file)
|
if (kmFile) {
|
||||||
|
await uploadKmReceipt(apiBase, result.id, kmFile)
|
||||||
|
}
|
||||||
|
if (amountFile) {
|
||||||
|
await uploadAmountReceipt(apiBase, result.id, amountFile)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await reloadEmployee()
|
await reloadEmployee()
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitUpdateMileage = async (id: number, data: { month: string; kilometers: number; amount: number; comment?: string }, file?: File) => {
|
const submitUpdateMileage = async (id: number, data: { month: string; kilometers: number; amount: number; comment?: string }, kmFile?: File, amountFile?: File) => {
|
||||||
await updateMileageAllowance(id, data)
|
await updateMileageAllowance(id, data)
|
||||||
if (file) {
|
if (kmFile) {
|
||||||
await uploadReceipt(apiBase, id, file)
|
await uploadKmReceipt(apiBase, id, kmFile)
|
||||||
|
}
|
||||||
|
if (amountFile) {
|
||||||
|
await uploadAmountReceipt(apiBase, id, amountFile)
|
||||||
}
|
}
|
||||||
await reloadEmployee()
|
await reloadEmployee()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,5 +6,7 @@ export type MileageAllowance = {
|
|||||||
comment: string | null
|
comment: string | null
|
||||||
receiptPath: string | null
|
receiptPath: string | null
|
||||||
receiptName: string | null
|
receiptName: string | null
|
||||||
|
amountReceiptPath: string | null
|
||||||
|
amountReceiptName: string | null
|
||||||
createdAt: string
|
createdAt: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export const deleteMileageAllowance = async (id: number) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const uploadReceipt = async (baseURL: string, id: number, file: File) => {
|
export const uploadKmReceipt = async (baseURL: string, id: number, file: File) => {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
return $fetch(`${baseURL}/mileage_allowances/${id}/receipt`, {
|
return $fetch(`${baseURL}/mileage_allowances/${id}/receipt`, {
|
||||||
@@ -68,6 +68,20 @@ export const uploadReceipt = async (baseURL: string, id: number, file: File) =>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getReceiptUrl = (baseURL: string, id: number): string => {
|
export const uploadAmountReceipt = async (baseURL: string, id: number, file: File) => {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
return $fetch(`${baseURL}/mileage_allowances/${id}/amount-receipt`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData,
|
||||||
|
credentials: 'include'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getKmReceiptUrl = (baseURL: string, id: number): string => {
|
||||||
return `${baseURL}/mileage_allowances/${id}/receipt`
|
return `${baseURL}/mileage_allowances/${id}/receipt`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getAmountReceiptUrl = (baseURL: string, id: number): string => {
|
||||||
|
return `${baseURL}/mileage_allowances/${id}/amount-receipt`
|
||||||
|
}
|
||||||
|
|||||||
28
migrations/Version20260319100000.php
Normal file
28
migrations/Version20260319100000.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class Version20260319100000 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Add amount receipt fields to mileage_allowances';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE mileage_allowances ADD amount_receipt_path VARCHAR(255) DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE mileage_allowances ADD amount_receipt_name VARCHAR(255) DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE mileage_allowances DROP COLUMN amount_receipt_path');
|
||||||
|
$this->addSql('ALTER TABLE mileage_allowances DROP COLUMN amount_receipt_name');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,8 @@ use ApiPlatform\Metadata\GetCollection;
|
|||||||
use ApiPlatform\Metadata\Patch;
|
use ApiPlatform\Metadata\Patch;
|
||||||
use ApiPlatform\Metadata\Post;
|
use ApiPlatform\Metadata\Post;
|
||||||
use App\Repository\MileageAllowanceRepository;
|
use App\Repository\MileageAllowanceRepository;
|
||||||
|
use App\State\MileageAllowanceAmountReceiptDownloadProvider;
|
||||||
|
use App\State\MileageAllowanceAmountReceiptUploadProcessor;
|
||||||
use App\State\MileageAllowanceDeleteProcessor;
|
use App\State\MileageAllowanceDeleteProcessor;
|
||||||
use App\State\MileageAllowanceReceiptDownloadProvider;
|
use App\State\MileageAllowanceReceiptDownloadProvider;
|
||||||
use App\State\MileageAllowanceReceiptUploadProcessor;
|
use App\State\MileageAllowanceReceiptUploadProcessor;
|
||||||
@@ -50,6 +52,17 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
security: "is_granted('ROLE_ADMIN')",
|
security: "is_granted('ROLE_ADMIN')",
|
||||||
provider: MileageAllowanceReceiptDownloadProvider::class,
|
provider: MileageAllowanceReceiptDownloadProvider::class,
|
||||||
),
|
),
|
||||||
|
new Post(
|
||||||
|
uriTemplate: '/mileage_allowances/{id}/amount-receipt',
|
||||||
|
security: "is_granted('ROLE_ADMIN')",
|
||||||
|
deserialize: false,
|
||||||
|
processor: MileageAllowanceAmountReceiptUploadProcessor::class,
|
||||||
|
),
|
||||||
|
new Get(
|
||||||
|
uriTemplate: '/mileage_allowances/{id}/amount-receipt',
|
||||||
|
security: "is_granted('ROLE_ADMIN')",
|
||||||
|
provider: MileageAllowanceAmountReceiptDownloadProvider::class,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
normalizationContext: [
|
normalizationContext: [
|
||||||
'groups' => ['mileage_allowance:read', 'employee:read'],
|
'groups' => ['mileage_allowance:read', 'employee:read'],
|
||||||
@@ -103,6 +116,14 @@ class MileageAllowance
|
|||||||
#[Groups(['mileage_allowance:read'])]
|
#[Groups(['mileage_allowance:read'])]
|
||||||
private ?string $receiptName = null;
|
private ?string $receiptName = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'string', length: 255, nullable: true)]
|
||||||
|
#[Groups(['mileage_allowance:read'])]
|
||||||
|
private ?string $amountReceiptPath = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'string', length: 255, nullable: true)]
|
||||||
|
#[Groups(['mileage_allowance:read'])]
|
||||||
|
private ?string $amountReceiptName = null;
|
||||||
|
|
||||||
#[ORM\Column(type: 'datetime_immutable')]
|
#[ORM\Column(type: 'datetime_immutable')]
|
||||||
#[Groups(['mileage_allowance:read'])]
|
#[Groups(['mileage_allowance:read'])]
|
||||||
private DateTimeImmutable $createdAt;
|
private DateTimeImmutable $createdAt;
|
||||||
@@ -201,6 +222,30 @@ class MileageAllowance
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAmountReceiptPath(): ?string
|
||||||
|
{
|
||||||
|
return $this->amountReceiptPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAmountReceiptPath(?string $amountReceiptPath): self
|
||||||
|
{
|
||||||
|
$this->amountReceiptPath = $amountReceiptPath;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAmountReceiptName(): ?string
|
||||||
|
{
|
||||||
|
return $this->amountReceiptName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAmountReceiptName(?string $amountReceiptName): self
|
||||||
|
{
|
||||||
|
$this->amountReceiptName = $amountReceiptName;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCreatedAt(): DateTimeImmutable
|
public function getCreatedAt(): DateTimeImmutable
|
||||||
{
|
{
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
|
|||||||
@@ -228,6 +228,55 @@ final class WorkHourRepository extends ServiceEntityRepository implements WorkHo
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isWeekFullyValidated(Employee $employee, DateTimeImmutable $from, DateTimeImmutable $to): bool
|
||||||
|
{
|
||||||
|
// Count weekdays (Mon-Fri) in range
|
||||||
|
$expectedWeekdays = 0;
|
||||||
|
for ($d = $from; $d <= $to; $d = $d->modify('+1 day')) {
|
||||||
|
if ((int) $d->format('N') <= 5) {
|
||||||
|
++$expectedWeekdays;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 === $expectedWeekdays) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every weekday must have a work_hour row
|
||||||
|
$totalCount = (int) $this->createQueryBuilder('w')
|
||||||
|
->select('COUNT(w.id)')
|
||||||
|
->andWhere('w.employee = :employee')
|
||||||
|
->andWhere('w.workDate >= :from')
|
||||||
|
->andWhere('w.workDate <= :to')
|
||||||
|
->setParameter('employee', $employee)
|
||||||
|
->setParameter('from', $from)
|
||||||
|
->setParameter('to', $to)
|
||||||
|
->getQuery()
|
||||||
|
->getSingleScalarResult()
|
||||||
|
;
|
||||||
|
|
||||||
|
if ($totalCount < $expectedWeekdays) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All rows must be validated
|
||||||
|
$nonValidatedCount = (int) $this->createQueryBuilder('w')
|
||||||
|
->select('COUNT(w.id)')
|
||||||
|
->andWhere('w.employee = :employee')
|
||||||
|
->andWhere('w.workDate >= :from')
|
||||||
|
->andWhere('w.workDate <= :to')
|
||||||
|
->andWhere('w.isValid = :isValid')
|
||||||
|
->setParameter('employee', $employee)
|
||||||
|
->setParameter('from', $from)
|
||||||
|
->setParameter('to', $to)
|
||||||
|
->setParameter('isValid', false)
|
||||||
|
->getQuery()
|
||||||
|
->getSingleScalarResult()
|
||||||
|
;
|
||||||
|
|
||||||
|
return 0 === $nonValidatedCount;
|
||||||
|
}
|
||||||
|
|
||||||
public function hasPendingSiteValidationForSiteAndDate(int $siteId, DateTimeInterface $date): bool
|
public function hasPendingSiteValidationForSiteAndDate(int $siteId, DateTimeInterface $date): bool
|
||||||
{
|
{
|
||||||
$workDate = DateTimeImmutable::createFromInterface($date);
|
$workDate = DateTimeImmutable::createFromInterface($date);
|
||||||
|
|||||||
@@ -206,20 +206,36 @@ final readonly class RttRecoveryComputationService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$weekAnchorNature = $naturesByDate[$employeeId][$weekDays[0]] ?? ContractNature::CDI;
|
$weekAnchorNature = $naturesByDate[$employeeId][$weekDays[0]] ?? ContractNature::CDI;
|
||||||
$weekAnchorContract = $employeeContractsByDate[$weekDays[0]] ?? null;
|
$weekAnchorContract = $employeeContractsByDate[$weekDays[0]] ?? null;
|
||||||
$isWeekPresenceTracking = TrackingMode::PRESENCE->value === $weekAnchorContract?->getTrackingMode();
|
$isWeekPresenceTracking = TrackingMode::PRESENCE->value === $weekAnchorContract?->getTrackingMode();
|
||||||
$disableOvertimeBonuses = $this->hasDisabledOvertimeBonuses($weekAnchorContract, $weekAnchorNature);
|
$disableOvertimeBonuses = $this->hasDisabledOvertimeBonuses($weekAnchorContract, $weekAnchorNature);
|
||||||
$overtimeReferenceMinutes = $this->computeWeeklyOvertimeReferenceMinutes($weekDays, $employeeContractsByDate);
|
$weekContractType = ContractType::resolve(
|
||||||
|
$weekAnchorContract?->getName(),
|
||||||
|
$weekAnchorContract?->getTrackingMode(),
|
||||||
|
$weekAnchorContract?->getWeeklyHours()
|
||||||
|
);
|
||||||
|
$isCustomContract = ContractType::CUSTOM === $weekContractType;
|
||||||
|
$overtimeReferenceMinutes = $isCustomContract
|
||||||
|
? $this->computeWeeklyCustomReferenceMinutes($weekDays, $employeeContractsByDate)
|
||||||
|
: $this->computeWeeklyOvertimeReferenceMinutes($weekDays, $employeeContractsByDate);
|
||||||
$overtime25StartMinutes = $this->computeWeeklyOvertime25StartMinutes($weekDays, $employeeContractsByDate);
|
$overtime25StartMinutes = $this->computeWeeklyOvertime25StartMinutes($weekDays, $employeeContractsByDate);
|
||||||
$weeklyOvertimeTotalMinutes = $isWeekPresenceTracking
|
$weeklyOvertimeTotalMinutes = $isWeekPresenceTracking
|
||||||
? 0
|
? 0
|
||||||
: $weeklyTotalMinutes - $overtimeReferenceMinutes;
|
: $weeklyTotalMinutes - $overtimeReferenceMinutes;
|
||||||
|
|
||||||
$base25 = ($isWeekPresenceTracking || $disableOvertimeBonuses) ? 0 : max(0, min($weeklyTotalMinutes, 43 * 60) - $overtime25StartMinutes);
|
$base25 = ($isWeekPresenceTracking || $disableOvertimeBonuses || $isCustomContract) ? 0 : max(0, min($weeklyTotalMinutes, 43 * 60) - $overtime25StartMinutes);
|
||||||
$bonus25 = ($isWeekPresenceTracking || $disableOvertimeBonuses) ? 0 : (int) round($base25 * 0.25);
|
$bonus25 = ($isWeekPresenceTracking || $disableOvertimeBonuses || $isCustomContract) ? 0 : (int) round($base25 * 0.25);
|
||||||
$base50 = ($isWeekPresenceTracking || $disableOvertimeBonuses) ? 0 : max(0, $weeklyTotalMinutes - 43 * 60);
|
$base50 = ($isWeekPresenceTracking || $disableOvertimeBonuses || $isCustomContract) ? 0 : max(0, $weeklyTotalMinutes - 43 * 60);
|
||||||
$bonus50 = ($isWeekPresenceTracking || $disableOvertimeBonuses) ? 0 : (int) round($base50 * 0.5);
|
$bonus50 = ($isWeekPresenceTracking || $disableOvertimeBonuses || $isCustomContract) ? 0 : (int) round($base50 * 0.5);
|
||||||
|
|
||||||
|
if ($isWeekPresenceTracking || $disableOvertimeBonuses) {
|
||||||
|
$totalMinutes = 0;
|
||||||
|
} elseif ($isCustomContract) {
|
||||||
|
$totalMinutes = max(0, $weeklyOvertimeTotalMinutes);
|
||||||
|
} else {
|
||||||
|
$totalMinutes = $weeklyOvertimeTotalMinutes + $bonus25 + $bonus50;
|
||||||
|
}
|
||||||
|
|
||||||
$results[$weekKey] = new WeekRecoveryDetail(
|
$results[$weekKey] = new WeekRecoveryDetail(
|
||||||
overtimeMinutes: $weeklyOvertimeTotalMinutes,
|
overtimeMinutes: $weeklyOvertimeTotalMinutes,
|
||||||
@@ -227,9 +243,7 @@ final readonly class RttRecoveryComputationService
|
|||||||
bonus25Minutes: $bonus25,
|
bonus25Minutes: $bonus25,
|
||||||
base50Minutes: $base50,
|
base50Minutes: $base50,
|
||||||
bonus50Minutes: $bonus50,
|
bonus50Minutes: $bonus50,
|
||||||
totalMinutes: ($isWeekPresenceTracking || $disableOvertimeBonuses)
|
totalMinutes: $totalMinutes,
|
||||||
? 0
|
|
||||||
: $weeklyOvertimeTotalMinutes + $bonus25 + $bonus50,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,6 +340,23 @@ final readonly class RttRecoveryComputationService
|
|||||||
return max(0, $end - $start);
|
return max(0, $end - $start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $days
|
||||||
|
* @param array<string, ?Contract> $contractsByDate
|
||||||
|
*/
|
||||||
|
private function computeWeeklyCustomReferenceMinutes(array $days, array $contractsByDate): int
|
||||||
|
{
|
||||||
|
$total = 0;
|
||||||
|
foreach ($days as $date) {
|
||||||
|
$isoDay = (int) new DateTimeImmutable($date)->format('N');
|
||||||
|
$contract = $contractsByDate[$date] ?? null;
|
||||||
|
$hours = $contract?->getWeeklyHours();
|
||||||
|
$total += $this->resolveDailyReferenceMinutes($hours, $isoDay);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $total;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param list<string> $days
|
* @param list<string> $days
|
||||||
* @param array<string, ?Contract> $contractsByDate
|
* @param array<string, ?Contract> $contractsByDate
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use App\Entity\User;
|
|||||||
use App\Repository\EmployeeRepository;
|
use App\Repository\EmployeeRepository;
|
||||||
use App\Repository\EmployeeRttBalanceRepository;
|
use App\Repository\EmployeeRttBalanceRepository;
|
||||||
use App\Repository\EmployeeRttPaymentRepository;
|
use App\Repository\EmployeeRttPaymentRepository;
|
||||||
|
use App\Repository\WorkHourRepository;
|
||||||
use App\Security\EmployeeScopeService;
|
use App\Security\EmployeeScopeService;
|
||||||
use App\Service\Rtt\RttRecoveryComputationService;
|
use App\Service\Rtt\RttRecoveryComputationService;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
@@ -36,6 +37,7 @@ final readonly class EmployeeRttSummaryProvider implements ProviderInterface
|
|||||||
private EmployeeRttBalanceRepository $rttBalanceRepository,
|
private EmployeeRttBalanceRepository $rttBalanceRepository,
|
||||||
private EmployeeRttPaymentRepository $rttPaymentRepository,
|
private EmployeeRttPaymentRepository $rttPaymentRepository,
|
||||||
private RttRecoveryComputationService $rttRecoveryService,
|
private RttRecoveryComputationService $rttRecoveryService,
|
||||||
|
private WorkHourRepository $workHourRepository,
|
||||||
string $rttStartDate = '',
|
string $rttStartDate = '',
|
||||||
) {
|
) {
|
||||||
$this->rttStartDate = '' !== $rttStartDate ? $rttStartDate : null;
|
$this->rttStartDate = '' !== $rttStartDate ? $rttStartDate : null;
|
||||||
@@ -83,6 +85,16 @@ final readonly class EmployeeRttSummaryProvider implements ProviderInterface
|
|||||||
// Exclude the current (incomplete) week: limit to last Sunday
|
// Exclude the current (incomplete) week: limit to last Sunday
|
||||||
$isoDay = (int) $today->format('N'); // 1=Monday .. 7=Sunday
|
$isoDay = (int) $today->format('N'); // 1=Monday .. 7=Sunday
|
||||||
$limitDate = 7 === $isoDay ? $today : $today->modify('last sunday');
|
$limitDate = 7 === $isoDay ? $today : $today->modify('last sunday');
|
||||||
|
|
||||||
|
// Include the current week if all existing days are admin-validated
|
||||||
|
if (7 !== $isoDay) {
|
||||||
|
$currentWeekStart = $today->modify('monday this week');
|
||||||
|
$currentWeekEnd = $currentWeekStart->modify('+6 days');
|
||||||
|
$checkEnd = $this->resolveWeekEndForEmployee($employee, $currentWeekStart, $currentWeekEnd, $today);
|
||||||
|
if ($this->workHourRepository->isWeekFullyValidated($employee, $currentWeekStart, $checkEnd)) {
|
||||||
|
$limitDate = $currentWeekEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentByWeekStart = $this->rttRecoveryService->computeRecoveryByWeek($employee, $weekRanges, $periodFrom, $periodTo, $limitDate);
|
$currentByWeekStart = $this->rttRecoveryService->computeRecoveryByWeek($employee, $weekRanges, $periodFrom, $periodTo, $limitDate);
|
||||||
@@ -236,4 +248,25 @@ final readonly class EmployeeRttSummaryProvider implements ProviderInterface
|
|||||||
|
|
||||||
return $month >= 6 ? $year + 1 : $year;
|
return $month >= 6 ? $year + 1 : $year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the employee's contract ends within the current week, cap the check range to that end date.
|
||||||
|
*/
|
||||||
|
private function resolveWeekEndForEmployee(Employee $employee, DateTimeImmutable $weekStart, DateTimeImmutable $weekEnd, DateTimeImmutable $today): DateTimeImmutable
|
||||||
|
{
|
||||||
|
foreach ($employee->getContractPeriods() as $period) {
|
||||||
|
if ($period->getStartDate() > $today) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$endDate = $period->getEndDate();
|
||||||
|
if (null === $endDate) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($endDate >= $weekStart && $endDate <= $weekEnd) {
|
||||||
|
return $endDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $weekEnd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use App\Enum\TrackingMode;
|
|||||||
use App\Repository\EmployeeRepository;
|
use App\Repository\EmployeeRepository;
|
||||||
use App\Repository\EmployeeRttBalanceRepository;
|
use App\Repository\EmployeeRttBalanceRepository;
|
||||||
use App\Repository\EmployeeRttPaymentRepository;
|
use App\Repository\EmployeeRttPaymentRepository;
|
||||||
|
use App\Repository\WorkHourRepository;
|
||||||
use App\Service\Rtt\RttRecoveryComputationService;
|
use App\Service\Rtt\RttRecoveryComputationService;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
@@ -32,6 +33,7 @@ class LeaveRecapPrintProvider implements ProviderInterface
|
|||||||
private EmployeeRttBalanceRepository $rttBalanceRepository,
|
private EmployeeRttBalanceRepository $rttBalanceRepository,
|
||||||
private EmployeeRttPaymentRepository $rttPaymentRepository,
|
private EmployeeRttPaymentRepository $rttPaymentRepository,
|
||||||
private EntityManagerInterface $entityManager,
|
private EntityManagerInterface $entityManager,
|
||||||
|
private WorkHourRepository $workHourRepository,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): Response
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): Response
|
||||||
@@ -142,6 +144,16 @@ class LeaveRecapPrintProvider implements ProviderInterface
|
|||||||
$isoDay = (int) $today->format('N');
|
$isoDay = (int) $today->format('N');
|
||||||
$limitDate = 7 === $isoDay ? $today : $today->modify('last sunday');
|
$limitDate = 7 === $isoDay ? $today : $today->modify('last sunday');
|
||||||
|
|
||||||
|
// Include the current week if all existing days are admin-validated
|
||||||
|
if (7 !== $isoDay) {
|
||||||
|
$currentWeekStart = $today->modify('monday this week');
|
||||||
|
$currentWeekEnd = $currentWeekStart->modify('+6 days');
|
||||||
|
$checkEnd = $this->resolveWeekEndForEmployee($employee, $currentWeekStart, $currentWeekEnd, $today);
|
||||||
|
if ($this->workHourRepository->isWeekFullyValidated($employee, $currentWeekStart, $checkEnd)) {
|
||||||
|
$limitDate = $currentWeekEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Carry from previous exercise
|
// Carry from previous exercise
|
||||||
$carry = 0;
|
$carry = 0;
|
||||||
$balance = $this->rttBalanceRepository->findOneByEmployeeAndYear($employee, $exerciseYear);
|
$balance = $this->rttBalanceRepository->findOneByEmployeeAndYear($employee, $exerciseYear);
|
||||||
@@ -165,6 +177,24 @@ class LeaveRecapPrintProvider implements ProviderInterface
|
|||||||
return $carry + $current->totalMinutes - $paid;
|
return $carry + $current->totalMinutes - $paid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function resolveWeekEndForEmployee(Employee $employee, DateTimeImmutable $weekStart, DateTimeImmutable $weekEnd, DateTimeImmutable $today): DateTimeImmutable
|
||||||
|
{
|
||||||
|
foreach ($employee->getContractPeriods() as $period) {
|
||||||
|
if ($period->getStartDate() > $today) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$endDate = $period->getEndDate();
|
||||||
|
if (null === $endDate) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($endDate >= $weekStart && $endDate <= $weekEnd) {
|
||||||
|
return $endDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $weekEnd;
|
||||||
|
}
|
||||||
|
|
||||||
private function formatMinutes(int $minutes): string
|
private function formatMinutes(int $minutes): string
|
||||||
{
|
{
|
||||||
if (0 === $minutes) {
|
if (0 === $minutes) {
|
||||||
|
|||||||
53
src/State/MileageAllowanceAmountReceiptDownloadProvider.php
Normal file
53
src/State/MileageAllowanceAmountReceiptDownloadProvider.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\State;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Operation;
|
||||||
|
use ApiPlatform\State\ProviderInterface;
|
||||||
|
use App\Entity\MileageAllowance;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
|
final readonly class MileageAllowanceAmountReceiptDownloadProvider implements ProviderInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private EntityManagerInterface $entityManager,
|
||||||
|
#[Autowire('%kernel.project_dir%/var/uploads')]
|
||||||
|
private string $uploadDir,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$mileageAllowance = $this->entityManager->find(MileageAllowance::class, $uriVariables['id']);
|
||||||
|
|
||||||
|
if (null === $mileageAllowance) {
|
||||||
|
throw new NotFoundHttpException('Mileage allowance not found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$receiptPath = $mileageAllowance->getAmountReceiptPath();
|
||||||
|
|
||||||
|
if (null === $receiptPath) {
|
||||||
|
throw new NotFoundHttpException('No amount receipt found for this mileage allowance.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$absolutePath = sprintf('%s/%s', $this->uploadDir, $receiptPath);
|
||||||
|
|
||||||
|
if (!file_exists($absolutePath)) {
|
||||||
|
throw new NotFoundHttpException('Amount receipt file not found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = new BinaryFileResponse($absolutePath);
|
||||||
|
$disposition = HeaderUtils::makeDisposition(
|
||||||
|
HeaderUtils::DISPOSITION_ATTACHMENT,
|
||||||
|
$mileageAllowance->getAmountReceiptName() ?? 'justificatif.pdf'
|
||||||
|
);
|
||||||
|
$response->headers->set('Content-Disposition', $disposition);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
66
src/State/MileageAllowanceAmountReceiptUploadProcessor.php
Normal file
66
src/State/MileageAllowanceAmountReceiptUploadProcessor.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\State;
|
||||||
|
|
||||||
|
use ApiPlatform\Metadata\Operation;
|
||||||
|
use ApiPlatform\State\ProcessorInterface;
|
||||||
|
use App\Entity\MileageAllowance;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
|
use Symfony\Component\Uid\Uuid;
|
||||||
|
|
||||||
|
final readonly class MileageAllowanceAmountReceiptUploadProcessor implements ProcessorInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private EntityManagerInterface $entityManager,
|
||||||
|
private RequestStack $requestStack,
|
||||||
|
#[Autowire('%kernel.project_dir%/var/uploads')]
|
||||||
|
private string $uploadDir,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): JsonResponse
|
||||||
|
{
|
||||||
|
if (!$data instanceof MileageAllowance) {
|
||||||
|
throw new BadRequestHttpException('Invalid entity.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$request = $this->requestStack->getCurrentRequest();
|
||||||
|
$file = $request?->files->get('file');
|
||||||
|
|
||||||
|
if (null === $file) {
|
||||||
|
throw new BadRequestHttpException('No file uploaded.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('application/pdf' !== $file->getMimeType()) {
|
||||||
|
throw new BadRequestHttpException('Only PDF files are accepted.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$month = $data->getMonth();
|
||||||
|
$year = $month?->format('Y') ?? date('Y');
|
||||||
|
$monthNumber = $month?->format('m') ?? date('m');
|
||||||
|
$relativePath = sprintf('mileage-receipts/%s/%s', $year, $monthNumber);
|
||||||
|
$absoluteDir = sprintf('%s/%s', $this->uploadDir, $relativePath);
|
||||||
|
|
||||||
|
if (!is_dir($absoluteDir)) {
|
||||||
|
mkdir($absoluteDir, 0o755, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = Uuid::v4()->toRfc4122().'.pdf';
|
||||||
|
$fullRelative = sprintf('%s/%s', $relativePath, $filename);
|
||||||
|
$originalName = $file->getClientOriginalName();
|
||||||
|
|
||||||
|
$file->move($absoluteDir, $filename);
|
||||||
|
|
||||||
|
$data->setAmountReceiptPath($fullRelative);
|
||||||
|
$data->setAmountReceiptName($originalName);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
return new JsonResponse(['path' => $fullRelative, 'name' => $originalName], Response::HTTP_OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,6 +34,16 @@ final readonly class MileageAllowanceDeleteProcessor implements ProcessorInterfa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$amountReceiptPath = $data->getAmountReceiptPath();
|
||||||
|
|
||||||
|
if (null !== $amountReceiptPath) {
|
||||||
|
$absolutePath = sprintf('%s/%s', $this->uploadDir, $amountReceiptPath);
|
||||||
|
|
||||||
|
if (file_exists($absolutePath)) {
|
||||||
|
unlink($absolutePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->entityManager->remove($data);
|
$this->entityManager->remove($data);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user