feat : cause d'entrée bovin + confirmation EDNOTIF asynchrone + historique entrées

- Champ entryCause sur Bovine (enum App\Enum\CauseEntree : Achat/Naissance/PretOuPension)
- Sélecteur "Cause d'entrée" sur le formulaire de saisie (default Achat, required)
- ednotif_confirmed_at sur Bovine : timestamp set par le sync EDNOTIF la première
  fois qu'un bovin remonte dans getInventory. Backfill des bovins existants au
  jour de la migration.
- Inventaire (page + export + stats) filtre les bovins encore "en attente
  EDNOTIF" : ils n'apparaissent qu'une fois confirmés par le sync.
- getter getConfirmedBovineCount sur Reception, exposé en reception:read.
- Tableau Historique full-width sur /entry-exit listant les entrées validées,
  avec filtres de colonnes (numéro, date, fournisseur), compteur Confirmés/Saisis,
  et badge de statut "Confirmée" / "EDNOTIF en attente".
- Tableau récap de l'écran de saisie passé en useDataTableServerState pour
  bénéficier du loading et de la pagination serveur.
- Validation entrée : confirm window obligatoire, message renforcé en cas
  d'écart entre saisis et déclarés.
- Pattern projet "submitted" sur le formulaire d'ajout pour le visuel required.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-29 17:29:46 +02:00
parent c64e0c7100
commit 476502c91c
13 changed files with 376 additions and 96 deletions

View File

