Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ec1e1f10d | ||
| 24b7512c8a | |||
| f047e3ed4b | |||
|
|
1feedd0381 | ||
| f9cd5a0143 | |||
|
|
ede7decaa7 | ||
| 2cfb05e5de | |||
|
|
0a8399a950 | ||
| 6a64cb4c58 |
6
.idea/sqldialects.xml
generated
Normal file
6
.idea/sqldialects.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/sirh.sql" dialect="GenericSQL" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
parameters:
|
parameters:
|
||||||
app.version: '0.1.51'
|
app.version: '0.1.55'
|
||||||
|
|||||||
@@ -344,7 +344,24 @@ Tous les filtres checkbox sont cochés par défaut à l'ouverture du drawer.
|
|||||||
| CHAUFFEUR - samedi | WorkHour (samedi) | Samedis travaillés (chauffeurs uniquement) |
|
| CHAUFFEUR - samedi | WorkHour (samedi) | Samedis travaillés (chauffeurs uniquement) |
|
||||||
| Observations | — | Colonne vide pour saisie manuelle |
|
| Observations | — | Colonne vide pour saisie manuelle |
|
||||||
|
|
||||||
## 12) Notifications
|
## 12) Frais
|
||||||
|
|
||||||
|
- Onglet "Frais" sur la fiche employé (icône `mdi:account-cash-outline`)
|
||||||
|
- Entité `MileageAllowance` (table `mileage_allowances`)
|
||||||
|
- Champs:
|
||||||
|
- `month` (mois, obligatoire)
|
||||||
|
- `kilometers` (nombre de km, optionnel)
|
||||||
|
- `amount` (montant en €, optionnel)
|
||||||
|
- `comment` (commentaire, optionnel)
|
||||||
|
- `receiptPath` / `receiptName` (justificatif PDF)
|
||||||
|
- Règle de validation:
|
||||||
|
- le mois est obligatoire
|
||||||
|
- au moins un des deux champs `kilometers` ou `amount` doit être > 0
|
||||||
|
- les deux peuvent être remplis simultanément
|
||||||
|
- Tableau: colonnes Mois, Nombre de Km, Montant €, Commentaire, Justificatif
|
||||||
|
- Justificatif: upload PDF uniquement, téléchargement via endpoint dédié
|
||||||
|
|
||||||
|
## 13) Notifications
|
||||||
|
|
||||||
- Icône cloche en topbar:
|
- Icône cloche en topbar:
|
||||||
- badge = nombre de notifications non lues
|
- badge = nombre de notifications non lues
|
||||||
|
|||||||
@@ -1,35 +1,35 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="flex h-full min-h-0 flex-col overflow-hidden pt-8">
|
<section class="flex h-full min-h-0 flex-col overflow-hidden pt-8">
|
||||||
<div class="grid grid-cols-4 rounded-md bg-tertiary-500 text-primary-500 text-[18px] border border-primary-500">
|
<div class="grid grid-cols-4 rounded-md bg-tertiary-500 text-primary-500 text-[18px] border border-primary-500">
|
||||||
<p class="col-start-1 p-[10px] border-b border-b-black"><strong class="uppercase font-semibold">Année acquis :</strong> {{
|
<p class="col-start-1 p-[10px] border-b border-r border-primary-500"><strong class="uppercase font-semibold">Année acquis :</strong> {{
|
||||||
formatCount(summary?.acquiredDays)
|
formatCount(summary?.acquiredDays)
|
||||||
}} Jours
|
}} Jours
|
||||||
</p>
|
</p>
|
||||||
<p class="col-start-2 p-[10px] border-b border-b-black"><strong class="uppercase font-semibold">Pris :</strong>
|
<p class="col-start-2 p-[10px] border-b border-r border-primary-500"><strong class="uppercase font-semibold">Pris :</strong>
|
||||||
{{ formatCount(isForfaitRule ? currentYearTakenDays : summary?.takenDays) }} Jours
|
{{ formatCount(isForfaitRule ? currentYearTakenDays : summary?.takenDays) }} Jours
|
||||||
</p>
|
</p>
|
||||||
<p class="col-start-3 p-[10px] border-b border-b-black"><strong class="uppercase font-semibold">Reste à prendre :</strong>
|
<p class="col-start-3 p-[10px] border-b border-r border-b-white border-r-primary-500 bg-primary-500 text-white"><strong class="uppercase font-semibold">Reste à prendre :</strong>
|
||||||
{{ formatCount(summary?.remainingDays) }} Jours
|
{{ formatCount(summary?.remainingDays) }} Jours
|
||||||
</p>
|
</p>
|
||||||
<p class="col-start-4 p-[10px] border-b border-b-black"><strong class="uppercase font-semibold">En cours d'acquisition :</strong>
|
<p class="col-start-4 p-[10px] border-b border-primary-500"><strong class="uppercase font-semibold">En cours d'acquisition :</strong>
|
||||||
{{ formatCount(summary?.accruingDays) }} Jours
|
{{ formatCount(summary?.accruingDays) }} Jours
|
||||||
</p>
|
</p>
|
||||||
<p v-if="!isForfaitRule" class="col-start-1 p-[10px]"><span class="uppercase font-semibold">Samedi acquis :</span>
|
<p v-if="!isForfaitRule" class="col-start-1 p-[10px] border-r border-primary-500"><span class="uppercase font-semibold">Samedi acquis :</span>
|
||||||
{{ formatCount(summary?.acquiredSaturdays) }} Jours
|
{{ formatCount(summary?.acquiredSaturdays) }} Jours
|
||||||
</p>
|
</p>
|
||||||
<p v-else class="col-start-1 p-[10px]"><span class="uppercase font-semibold">Année N-1 acquis :</span>
|
<p v-else class="col-start-1 p-[10px] border-r border-primary-500"><span class="uppercase font-semibold">Année N-1 acquis :</span>
|
||||||
{{ formatCount(summary?.previousYearAcquiredDays) }} Jours
|
{{ formatCount(summary?.previousYearAcquiredDays) }} Jours
|
||||||
</p>
|
</p>
|
||||||
<p v-if="!isForfaitRule" class="col-start-2 p-[10px]"><span class="uppercase font-semibold">Pris :</span>
|
<p v-if="!isForfaitRule" class="col-start-2 p-[10px] border-r border-primary-500"><span class="uppercase font-semibold">Pris :</span>
|
||||||
{{ formatCount(summary?.takenSaturdays) }} Jours
|
{{ formatCount(summary?.takenSaturdays) }} Jours
|
||||||
</p>
|
</p>
|
||||||
<p v-if="!isForfaitRule" class="col-start-3 p-[10px]"><span class="uppercase font-semibold">Reste à prendre :</span>
|
<p v-if="!isForfaitRule" class="col-start-3 p-[10px] border-r border-r-primary-500 bg-primary-500 text-white"><span class="uppercase font-semibold">Reste à prendre :</span>
|
||||||
{{ formatCount(summary?.remainingSaturdays) }} Jours
|
{{ formatCount(summary?.remainingSaturdays) }} Jours
|
||||||
</p>
|
</p>
|
||||||
<p v-else class="col-start-2 p-[10px]"><span class="uppercase font-semibold">Pris :</span>
|
<p v-else class="col-start-2 p-[10px] border-r border-primary-500"><span class="uppercase font-semibold">Pris :</span>
|
||||||
{{ formatCount(summary?.previousYearTakenDays) }} Jours
|
{{ formatCount(summary?.previousYearTakenDays) }} Jours
|
||||||
</p>
|
</p>
|
||||||
<p v-if="isForfaitRule" class="col-start-3 p-[10px]"><span class="uppercase font-semibold">Reste à prendre :</span>
|
<p v-if="isForfaitRule" class="col-start-3 p-[10px] border-r-primary-500 bg-primary-500 text-white"><span class="uppercase font-semibold">Reste à prendre :</span>
|
||||||
{{ formatCount(summary?.previousYearRemainingDays) }} Jours
|
{{ formatCount(summary?.previousYearRemainingDays) }} Jours
|
||||||
</p>
|
</p>
|
||||||
<div v-if="!isForfaitRule" class="col-start-4 p-[10px] flex gap-7 items-center">
|
<div v-if="!isForfaitRule" class="col-start-4 p-[10px] flex gap-7 items-center">
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
<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-4 border border-black bg-tertiary-500 px-6 py-3 text-[20px] font-semibold text-black rounded-t-md">
|
class="grid grid-cols-5 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>Commentaire</p>
|
<p>Commentaire</p>
|
||||||
<p>Justificatif</p>
|
<p>Justificatif</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -15,11 +16,12 @@
|
|||||||
<div
|
<div
|
||||||
v-for="item in allowances"
|
v-for="item in allowances"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="grid grid-cols-4 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-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"
|
||||||
@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.comment ?? '-' }}</p>
|
<p>{{ item.comment ?? '-' }}</p>
|
||||||
<p>
|
<p>
|
||||||
<a
|
<a
|
||||||
@@ -48,7 +50,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<AppDrawer v-model="isDrawerOpen" title="Frais Kms">
|
<AppDrawer v-model="isDrawerOpen" title="Frais">
|
||||||
<form class="space-y-4" @submit.prevent="onSubmit">
|
<form class="space-y-4" @submit.prevent="onSubmit">
|
||||||
<div>
|
<div>
|
||||||
<label class="text-md font-semibold text-neutral-700" for="mileage-month">
|
<label class="text-md font-semibold text-neutral-700" for="mileage-month">
|
||||||
@@ -64,7 +66,7 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="text-md font-semibold text-neutral-700" for="mileage-kilometers">
|
<label class="text-md font-semibold text-neutral-700" for="mileage-kilometers">
|
||||||
Nombre de Km <span class="text-red-600">*</span>
|
Nombre de Km
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
id="mileage-kilometers"
|
id="mileage-kilometers"
|
||||||
@@ -76,6 +78,21 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="text-md font-semibold text-neutral-700" for="mileage-amount">
|
||||||
|
Montant (€)
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="mileage-amount"
|
||||||
|
v-model.number="form.amount"
|
||||||
|
type="number"
|
||||||
|
step="0.01"
|
||||||
|
min="0"
|
||||||
|
class="mt-2 w-full rounded-md border border-neutral-300 px-3 py-2 text-base text-neutral-900 focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-secondary-500/20"
|
||||||
|
/>
|
||||||
|
<p class="mt-1 text-sm text-neutral-500">Au moins un des deux champs doit être rempli</p>
|
||||||
|
</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-receipt">
|
||||||
Justificatif
|
Justificatif
|
||||||
@@ -148,8 +165,8 @@ const props = defineProps<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: 'create', data: { month: string; kilometers: number; comment?: string }, file?: File): void
|
(event: 'create', data: { month: string; kilometers: number; amount: number; comment?: string }, file?: File): void
|
||||||
(event: 'update', id: number, data: { month: string; kilometers: number; comment?: string }, file?: File): void
|
(event: 'update', id: number, data: { month: string; kilometers: number; amount: number; comment?: string }, file?: File): void
|
||||||
(event: 'delete', id: number): void
|
(event: 'delete', id: number): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
@@ -168,11 +185,12 @@ const currentYearMonth = () => {
|
|||||||
const form = reactive({
|
const form = reactive({
|
||||||
month: currentYearMonth(),
|
month: currentYearMonth(),
|
||||||
kilometers: 0,
|
kilometers: 0,
|
||||||
|
amount: 0,
|
||||||
comment: ''
|
comment: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const isFormValid = computed(() => {
|
const isFormValid = computed(() => {
|
||||||
return form.month && form.kilometers > 0 && !fileError.value
|
return form.month && (form.kilometers > 0 || form.amount > 0) && !fileError.value
|
||||||
})
|
})
|
||||||
|
|
||||||
const monthLabels: Record<number, string> = {
|
const monthLabels: Record<number, string> = {
|
||||||
@@ -201,6 +219,7 @@ const formatMonth = (dateStr: string): string => {
|
|||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
form.month = currentYearMonth()
|
form.month = currentYearMonth()
|
||||||
form.kilometers = 0
|
form.kilometers = 0
|
||||||
|
form.amount = 0
|
||||||
form.comment = ''
|
form.comment = ''
|
||||||
selectedFile.value = undefined
|
selectedFile.value = undefined
|
||||||
fileError.value = ''
|
fileError.value = ''
|
||||||
@@ -222,6 +241,7 @@ const onOpenEditDrawer = (item: MileageAllowance) => {
|
|||||||
// Extract YYYY-MM from YYYY-MM-DD
|
// Extract YYYY-MM from YYYY-MM-DD
|
||||||
form.month = item.month.substring(0, 7)
|
form.month = item.month.substring(0, 7)
|
||||||
form.kilometers = item.kilometers
|
form.kilometers = item.kilometers
|
||||||
|
form.amount = item.amount
|
||||||
form.comment = item.comment ?? ''
|
form.comment = item.comment ?? ''
|
||||||
selectedFile.value = undefined
|
selectedFile.value = undefined
|
||||||
if (fileInput.value) {
|
if (fileInput.value) {
|
||||||
@@ -247,6 +267,7 @@ const onSubmit = () => {
|
|||||||
const data = {
|
const data = {
|
||||||
month: `${form.month}-01`,
|
month: `${form.month}-01`,
|
||||||
kilometers: form.kilometers,
|
kilometers: form.kilometers,
|
||||||
|
amount: form.amount,
|
||||||
comment: form.comment || undefined
|
comment: form.comment || undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p class="text-[16px]">
|
<p class="text-[16px]">
|
||||||
<span class="font-bold">RTT À LA DATE DU JOUR :</span>
|
<span class="font-bold">RTT À LA SEMAINE {{ lastCompleteWeek }} : </span>
|
||||||
{{ formatMinutes(summary?.availableMinutes ?? 0) }}
|
<span class="font-bold">{{ formatMinutes(summary?.availableMinutes ?? 0) }}</span>
|
||||||
</p>
|
</p>
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<button
|
<button
|
||||||
@@ -258,6 +258,17 @@ const emit = defineEmits<{
|
|||||||
(event: 'submit-rtt-payment', month: number, base25Minutes: number, bonus25Minutes: number, base50Minutes: number, bonus50Minutes: number): void
|
(event: 'submit-rtt-payment', month: number, base25Minutes: number, bonus25Minutes: number, base50Minutes: number, bonus50Minutes: number): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
// --- Last complete week number ---
|
||||||
|
|
||||||
|
const lastCompleteWeek = computed(() => {
|
||||||
|
const now = new Date()
|
||||||
|
const startOfYear = new Date(now.getFullYear(), 0, 1)
|
||||||
|
const dayOfYear = Math.floor((now.getTime() - startOfYear.getTime()) / 86400000) + 1
|
||||||
|
const dayOfWeek = now.getDay() || 7 // Monday = 1, Sunday = 7
|
||||||
|
const currentWeek = Math.ceil((dayOfYear - dayOfWeek + 10) / 7)
|
||||||
|
return currentWeek - 1
|
||||||
|
})
|
||||||
|
|
||||||
// --- Month navigation ---
|
// --- Month navigation ---
|
||||||
|
|
||||||
const orderedMonths = [6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5] as const
|
const orderedMonths = [6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5] as const
|
||||||
|
|||||||
@@ -32,12 +32,13 @@ export const useEmployeeMileage = (employee: Ref<Employee | null>, reloadEmploye
|
|||||||
mileageDataLoaded.value = false
|
mileageDataLoaded.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitCreateMileage = async (data: { month: string; kilometers: number; comment?: string }, file?: File) => {
|
const submitCreateMileage = async (data: { month: string; kilometers: number; amount: number; comment?: string }, file?: 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,
|
||||||
month: data.month,
|
month: data.month,
|
||||||
kilometers: data.kilometers,
|
kilometers: data.kilometers,
|
||||||
|
amount: data.amount,
|
||||||
comment: data.comment
|
comment: data.comment
|
||||||
})
|
})
|
||||||
if (file && result?.id) {
|
if (file && result?.id) {
|
||||||
@@ -46,7 +47,7 @@ export const useEmployeeMileage = (employee: Ref<Employee | null>, reloadEmploye
|
|||||||
await reloadEmployee()
|
await reloadEmployee()
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitUpdateMileage = async (id: number, data: { month: string; kilometers: number; comment?: string }, file?: File) => {
|
const submitUpdateMileage = async (id: number, data: { month: string; kilometers: number; amount: number; comment?: string }, file?: File) => {
|
||||||
await updateMileageAllowance(id, data)
|
await updateMileageAllowance(id, data)
|
||||||
if (file) {
|
if (file) {
|
||||||
await uploadReceipt(apiBase, id, file)
|
await uploadReceipt(apiBase, id, file)
|
||||||
|
|||||||
@@ -62,8 +62,8 @@
|
|||||||
: 'border-transparent text-primary-500/50 hover:text-primary-500'"
|
: 'border-transparent text-primary-500/50 hover:text-primary-500'"
|
||||||
@click="activeTab = 'mileage'"
|
@click="activeTab = 'mileage'"
|
||||||
>
|
>
|
||||||
<Icon name="mdi:car-outline" size="24" class="align-self"/>
|
<Icon name="mdi:account-cash-outline" size="24" class="align-self"/>
|
||||||
Frais Kms
|
Frais
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="pb-2 border-b-2 flex items-center gap-3"
|
class="pb-2 border-b-2 flex items-center gap-3"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ export type MileageAllowance = {
|
|||||||
id: number
|
id: number
|
||||||
month: string
|
month: string
|
||||||
kilometers: number
|
kilometers: number
|
||||||
|
amount: number
|
||||||
comment: string | null
|
comment: string | null
|
||||||
receiptPath: string | null
|
receiptPath: string | null
|
||||||
receiptName: string | null
|
receiptName: string | null
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export const createMileageAllowance = async (data: {
|
|||||||
employeeId: number
|
employeeId: number
|
||||||
month: string
|
month: string
|
||||||
kilometers: number
|
kilometers: number
|
||||||
|
amount: number
|
||||||
comment?: string
|
comment?: string
|
||||||
}) => {
|
}) => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
@@ -23,6 +24,7 @@ export const createMileageAllowance = async (data: {
|
|||||||
employee: `/api/employees/${data.employeeId}`,
|
employee: `/api/employees/${data.employeeId}`,
|
||||||
month: data.month,
|
month: data.month,
|
||||||
kilometers: data.kilometers,
|
kilometers: data.kilometers,
|
||||||
|
amount: data.amount,
|
||||||
comment: data.comment
|
comment: data.comment
|
||||||
}, {
|
}, {
|
||||||
toastSuccessKey: 'success.mileage.create',
|
toastSuccessKey: 'success.mileage.create',
|
||||||
@@ -33,12 +35,14 @@ export const createMileageAllowance = async (data: {
|
|||||||
export const updateMileageAllowance = async (id: number, data: {
|
export const updateMileageAllowance = async (id: number, data: {
|
||||||
month: string
|
month: string
|
||||||
kilometers: number
|
kilometers: number
|
||||||
|
amount: number
|
||||||
comment?: string
|
comment?: string
|
||||||
}) => {
|
}) => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
return api.patch<MileageAllowance>(`/mileage_allowances/${id}`, {
|
return api.patch<MileageAllowance>(`/mileage_allowances/${id}`, {
|
||||||
month: data.month,
|
month: data.month,
|
||||||
kilometers: data.kilometers,
|
kilometers: data.kilometers,
|
||||||
|
amount: data.amount,
|
||||||
comment: data.comment
|
comment: data.comment
|
||||||
}, {
|
}, {
|
||||||
toastSuccessKey: 'success.mileage.update',
|
toastSuccessKey: 'success.mileage.update',
|
||||||
|
|||||||
26
migrations/Version20260318143503.php
Normal file
26
migrations/Version20260318143503.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class Version20260318143503 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Add amount column to mileage_allowances';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE mileage_allowances ADD COLUMN amount DOUBLE PRECISION DEFAULT 0 NOT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE mileage_allowances DROP COLUMN amount');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ use App\State\EmployeeLeaveSummaryProvider;
|
|||||||
operations: [
|
operations: [
|
||||||
new Get(
|
new Get(
|
||||||
uriTemplate: '/employees/{id}/leave-summary',
|
uriTemplate: '/employees/{id}/leave-summary',
|
||||||
security: "is_granted('ROLE_USER')",
|
security: "is_granted('ROLE_ADMIN')",
|
||||||
provider: EmployeeLeaveSummaryProvider::class
|
provider: EmployeeLeaveSummaryProvider::class
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use App\State\EmployeeRttSummaryProvider;
|
|||||||
operations: [
|
operations: [
|
||||||
new Get(
|
new Get(
|
||||||
uriTemplate: '/employees/{id}/rtt-summary',
|
uriTemplate: '/employees/{id}/rtt-summary',
|
||||||
security: "is_granted('ROLE_USER')",
|
security: "is_granted('ROLE_ADMIN')",
|
||||||
provider: EmployeeRttSummaryProvider::class
|
provider: EmployeeRttSummaryProvider::class
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
operations: [
|
operations: [
|
||||||
new Get(
|
new Get(
|
||||||
security: "is_granted('ROLE_USER')"
|
security: "is_granted('ROLE_ADMIN')"
|
||||||
),
|
),
|
||||||
new GetCollection(
|
new GetCollection(
|
||||||
security: "is_granted('ROLE_USER')"
|
security: "is_granted('ROLE_ADMIN')"
|
||||||
),
|
),
|
||||||
new Post(
|
new Post(
|
||||||
security: "is_granted('ROLE_ADMIN')"
|
security: "is_granted('ROLE_ADMIN')"
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
operations: [
|
operations: [
|
||||||
new Get(
|
new Get(
|
||||||
security: "is_granted('ROLE_USER')"
|
security: "is_granted('ROLE_ADMIN')"
|
||||||
),
|
),
|
||||||
new GetCollection(
|
new GetCollection(
|
||||||
security: "is_granted('ROLE_USER')"
|
security: "is_granted('ROLE_ADMIN')"
|
||||||
),
|
),
|
||||||
new Post(
|
new Post(
|
||||||
security: "is_granted('ROLE_ADMIN')"
|
security: "is_granted('ROLE_ADMIN')"
|
||||||
@@ -47,7 +47,7 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
),
|
),
|
||||||
new Get(
|
new Get(
|
||||||
uriTemplate: '/mileage_allowances/{id}/receipt',
|
uriTemplate: '/mileage_allowances/{id}/receipt',
|
||||||
security: "is_granted('ROLE_USER')",
|
security: "is_granted('ROLE_ADMIN')",
|
||||||
provider: MileageAllowanceReceiptDownloadProvider::class,
|
provider: MileageAllowanceReceiptDownloadProvider::class,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -87,6 +87,10 @@ class MileageAllowance
|
|||||||
#[Groups(['mileage_allowance:read', 'mileage_allowance:write'])]
|
#[Groups(['mileage_allowance:read', 'mileage_allowance:write'])]
|
||||||
private float $kilometers = 0;
|
private float $kilometers = 0;
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'float', options: ['default' => 0])]
|
||||||
|
#[Groups(['mileage_allowance:read', 'mileage_allowance:write'])]
|
||||||
|
private float $amount = 0;
|
||||||
|
|
||||||
#[ORM\Column(type: 'text', nullable: true)]
|
#[ORM\Column(type: 'text', nullable: true)]
|
||||||
#[Groups(['mileage_allowance:read', 'mileage_allowance:write'])]
|
#[Groups(['mileage_allowance:read', 'mileage_allowance:write'])]
|
||||||
private ?string $comment = null;
|
private ?string $comment = null;
|
||||||
@@ -149,6 +153,18 @@ class MileageAllowance
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAmount(): float
|
||||||
|
{
|
||||||
|
return $this->amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAmount(float $amount): self
|
||||||
|
{
|
||||||
|
$this->amount = $amount;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getComment(): ?string
|
public function getComment(): ?string
|
||||||
{
|
{
|
||||||
return $this->comment;
|
return $this->comment;
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ namespace App\Service;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use Symfony\Contracts\Cache\CacheInterface;
|
||||||
|
use Symfony\Contracts\Cache\ItemInterface;
|
||||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||||
@@ -17,7 +19,8 @@ final readonly class PublicHolidayService implements PublicHolidayServiceInterfa
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private HttpClientInterface $client,
|
private HttpClientInterface $client,
|
||||||
private string $holidayUrl
|
private string $holidayUrl,
|
||||||
|
private CacheInterface $cache,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,24 +33,29 @@ final readonly class PublicHolidayService implements PublicHolidayServiceInterfa
|
|||||||
public function getHolidaysDay(string $zone): array
|
public function getHolidaysDay(string $zone): array
|
||||||
{
|
{
|
||||||
$zone = strtolower(trim($zone));
|
$zone = strtolower(trim($zone));
|
||||||
$url = $this->holidayUrl."{$zone}.json";
|
$key = "public_holidays_{$zone}_all";
|
||||||
|
|
||||||
try {
|
return $this->cache->get($key, function (ItemInterface $item) use ($zone): array {
|
||||||
$response = $this->client->request(
|
$item->expiresAfter(30 * 86400);
|
||||||
'GET',
|
$url = $this->holidayUrl."{$zone}.json";
|
||||||
$url
|
|
||||||
);
|
|
||||||
} catch (TransportExceptionInterface) {
|
|
||||||
throw new RuntimeException('Unable to reach public holidays API.');
|
|
||||||
} catch (ClientExceptionInterface) {
|
|
||||||
throw new RuntimeException('Invalid zone provided for public holidays.');
|
|
||||||
} catch (ServerExceptionInterface) {
|
|
||||||
throw new RuntimeException('Public holidays API is temporarily unavailable.');
|
|
||||||
} catch (Throwable) {
|
|
||||||
throw new RuntimeException('Unexpected error while fetching public holidays.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return json_decode($response->getContent(), true);
|
try {
|
||||||
|
$response = $this->client->request(
|
||||||
|
'GET',
|
||||||
|
$url
|
||||||
|
);
|
||||||
|
} catch (TransportExceptionInterface) {
|
||||||
|
throw new RuntimeException('Unable to reach public holidays API.');
|
||||||
|
} catch (ClientExceptionInterface) {
|
||||||
|
throw new RuntimeException('Invalid zone provided for public holidays.');
|
||||||
|
} catch (ServerExceptionInterface) {
|
||||||
|
throw new RuntimeException('Public holidays API is temporarily unavailable.');
|
||||||
|
} catch (Throwable) {
|
||||||
|
throw new RuntimeException('Unexpected error while fetching public holidays.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_decode($response->getContent(), true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,20 +68,25 @@ final readonly class PublicHolidayService implements PublicHolidayServiceInterfa
|
|||||||
{
|
{
|
||||||
$zone = strtolower(trim($zone));
|
$zone = strtolower(trim($zone));
|
||||||
$years = trim($years);
|
$years = trim($years);
|
||||||
$url = $this->holidayUrl."{$zone}/{$years}.json";
|
$key = "public_holidays_{$zone}_{$years}";
|
||||||
|
|
||||||
try {
|
return $this->cache->get($key, function (ItemInterface $item) use ($zone, $years): array {
|
||||||
$response = $this->client->request('GET', $url);
|
$item->expiresAfter(30 * 86400);
|
||||||
} catch (TransportExceptionInterface) {
|
$url = $this->holidayUrl."{$zone}/{$years}.json";
|
||||||
throw new RuntimeException('Unable to reach public holidays API.');
|
|
||||||
} catch (ClientExceptionInterface) {
|
|
||||||
throw new RuntimeException('Invalid zone or year provided for public holidays.');
|
|
||||||
} catch (ServerExceptionInterface) {
|
|
||||||
throw new RuntimeException('Public holidays API is temporarily unavailable.');
|
|
||||||
} catch (Throwable) {
|
|
||||||
throw new RuntimeException('Unexpected error while fetching public holidays.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return json_decode($response->getContent(), true);
|
try {
|
||||||
|
$response = $this->client->request('GET', $url);
|
||||||
|
} catch (TransportExceptionInterface) {
|
||||||
|
throw new RuntimeException('Unable to reach public holidays API.');
|
||||||
|
} catch (ClientExceptionInterface) {
|
||||||
|
throw new RuntimeException('Invalid zone or year provided for public holidays.');
|
||||||
|
} catch (ServerExceptionInterface) {
|
||||||
|
throw new RuntimeException('Public holidays API is temporarily unavailable.');
|
||||||
|
} catch (Throwable) {
|
||||||
|
throw new RuntimeException('Unexpected error while fetching public holidays.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_decode($response->getContent(), true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user