feat(rtt) : enable pay button on closed phase last exercise

This commit is contained in:
2026-05-19 12:17:44 +02:00
parent 9d4a12f6cb
commit a5c75a9129
2 changed files with 18 additions and 1 deletions

View File

@@ -28,7 +28,7 @@
<div class="flex justify-center"> <div class="flex justify-center">
<button <button
class="rounded-md bg-primary-500 px-8 py-2 font-bold text-white hover:bg-primary-600 disabled:opacity-40 disabled:cursor-not-allowed" class="rounded-md bg-primary-500 px-8 py-2 font-bold text-white hover:bg-primary-600 disabled:opacity-40 disabled:cursor-not-allowed"
:disabled="isHistoricalYear" :disabled="isPayDisabled"
@click="openPaymentDrawer" @click="openPaymentDrawer"
> >
+ Payer les RTT + Payer les RTT
@@ -276,6 +276,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { EmployeeRttSummary, EmployeeRttWeekSummary } from '~/services/dto/employee-rtt-summary' import type { EmployeeRttSummary, EmployeeRttWeekSummary } from '~/services/dto/employee-rtt-summary'
import type { ContractPhase } from '~/services/dto/contract-phase'
import AppDrawer from '~/components/AppDrawer.vue' import AppDrawer from '~/components/AppDrawer.vue'
type RttYearOption = { type RttYearOption = {
@@ -288,6 +289,7 @@ const props = defineProps<{
selectedYear: number | null selectedYear: number | null
availableYears: RttYearOption[] availableYears: RttYearOption[]
currentYear: number | null currentYear: number | null
selectedPhase: ContractPhase | null
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
@@ -301,6 +303,20 @@ const isHistoricalYear = computed(() =>
&& props.selectedYear !== props.currentYear && props.selectedYear !== props.currentYear
) )
const isLastExerciseOfPhase = computed(() => {
if (!props.selectedPhase || props.selectedPhase.isCurrent) return false
if (!props.selectedPhase.endDate) return false
const endDate = new Date(`${props.selectedPhase.endDate}T00:00:00`)
const endYear = endDate.getMonth() >= 5
? endDate.getFullYear() + 1
: endDate.getFullYear()
return props.selectedYear === endYear
})
const isPayDisabled = computed(() =>
isHistoricalYear.value && !isLastExerciseOfPhase.value
)
const handleYearChange = (event: Event) => { const handleYearChange = (event: Event) => {
const target = event.target as HTMLSelectElement const target = event.target as HTMLSelectElement
const value = Number(target.value) const value = Number(target.value)

View File

@@ -197,6 +197,7 @@
:selected-year="selectedRttYear" :selected-year="selectedRttYear"
:available-years="availableRttYears" :available-years="availableRttYears"
:current-year="currentRttYear" :current-year="currentRttYear"
:selected-phase="selectedPhase"
@submit-rtt-payment="submitRttPayment" @submit-rtt-payment="submitRttPayment"
@update-selected-year="setSelectedRttYear" @update-selected-year="setSelectedRttYear"
/> />