@@ -10,7 +10,7 @@
<h1 class="font-bold text-3xl uppercase text-primary-500">Entrée / Sortie</h1>
</div>
<div class="mt-8 mb-16 grid grid-cols-2 gap-8">
<div class="mt-8 grid grid-cols-2 gap-8">
<section>
<h2 class="text-xl font-bold uppercase text-primary-500 mb-4">Entrées en attente</h2>
<UiDataTable
@@ -23,11 +23,14 @@
row-clickable
@row-click="goToEntry"
>
<template #cell-identificationNumber="{ item }">
{{ item.identificationNumber }}
</template>
<template #cell-receptionDate="{ item }">
{{ formatDate(item.receptionDate) }}
</template>
<template #cell-declaredCount="{ item }">
{{ declaredCount(item) }}
{{ item.declaredBovineCount ?? 0 }}
</template>
<template #cell-registeredBovineCount="{ item }">
{{ item.registeredBovineCount ?? 0 }}
@@ -42,6 +45,71 @@
</div>
</section>
</div>
<section class="mt-12 mb-16">
<h2 class="text-xl font-bold uppercase text-primary-500 mb-4">Historique</h2>
<UiDataTable
v-model:page="historyPage"
v-model:per-page="historyPerPage"
:columns="historyColumns"
:items="history"
:total-items="totalHistory"
:loading="historyLoading"
>
<template #header-identificationNumber>
<UiTextInput
v-model="historyFilters.identificationNumber"
placeholder="Numéro"
size="compact"
/>
</template>
<template #header-receptionDate>
<UiDateMaskedInput v-model="historyDateFilter" placeholder="Date" size="compact" />
</template>
<template #header-supplier.name>
<UiTextInput
v-model="historyFilters['supplier.name']"
placeholder="Fournisseur"
size="compact"
/>
</template>
<template #header-registeredBovineCount>
<UiTextInput :model-value="''" placeholder="Saisis" size="compact" disabled />
</template>
<template #header-confirmedBovineCount>
<UiTextInput :model-value="''" placeholder="Confirmés" size="compact" disabled />
</template>
<template #header-status>
<UiTextInput :model-value="''" placeholder="Statut" size="compact" disabled />
</template>
<template #cell-identificationNumber="{ item }">
{{ item.identificationNumber }}
</template>
<template #cell-receptionDate="{ item }">
{{ formatDate(item.receptionDate) }}
</template>
<template #cell-registeredBovineCount="{ item }">
{{ item.registeredBovineCount ?? 0 }}
</template>
<template #cell-confirmedBovineCount="{ item }">
{{ item.confirmedBovineCount ?? 0 }} / {{ item.registeredBovineCount ?? 0 }}
</template>
<template #cell-status="{ item }">
<span
v-if="(item.confirmedBovineCount ?? 0) >= (item.registeredBovineCount ?? 0) && (item.registeredBovineCount ?? 0) > 0"
class="inline-block rounded px-2 py-0.5 text-xs font-semibold bg-green-100 text-green-700"
>
Confirmée
</span>
<span
v-else
class="inline-block rounded px-2 py-0.5 text-xs font-semibold bg-yellow-100 text-yellow-700"
>
EDNOTIF en attente
</span>
</template>
</UiDataTable>
</section>
</div>
</template>
@@ -65,23 +133,66 @@ const {
'entryCompleted': 'false',
'receptionType.code': 'BOVINS'
},
{ initialPerPage: 5 }
)
const {
items: history,
totalItems: totalHistory,
page: historyPage,
perPage: historyPerPage,
filters: historyFilters,
loading: historyLoading,
reload: reloadHistory
} = useDataTableServerState<ReceptionData>(
'receptions',
{
'isValid': 'true',
'entryCompleted': 'true',
'receptionType.code': 'BOVINS',
'identificationNumber': '',
'supplier.name': '',
'receptionDate[after]': '',
'receptionDate[strictly_before]': ''
},
{ initialPerPage: 10 }
)
const addOneDay = (dateString: string): string => {
const [year, month, day] = dateString.split('-').map(Number)
const next = new Date(Date.UTC(year, month - 1, day + 1))
return next.toISOString().slice(0, 10)
}
const historyDateFilter = computed<string>({
get: () => (historyFilters.value['receptionDate[after]'] as string) ?? '',
set: (value: string) => {
if (!value) {
historyFilters.value['receptionDate[after]'] = ''
historyFilters.value['receptionDate[strictly_before]'] = ''
return
}
historyFilters.value['receptionDate[after]'] = value
historyFilters.value['receptionDate[strictly_before]'] = addOneDay(value)
}
})
const entryColumns = [
{ key: 'receptionDate', label: 'Date réception', width: '160px' },
{ key: 'supplier.name', label: 'Fournisseur', width: '1.5fr' },
{ key: 'declaredCount', label: 'Bovins déclarés', width: '140px' },
{ key: 'registeredBovineCount', label: 'Bovins saisis', width: '140px' }
{ key: 'identificationNumber', label: 'Numéro', width: '80px' },
{ key: 'receptionDate', label: 'Date', width: '75px' },
{ key: 'supplier.name', label: 'Fournisseur', width: '1fr' },
{ key: 'declaredCount', label: 'Déclarés', width: '85px' },
{ key: 'registeredBovineCount', label: 'Saisis', width: '50px' }
]
const declaredCount = (reception: ReceptionData): number => {
const fromTypes = (reception.bovinesTypes ?? []).reduce((sum: number, bt: any) => {
return sum + (typeof bt.quantity === 'number' ? bt.quantity : 0)
}, 0)
const fromOther = parseInt(reception.bovineDetail ?? '0', 10) || 0
return fromTypes + fromOther
}
const historyColumns = [
{ key: 'identificationNumber', label: 'Numéro', width: '110px' },
{ key: 'receptionDate', label: 'Date', width: '110px' },
{ key: 'supplier.name', label: 'Fournisseur', width: '1fr' },
{ key: 'registeredBovineCount', label: 'Saisis', width: '80px' },
{ key: 'confirmedBovineCount', label: 'Confirmés', width: '110px' },
{ key: 'status', label: 'Statut', width: '170px' }
]
const formatDate = (date: string | null) => {
if (!date) return '—'
@@ -90,9 +201,7 @@ const formatDate = (date: string | null) => {
return d.toLocaleDateString('fr-FR', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit'
year: 'numeric'
})
}
@@ -102,5 +211,6 @@ const goToEntry = (reception: ReceptionData) => {
onMounted(() => {
reload()
reloadHistory()
})
</script>