feat : mettre a jour l'entite shipment et bovin_shipment

This commit is contained in:
2026-02-19 08:42:07 +01:00
parent 7f8f9fc219
commit 892e0c1fe4
4 changed files with 25 additions and 22 deletions

View File

@@ -49,6 +49,7 @@ Ajouter dans le fichier .env du frontend
* fix layout admin * fix layout admin
* Creation page admin listing bovins * Creation page admin listing bovins
* Creation page admin ajout/modification bovins * Creation page admin ajout/modification bovins
* [#331] Mettre à jour l'entité Shipment et bovin_shipment
### Changed ### Changed
### Fixed ### Fixed

View File

@@ -75,7 +75,7 @@ const printReceipt = async () => {
await saveWeight() await saveWeight()
const shipment = shipmentStore.current const shipment = shipmentStore.current
const filename = `${shipment.identificationNumber ?? shipment.id}_${shipment.customer?.name ?? 'client'}_${shipment.licencePlate ?? 'immat'}.pdf` const filename = `${shipment.identificationNumber ?? shipment.id}_${shipment.customer?.label ?? 'client'}_${shipment.licencePlate ?? 'immat'}.pdf`
await printPdf(`/shipments/${shipment.id}/receipt`, filename) await printPdf(`/shipments/${shipment.id}/receipt`, filename)
// Laisse le temps a la boite de dialogue d'impression de s'ouvrir. // Laisse le temps a la boite de dialogue d'impression de s'ouvrir.

View File

@@ -28,9 +28,9 @@
<div>{{ shipment.customer?.name }}</div> <div>{{ shipment.customer?.name }}</div>
<div>{{ shipment.address?.fullAddress }}</div> <div>{{ shipment.address?.fullAddress }}</div>
<div> <div>
<template v-if="formatBovinShipmentLines(shipment).length"> <template v-if="formatShipmentLines(shipment).length">
<div <div
v-for="(line, index) in formatBovinShipmentLines(shipment)" v-for="(line, index) in formatShipmentLines(shipment)"
:key="index" :key="index"
class="leading-5" class="leading-5"
> >
@@ -62,16 +62,17 @@ const formatWeighing = (shipment: ShipmentData) => {
return `${gross - tare} kg` return `${gross - tare} kg`
} }
const formatBovinShipmentLines = (shipment: ShipmentData) => {
if (!shipment.bovinShipments?.length) { const formatShipmentLines = (shipment: ShipmentData) => {
if (!shipment.shipmentType && shipment.nbBovinSend == null) {
return [] return []
} }
return shipment.bovinShipments.map((entry) => {
const label = typeof entry.shipmentType === 'string' const label = typeof shipment.shipmentType === 'string'
? entry.shipmentType ? shipment.shipmentType
: entry.shipmentType?.label : shipment.shipmentType?.label
return `${label ?? ''} : ${entry.nbBovinSend ?? ''}`
}) return [`${label ?? ''} : ${shipment.nbBovinSend ?? ''}`]
} }
const goShipment = (id: number) => { const goShipment = (id: number) => {

View File

@@ -24,12 +24,12 @@
@click="goToShipment(shipment.id)" @click="goToShipment(shipment.id)"
@keydown.enter="goToShipment(shipment.id)" @keydown.enter="goToShipment(shipment.id)"
> >
<div>{{ shipment.customer?.label }}</div> <div>{{ shipment.customer?.name }}</div>
<div>{{ shipment.address?.fullAddress }}</div> <div>{{ shipment.address?.fullAddress }}</div>
<div> <div>
<template v-if="formatBovinShipmentLines(shipment).length"> <template v-if="formatShipmentLines(shipment).length">
<div <div
v-for="(line, index) in formatBovinShipmentLines(shipment)" v-for="(line, index) in formatShipmentLines(shipment)"
:key="index" :key="index"
class="leading-5" class="leading-5"
> >
@@ -55,16 +55,17 @@ const router = useRouter()
const goToShipment = (id: number) => { const goToShipment = (id: number) => {
router.push(`/shipment/${id}`) router.push(`/shipment/${id}`)
} }
const formatBovinShipmentLines = (shipment: ShipmentData) => {
if (!shipment.bovinShipments?.length) { const formatShipmentLines = (shipment: ShipmentData) => {
if (!shipment.shipmentType && shipment.nbBovinSend == null) {
return [] return []
} }
return shipment.bovinShipments.map((entry) => {
const label = typeof entry.shipmentType === 'string' const label = typeof shipment.shipmentType === 'string'
? entry.shipmentType ? shipment.shipmentType
: entry.shipmentType?.label : shipment.shipmentType?.label
return `${label ?? ''} : ${entry.nbBovinSend ?? ''}`
}) return [`${label ?? ''} : ${shipment.nbBovinSend ?? ''}`]
} }
onMounted(async () => { onMounted(async () => {