Compare commits
4 Commits
42c5a3b2d2
...
v0.0.38
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab6de16319 | ||
| 800ab1d432 | |||
|
|
fade51d3ee | ||
| 9ca0a7511b |
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="PhpCSFixerValidationInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
1
.idea/php.xml
generated
1
.idea/php.xml
generated
@@ -15,7 +15,6 @@
|
|||||||
<component name="PhpCSFixer">
|
<component name="PhpCSFixer">
|
||||||
<phpcsfixer_settings>
|
<phpcsfixer_settings>
|
||||||
<PhpCSFixerConfiguration tool_path="$PROJECT_DIR$/vendor/bin/php-cs-fixer" />
|
<PhpCSFixerConfiguration tool_path="$PROJECT_DIR$/vendor/bin/php-cs-fixer" />
|
||||||
<phpcs_fixer_by_interpreter asDefaultInterpreter="true" interpreter_id="990ff521-e6e9-4080-9cc9-228367d597f9" tool_path="\\wsl.localhost\Ubuntu-24.04\home\matte\Ferme\vendor\bin\php-cs-fixer" timeout="30000" />
|
|
||||||
</phpcsfixer_settings>
|
</phpcsfixer_settings>
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpCodeSniffer">
|
<component name="PhpCodeSniffer">
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ Ajouter dans le fichier .env du frontend
|
|||||||
* [#312] Creation administration listing fournisseurs
|
* [#312] Creation administration listing fournisseurs
|
||||||
* [#315] Creation page admin utilisateur
|
* [#315] Creation page admin utilisateur
|
||||||
* [#317] Admin modification creation transporteur
|
* [#317] Admin modification creation transporteur
|
||||||
|
* [#318] Affichage modification reception terminée
|
||||||
|
* [#320] Affichage modification reception terminée suite
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
parameters:
|
parameters:
|
||||||
app.version: '0.0.36'
|
app.version: '0.0.38'
|
||||||
|
|||||||
@@ -123,6 +123,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -144,19 +145,7 @@ import type {VehicleData} from '~/services/dto/vehicle-data'
|
|||||||
import {getVehicleList} from '~/services/vehicle'
|
import {getVehicleList} from '~/services/vehicle'
|
||||||
import {RECEPTION_TYPE_CODES, SUPLLIER_CODE} from "~/utils/constants";
|
import {RECEPTION_TYPE_CODES, SUPLLIER_CODE} from "~/utils/constants";
|
||||||
import {deleteReceptionBovine, getReceptionBovineList} from "~/services/reception-bovine";
|
import {deleteReceptionBovine, getReceptionBovineList} from "~/services/reception-bovine";
|
||||||
|
import type {ReceptionFormData} from "~/services/dto/reception-data";
|
||||||
type ReceptionFormData = {
|
|
||||||
licensePlate: string
|
|
||||||
receptionDate: string
|
|
||||||
receptionTypeId: string
|
|
||||||
userId: string
|
|
||||||
supplierId: string
|
|
||||||
addressId: string
|
|
||||||
truckId: string
|
|
||||||
carrierId: string
|
|
||||||
driverId: string
|
|
||||||
vehicleId: string
|
|
||||||
}
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const receptionStore = useReceptionStore()
|
const receptionStore = useReceptionStore()
|
||||||
|
|||||||
183
frontend/components/reception/update-bovin.vue
Normal file
183
frontend/components/reception/update-bovin.vue
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
<template>
|
||||||
|
<form @submit.prevent="validate">
|
||||||
|
<div
|
||||||
|
class="flex flex-col items-center gap-16">
|
||||||
|
<div
|
||||||
|
class="flex flex-row gap-6 items-center">
|
||||||
|
<div
|
||||||
|
v-for="type in bovineType"
|
||||||
|
:key="type.id"
|
||||||
|
class="flex flex-row mb-2 gap-6 ">
|
||||||
|
<UiNumberInput
|
||||||
|
:label="type.label"
|
||||||
|
:code="type.code"
|
||||||
|
v-model="bovineQuantities[String(type.id)]"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
:placeholder="0"
|
||||||
|
:min="0"
|
||||||
|
:max="10"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class=" flex flex-row mb-2 gap-6">
|
||||||
|
<UiNumberInput
|
||||||
|
label="Autres"
|
||||||
|
v-model="otherQuantity"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
>Valider
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type {BovineTypeData} from "~/services/dto/bovine-type-data";
|
||||||
|
import {getBovineTypeList} from "~/services/bovine-type";
|
||||||
|
import {
|
||||||
|
createReceptionBovine,
|
||||||
|
deleteReceptionBovine,
|
||||||
|
getReceptionBovineList,
|
||||||
|
updateReceptionBovine
|
||||||
|
} from "~/services/reception-bovine";
|
||||||
|
import {computed, onMounted, reactive, ref, watch} from "vue";
|
||||||
|
import {getReception, updateReception} from "~/services/reception";
|
||||||
|
const toast = useToast()
|
||||||
|
const isLoadingBovineType = ref(false)
|
||||||
|
const bovineType = ref<BovineTypeData[]>([])
|
||||||
|
const bovineQuantities = reactive<Record<string, number | null>>({})
|
||||||
|
const otherQuantity = ref<number | null>(0)
|
||||||
|
const auth = useAuthStore()
|
||||||
|
const props = defineProps<{
|
||||||
|
idReception: number
|
||||||
|
}>()
|
||||||
|
const receptionId = props.idReception
|
||||||
|
const reception = await getReception(receptionId)
|
||||||
|
|
||||||
|
const receptionIri = computed(() =>
|
||||||
|
receptionId ? `/api/receptions/${receptionId}` : null
|
||||||
|
)
|
||||||
|
const totalBovines = computed(() => {
|
||||||
|
const base = Object.values(bovineQuantities).reduce((sum, value) => {
|
||||||
|
return sum + (value ?? 0)
|
||||||
|
}, 0)
|
||||||
|
return base + (otherQuantity.value ?? 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
const loadBovineType = async () => {
|
||||||
|
isLoadingBovineType.value = true
|
||||||
|
try {
|
||||||
|
bovineType.value = await getBovineTypeList()
|
||||||
|
} finally {
|
||||||
|
isLoadingBovineType.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadBovineType()
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => receptionId,
|
||||||
|
async (id) => {
|
||||||
|
if (!id || !receptionIri.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectionMap: Record<string, number | null> = {}
|
||||||
|
for (const type of bovineType.value) {
|
||||||
|
selectionMap[String(type.id)] = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const existing = await getReceptionBovineList(receptionIri.value)
|
||||||
|
for (const selection of existing) {
|
||||||
|
const bovineTypeId = String(selection.bovineType.id)
|
||||||
|
selectionMap[bovineTypeId] = selection.quantity ?? 0
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key of Object.keys(bovineQuantities)) {
|
||||||
|
delete bovineQuantities[key]
|
||||||
|
}
|
||||||
|
Object.assign(bovineQuantities, selectionMap)
|
||||||
|
|
||||||
|
const existingOther = await reception.bovineDetail
|
||||||
|
const parsedOther =
|
||||||
|
typeof existingOther === 'string' && existingOther.trim() !== ''
|
||||||
|
? Number(existingOther)
|
||||||
|
: 0
|
||||||
|
otherQuantity.value = Number.isFinite(parsedOther) ? parsedOther : 0
|
||||||
|
},
|
||||||
|
{immediate: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
async function syncBovineSelections(receptionIri: string) {
|
||||||
|
const existing = await getReceptionBovineList(receptionIri)
|
||||||
|
const existingMap = new Map<string, { id: number; quantity: number | null }>()
|
||||||
|
|
||||||
|
for (const selection of existing) {
|
||||||
|
const bovineTypeId = String(selection.bovineType.id)
|
||||||
|
existingMap.set(bovineTypeId, {
|
||||||
|
id: selection.id,
|
||||||
|
quantity: selection.quantity ?? 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprime les entrées supprimées ou modifiées
|
||||||
|
for (const [bovineTypeId, entry] of existingMap.entries()) {
|
||||||
|
const selectedQuantity = bovineQuantities[bovineTypeId] ?? 0
|
||||||
|
if (!selectedQuantity) {
|
||||||
|
await deleteReceptionBovine(entry.id)
|
||||||
|
existingMap.delete(bovineTypeId)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedQuantity !== entry.quantity) {
|
||||||
|
await updateReceptionBovine(entry.id, {quantity: selectedQuantity})
|
||||||
|
existingMap.set(bovineTypeId, {
|
||||||
|
id: entry.id,
|
||||||
|
quantity: selectedQuantity
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crée les entrées manquantes
|
||||||
|
for (const [bovineTypeId, quantity] of Object.entries(bovineQuantities)) {
|
||||||
|
if (!quantity) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (existingMap.has(bovineTypeId)) {
|
||||||
|
// Déjà à jour
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
await createReceptionBovine({
|
||||||
|
reception: receptionIri,
|
||||||
|
bovineType: `/api/bovine_types/${bovineTypeId}`,
|
||||||
|
quantity
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function validate() {
|
||||||
|
// @TODO Ajouter un composable pour le toaster qui gère les key i18n
|
||||||
|
if (totalBovines.value > 52) {
|
||||||
|
toast.error({
|
||||||
|
title: 'Erreur',
|
||||||
|
message: ('Le total des bovins ne peut pas dépasser 52.')
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await syncBovineSelections(receptionIri.value)
|
||||||
|
|
||||||
|
await updateReception(receptionId, {
|
||||||
|
merchandiseType: null,
|
||||||
|
merchandiseDetail: null,
|
||||||
|
bovineDetail: otherQuantity.value ? String(otherQuantity.value) : null,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
257
frontend/components/reception/update-merchandise.vue
Normal file
257
frontend/components/reception/update-merchandise.vue
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
<template>
|
||||||
|
<form @submit.prevent="validate">
|
||||||
|
<div class="flex flex-col items-center gap-16">
|
||||||
|
<div
|
||||||
|
class="flex flex-col gap-16 items-center w-full">
|
||||||
|
<UiTextInput
|
||||||
|
id="merchandise-type"
|
||||||
|
v-model="selectedMerchandiseTypeId"
|
||||||
|
label="Type de marchandises"
|
||||||
|
:value="reception.merchandiseType?.label"
|
||||||
|
wrapper-class="w-[550px]"
|
||||||
|
:disabled="true"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-if="merchandiseTypeId && isAutres"
|
||||||
|
class="flex flex-col w-full max-w-[550px]"
|
||||||
|
>
|
||||||
|
<UiTextInput
|
||||||
|
id="merchandise-detail"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
v-model="merchandiseDetail"
|
||||||
|
label="Préciser"
|
||||||
|
placeholder="Précisions complémentaires"
|
||||||
|
:maxlength="255"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="merchandiseTypeId && !isGranule"
|
||||||
|
class="flex gap-4 w-[550px] justify-evenly"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="building in buildings"
|
||||||
|
:key="building.id"
|
||||||
|
>
|
||||||
|
<UiCheckbox
|
||||||
|
v-model="selectedBuildingIds"
|
||||||
|
:value="String(building.id)"
|
||||||
|
:label="building.label"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
label-class="text-xl"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="merchandiseTypeId && isGranule"
|
||||||
|
class="flex flex-col gap-10 w-full max-w-[1100px]"
|
||||||
|
>
|
||||||
|
<div class="grid grid-cols-1 gap-10 md:grid-cols-4">
|
||||||
|
<div v-for="type in pelletTypes" :key="type.id" class="flex flex-col gap-4">
|
||||||
|
<p class="font-bold uppercase">{{ type.label }}</p>
|
||||||
|
<div
|
||||||
|
v-for="building in buildings"
|
||||||
|
:key="building.id"
|
||||||
|
class="flex items-center gap-2 text-lg"
|
||||||
|
>
|
||||||
|
<UiCheckbox
|
||||||
|
v-model="selectedPelletBuildingIds[String(type.id)]"
|
||||||
|
:value="String(building.id)"
|
||||||
|
:label="building.label"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
label-class="text-lg"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
>Valider
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {computed, onMounted, ref} from 'vue'
|
||||||
|
import {getBuildingList} from '~/services/building'
|
||||||
|
import {getMerchandiseTypeList} from '~/services/merchandise-type'
|
||||||
|
import type {MerchandiseTypeData} from '~/services/dto/merchandise-type-data'
|
||||||
|
import type {BuildingData} from '~/services/dto/building-data'
|
||||||
|
import type {PelletTypeData} from '~/services/dto/pellet-type-data'
|
||||||
|
import {getPelletTypeList} from '~/services/pellet-type'
|
||||||
|
import {
|
||||||
|
createReceptionPelletBuilding,
|
||||||
|
deleteReceptionPelletBuilding,
|
||||||
|
getReceptionPelletBuildingList
|
||||||
|
} from '~/services/reception-pellet-building'
|
||||||
|
import {MERCHANDISE_TYPE_CODES} from '~/utils/constants'
|
||||||
|
import {getReception, updateReception} from "~/services/reception";
|
||||||
|
|
||||||
|
const merchandiseTypes = ref<MerchandiseTypeData[]>([])
|
||||||
|
const buildings = ref<BuildingData[]>([])
|
||||||
|
const pelletTypes = ref<PelletTypeData[]>([])
|
||||||
|
const selectedMerchandiseTypeId = ref('')
|
||||||
|
const selectedBuildingIds = ref<string[]>([])
|
||||||
|
const selectedPelletBuildingIds = ref<Record<string, string[]>>({})
|
||||||
|
const merchandiseDetail = ref('')
|
||||||
|
const auth = useAuthStore()
|
||||||
|
const props = defineProps<{
|
||||||
|
idReception: number
|
||||||
|
}>()
|
||||||
|
const receptionId = props.idReception
|
||||||
|
const reception = await getReception(receptionId)
|
||||||
|
const merchandiseTypeId = await reception.receptionType?.id
|
||||||
|
|
||||||
|
// Extrait l'ID d'une relation depuis un IRI ou un objet complet.
|
||||||
|
const getRelationId = (value: unknown): string | null => {
|
||||||
|
if (!value) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
const match = value.match(/\/(\d+)$/)
|
||||||
|
return match ? match[1] : null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'object' && 'id' in value) {
|
||||||
|
const record = value as { id?: number | string }
|
||||||
|
if (typeof record.id === 'number') {
|
||||||
|
return String(record.id)
|
||||||
|
}
|
||||||
|
if (typeof record.id === 'string') {
|
||||||
|
return record.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type de marchandise sélectionné dans le select
|
||||||
|
const selectedMerchandiseType = computed(() =>
|
||||||
|
merchandiseTypes.value.find((type) => String(type.id) === selectedMerchandiseTypeId.value)
|
||||||
|
)
|
||||||
|
// Indique si le type est "Granulé"
|
||||||
|
const isGranule = computed(() => selectedMerchandiseType.value?.code === MERCHANDISE_TYPE_CODES.GRANULE)
|
||||||
|
// Indique si le type est "Autres"
|
||||||
|
const isAutres = computed(() => selectedMerchandiseType.value?.code === MERCHANDISE_TYPE_CODES.AUTRES)
|
||||||
|
|
||||||
|
// Charge les référentiels et hydrate le formulaire depuis la réception
|
||||||
|
onMounted(async () => {
|
||||||
|
const [merchandiseTypeList, buildingList, pelletTypeList] = await Promise.all([
|
||||||
|
getMerchandiseTypeList(),
|
||||||
|
getBuildingList(),
|
||||||
|
getPelletTypeList()
|
||||||
|
])
|
||||||
|
merchandiseTypes.value = merchandiseTypeList
|
||||||
|
buildings.value = buildingList
|
||||||
|
pelletTypes.value = pelletTypeList
|
||||||
|
|
||||||
|
const currentId = reception.merchandiseType?.id
|
||||||
|
if (currentId) {
|
||||||
|
selectedMerchandiseTypeId.value = String(currentId)
|
||||||
|
}
|
||||||
|
merchandiseDetail.value = reception.merchandiseDetail ?? ''
|
||||||
|
|
||||||
|
selectedBuildingIds.value =
|
||||||
|
reception.buildings?.map((building) => String(building.id)) ?? []
|
||||||
|
|
||||||
|
const existingPelletSelections = reception.pelletBuildings ?? []
|
||||||
|
const selectionMap: Record<string, string[]> = {}
|
||||||
|
for (const selection of existingPelletSelections) {
|
||||||
|
// L'API peut renvoyer les relations comme IRI ou comme objets selon le contexte.
|
||||||
|
const pelletTypeId = getRelationId(selection.pelletType)
|
||||||
|
const buildingId = getRelationId(selection.building)
|
||||||
|
if (!pelletTypeId || !buildingId) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (!selectionMap[pelletTypeId]) {
|
||||||
|
selectionMap[pelletTypeId] = []
|
||||||
|
}
|
||||||
|
selectionMap[pelletTypeId].push(buildingId)
|
||||||
|
}
|
||||||
|
for (const pelletType of pelletTypes.value) {
|
||||||
|
const key = String(pelletType.id)
|
||||||
|
if (!selectionMap[key]) {
|
||||||
|
selectionMap[key] = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selectedPelletBuildingIds.value = selectionMap
|
||||||
|
})
|
||||||
|
// Enregistre les sélections et passe à l'étape suivante
|
||||||
|
async function validate() {
|
||||||
|
|
||||||
|
const receptionIri = `/api/receptions/${reception.id}`
|
||||||
|
|
||||||
|
await updateReception(reception.id, {
|
||||||
|
merchandiseDetail: isAutres.value ? merchandiseDetail.value.trim() : null,
|
||||||
|
buildings: isGranule.value
|
||||||
|
? []
|
||||||
|
: selectedBuildingIds.value.map((id) => `/api/buildings/${id}`),
|
||||||
|
bovineDetail: null,
|
||||||
|
bovinesTypes: null,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (isGranule.value) {
|
||||||
|
await syncPelletSelections(receptionIri)
|
||||||
|
} else {
|
||||||
|
await clearPelletSelections(receptionIri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprime toutes les associations granulés/bâtiments existantes
|
||||||
|
async function clearPelletSelections(receptionIri: string) {
|
||||||
|
const existing = await getReceptionPelletBuildingList(receptionIri)
|
||||||
|
for (const selection of existing) {
|
||||||
|
await deleteReceptionPelletBuilding(selection.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Synchronise les associations granulés/bâtiments avec l'état du formulaire
|
||||||
|
async function syncPelletSelections(receptionIri: string) {
|
||||||
|
const existing = await getReceptionPelletBuildingList(receptionIri)
|
||||||
|
const existingMap = new Map<string, number>()
|
||||||
|
for (const selection of existing) {
|
||||||
|
// Construit la table de correspondance avec des IDs normalisés pour éviter les doublons.
|
||||||
|
const pelletTypeId = getRelationId(selection.pelletType)
|
||||||
|
const buildingId = getRelationId(selection.building)
|
||||||
|
if (!pelletTypeId || !buildingId) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const key = `${pelletTypeId}:${buildingId}`
|
||||||
|
existingMap.set(key, selection.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
const desiredEntries: Array<{ pelletTypeId: string; buildingId: string }> = []
|
||||||
|
for (const [pelletTypeId, buildingIds] of Object.entries(selectedPelletBuildingIds.value)) {
|
||||||
|
for (const buildingId of buildingIds) {
|
||||||
|
desiredEntries.push({pelletTypeId, buildingId})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const desiredKeys = new Set(desiredEntries.map(
|
||||||
|
(entry) => `${entry.pelletTypeId}:${entry.buildingId}`
|
||||||
|
))
|
||||||
|
|
||||||
|
for (const [key, id] of existingMap.entries()) {
|
||||||
|
if (!desiredKeys.has(key)) {
|
||||||
|
await deleteReceptionPelletBuilding(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const entry of desiredEntries) {
|
||||||
|
const key = `${entry.pelletTypeId}:${entry.buildingId}`
|
||||||
|
if (!existingMap.has(key)) {
|
||||||
|
await createReceptionPelletBuilding({
|
||||||
|
reception: receptionIri,
|
||||||
|
pelletType: `/api/pellet_types/${entry.pelletTypeId}`,
|
||||||
|
building: `/api/buildings/${entry.buildingId}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
74
frontend/components/reception/update-weight.vue
Normal file
74
frontend/components/reception/update-weight.vue
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<template>
|
||||||
|
<form @submit.prevent="validate">
|
||||||
|
|
||||||
|
<div class="grid grid-cols-2 gap-x-40 gap-y-8 mb-16">
|
||||||
|
<UiNumberInput
|
||||||
|
label="Pesée à vide"
|
||||||
|
v-model="form.weights[0].weight"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
:min="0"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<UiNumberInput
|
||||||
|
label="Pesée à plein"
|
||||||
|
v-model="form.weights[1].weight"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
:min="0"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
>
|
||||||
|
Valider
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type {ReceptionFormWeight} from '~/services/dto/reception-data'
|
||||||
|
import { getReception } from '~/services/reception'
|
||||||
|
import {updateWeight} from "~/services/weight";
|
||||||
|
import {useAuthStore} from "~/stores/auth";
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
idReception: number
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const idReception = props.idReception
|
||||||
|
const auth = useAuthStore()
|
||||||
|
|
||||||
|
const form = reactive({
|
||||||
|
weights: [
|
||||||
|
{ id: 0, type: 'tare' as const, weight: 0 },
|
||||||
|
{ id: 0, type: 'gross' as const, weight: 0 }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
const hydrateFromReception = (reception: ReceptionFormWeight) => {
|
||||||
|
const tare = reception.weights.find(weight => weight.type === 'tare')
|
||||||
|
const gross = reception.weights.find(weight => weight.type === 'gross')
|
||||||
|
|
||||||
|
if (tare) form.weights[0] = { ...tare }
|
||||||
|
if (gross) form.weights[1] = { ...gross }
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const reception = await getReception(idReception)
|
||||||
|
hydrateFromReception(reception)
|
||||||
|
})
|
||||||
|
|
||||||
|
async function validate() {
|
||||||
|
|
||||||
|
for (const weight of form.weights) {
|
||||||
|
if (weight.id) {
|
||||||
|
await updateWeight(weight.id, {weight: weight.weight})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -12,7 +12,10 @@
|
|||||||
"fetch": "Impossible de récupérer la réception.",
|
"fetch": "Impossible de récupérer la réception.",
|
||||||
"create": "Impossible de créer la réception.",
|
"create": "Impossible de créer la réception.",
|
||||||
"update": "Impossible de mettre à jour la réception.",
|
"update": "Impossible de mettre à jour la réception.",
|
||||||
"weigh": "Impossible de récupérer la pesée."
|
"weight": "Impossible de récupérer la pesée."
|
||||||
|
},
|
||||||
|
"weight": {
|
||||||
|
"update": "Impossible de mettre à jour la pesée"
|
||||||
},
|
},
|
||||||
"receptionType": {
|
"receptionType": {
|
||||||
"list": "Impossible de récupérer la liste des types de réception."
|
"list": "Impossible de récupérer la liste des types de réception."
|
||||||
@@ -79,6 +82,9 @@
|
|||||||
"carrier": {
|
"carrier": {
|
||||||
"update": "Transporteur mis à jour",
|
"update": "Transporteur mis à jour",
|
||||||
"create": "Transporteur créé"
|
"create": "Transporteur créé"
|
||||||
|
},
|
||||||
|
"weight": {
|
||||||
|
"update": "Pesée mis à jour"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-2 items-start gap-y-8 gap-x-40 mb-16">
|
<div class="grid grid-cols-2 items-start gap-y-8 gap-x-40 mb-16">
|
||||||
|
|
||||||
<UiTextInput
|
<UiTextInput
|
||||||
label = "nom du fournisseur"
|
label = "nom du fournisseur"
|
||||||
id="carrier-name"
|
id="carrier-name"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
class="grid grid-cols-6 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t border-slate-200"
|
class="grid grid-cols-6 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t border-slate-200"
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
@click="goToReception(reception.id)"
|
||||||
>
|
>
|
||||||
<div>{{ reception.identificationNumber}}</div>
|
<div>{{ reception.identificationNumber}}</div>
|
||||||
<div>{{ reception.receptionDate}}</div>
|
<div>{{ reception.receptionDate}}</div>
|
||||||
@@ -47,6 +48,10 @@ const formatWeighing = (reception: ReceptionData, type: 'gross' | 'tare') => {
|
|||||||
return `${entry.weight} kg`
|
return `${entry.weight} kg`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const goToReception = (id: number) => {
|
||||||
|
router.push(`/reception/update/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
receptionList.value = await getReceptionList(true)
|
receptionList.value = await getReceptionList(true)
|
||||||
})
|
})
|
||||||
|
|||||||
546
frontend/pages/reception/update/[[id]].vue
Normal file
546
frontend/pages/reception/update/[[id]].vue
Normal file
@@ -0,0 +1,546 @@
|
|||||||
|
<template>
|
||||||
|
|
||||||
|
<form @submit.prevent="validate">
|
||||||
|
<div class="flex items-center justify-between mt-8 mb-8 ">
|
||||||
|
<h1 class="font-bold text-5xl uppercase">Réception {{receptionLoad?.identificationNumber}}</h1>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px] justify-self-end"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
>Enregistrer
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-2 items-start gap-y-8 gap-x-40 mb-16">
|
||||||
|
<!-- Nom de l'utilisateur -->
|
||||||
|
<UiSelect
|
||||||
|
id="reception-user"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
v-model="form.userId"
|
||||||
|
label="Nom de l'utilisateur"
|
||||||
|
:options="users.map((user) => ({
|
||||||
|
value: String(user.id),
|
||||||
|
label: user.username
|
||||||
|
}))"
|
||||||
|
:loading="isLoadingUsers"
|
||||||
|
wrapper-class="col-start-1 row-start-1"
|
||||||
|
/>
|
||||||
|
<!-- Date de réception -->
|
||||||
|
<UiDateInput
|
||||||
|
id="reception-date"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
v-model="form.receptionDate"
|
||||||
|
label="Date de réception"
|
||||||
|
wrapper-class="col-start-1 row-start-2"
|
||||||
|
/>
|
||||||
|
<!-- Fournisseur -->
|
||||||
|
<UiSelect
|
||||||
|
id="reception-supplier"
|
||||||
|
v-model="form.supplierId"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
label="Fournisseur"
|
||||||
|
:options="suppliers.map((supplier) => ({
|
||||||
|
value: String(supplier.id),
|
||||||
|
label: supplier.name
|
||||||
|
}))"
|
||||||
|
:loading="isLoadingSuppliers"
|
||||||
|
wrapper-class="col-start-1 row-start-3"
|
||||||
|
/>
|
||||||
|
<!-- Adresse fournisseur -->
|
||||||
|
<UiSelect
|
||||||
|
id="reception-address"
|
||||||
|
v-model="form.addressId"
|
||||||
|
label="Adresse"
|
||||||
|
:options="supplierAddresses.map((address) => ({
|
||||||
|
value: String(address.id),
|
||||||
|
label: address.fullAddress
|
||||||
|
}))"
|
||||||
|
:disabled="(isLoadingSuppliers || supplierAddresses.length === 0) && !auth.isAdmin"
|
||||||
|
wrapper-class="col-start-1 row-start-4"
|
||||||
|
/>
|
||||||
|
<!-- Camion -->
|
||||||
|
<UiSelect
|
||||||
|
id="reception-truck"
|
||||||
|
v-model="form.truckId"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
label="Camion"
|
||||||
|
:options="trucks.map((truck) => ({
|
||||||
|
value: String(truck.id),
|
||||||
|
label: truck.name
|
||||||
|
}))"
|
||||||
|
:loading="isLoadingTrucks"
|
||||||
|
wrapper-class="col-start-2 row-start-1"
|
||||||
|
/>
|
||||||
|
<!-- Transporteur -->
|
||||||
|
<UiSelect
|
||||||
|
id="reception-carrier"
|
||||||
|
v-model="form.carrierId"
|
||||||
|
label="Transporteur"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
:options="carriers.map((carrier) => ({
|
||||||
|
value: String(carrier.id),
|
||||||
|
label: carrier.name
|
||||||
|
}))"
|
||||||
|
:loading="isLoadingCarriers"
|
||||||
|
select-class="h-[34px]"
|
||||||
|
wrapper-class="col-start-2 row-start-2"
|
||||||
|
/>
|
||||||
|
<!-- Chauffeur (LIOT) -->
|
||||||
|
<UiSelect
|
||||||
|
id="reception-driver"
|
||||||
|
v-model="form.driverId"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
label="Nom du chauffeur si LIOT"
|
||||||
|
:options="filteredDrivers.map((driver) => ({
|
||||||
|
value: String(driver.id),
|
||||||
|
label: driver.name
|
||||||
|
}))"
|
||||||
|
:loading="isLoadingDrivers"
|
||||||
|
wrapper-class="col-start-2 row-start-3"
|
||||||
|
/>
|
||||||
|
<!-- Plaque d'immatriculation -->
|
||||||
|
<div v-if="!isLiotCarrier" class="col-start-2 row-start-4">
|
||||||
|
<UiLicensePlateInput
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
v-model="form.licensePlate"
|
||||||
|
v-model:allowAny="allowAnyLicensePlate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<!-- Immatriculation (LIOT) -->
|
||||||
|
<UiSelect
|
||||||
|
v-if="isLiotCarrier"
|
||||||
|
id="reception-vehicle"
|
||||||
|
v-model="form.vehicleId"
|
||||||
|
label="Immatriculation"
|
||||||
|
:options="filteredVehicles.map((vehicle) => ({
|
||||||
|
value: String(vehicle.id),
|
||||||
|
label: vehicle.plate
|
||||||
|
}))"
|
||||||
|
:loading="isLoadingVehicles"
|
||||||
|
:disabled="(isLoadingVehicles || filteredVehicles.length === 0) && !auth.isAdmin"
|
||||||
|
wrapper-class="col-start-2 row-start-4"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-2 items-start gap-y-8 gap-x-40 mb-16">
|
||||||
|
<h1 class="font-bold text-5xl uppercase col-start-1 row-start-1" @click="isBtWeight = true" >pesées</h1>
|
||||||
|
<h1 class="font-bold text-5xl uppercase col-start-2 row-start-1" @click="isBtWeight = false">{{isMerchandise ? "Marchandises" : "Bovins"}}</h1>
|
||||||
|
</div>
|
||||||
|
<update-weight
|
||||||
|
v-if="isBtWeight"
|
||||||
|
:idReception="idReception"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<update-merchandise
|
||||||
|
v-else-if="isMerchandise"
|
||||||
|
:idReception="idReception"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<update-bovin
|
||||||
|
v-else
|
||||||
|
:idReception="idReception"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {useReceptionStore} from '~/stores/reception'
|
||||||
|
import type {UserData} from '~/services/dto/user-data'
|
||||||
|
import {getUsers} from '~/services/auth'
|
||||||
|
import {useAuthStore} from '~/stores/auth'
|
||||||
|
import type {SupplierData} from '~/services/dto/supplier-data'
|
||||||
|
import {getSupplierList} from '~/services/supplier'
|
||||||
|
import type {TruckData} from '~/services/dto/truck-data'
|
||||||
|
import {getTruckList} from '~/services/truck'
|
||||||
|
import type {CarrierData} from '~/services/dto/carrier-data'
|
||||||
|
import {getCarrierList} from '~/services/carrier'
|
||||||
|
import type {DriverData} from '~/services/dto/driver-data'
|
||||||
|
import {getDriverList} from '~/services/driver'
|
||||||
|
import type {VehicleData} from '~/services/dto/vehicle-data'
|
||||||
|
import {getVehicleList} from '~/services/vehicle'
|
||||||
|
import {SUPLLIER_CODE} from "~/utils/constants";
|
||||||
|
import {deleteReceptionBovine, getReceptionBovineList} from "~/services/reception-bovine";
|
||||||
|
import type {ReceptionData, ReceptionFormData} from "~/services/dto/reception-data";
|
||||||
|
import {getReception} from "~/services/reception";
|
||||||
|
import UpdateWeight from "~/components/reception/update-weight.vue";
|
||||||
|
import UpdateMerchandise from "~/components/reception/update-merchandise.vue";
|
||||||
|
import UpdateBovin from "~/components/reception/update-bovin.vue";
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const receptionStore = useReceptionStore()
|
||||||
|
const form = reactive<ReceptionFormData>({
|
||||||
|
licensePlate: '',
|
||||||
|
receptionDate: new Date().toISOString().slice(0, 10),
|
||||||
|
receptionTypeId: '',
|
||||||
|
userId: '',
|
||||||
|
supplierId: '',
|
||||||
|
addressId: '',
|
||||||
|
truckId: '',
|
||||||
|
carrierId: '',
|
||||||
|
driverId: '',
|
||||||
|
vehicleId: ''
|
||||||
|
})
|
||||||
|
const allowAnyLicensePlate = ref(false)
|
||||||
|
const isLoading = ref(false)
|
||||||
|
const users = ref<UserData[]>([])
|
||||||
|
const isLoadingUsers = ref(false)
|
||||||
|
const suppliers = ref<SupplierData[]>([])
|
||||||
|
const isLoadingSuppliers = ref(false)
|
||||||
|
const trucks = ref<TruckData[]>([])
|
||||||
|
const isLoadingTrucks = ref(false)
|
||||||
|
const carriers = ref<CarrierData[]>([])
|
||||||
|
const isLoadingCarriers = ref(false)
|
||||||
|
const drivers = ref<DriverData[]>([])
|
||||||
|
const isLoadingDrivers = ref(false)
|
||||||
|
const vehicles = ref<VehicleData[]>([])
|
||||||
|
const isLoadingVehicles = ref(false)
|
||||||
|
const authStore = useAuthStore()
|
||||||
|
|
||||||
|
// Empêche les watchers de reset des champs pendant le remplissage initial
|
||||||
|
const isHydrating = ref(false)
|
||||||
|
const route = useRoute()
|
||||||
|
const idReception = Number(route.params.id)
|
||||||
|
const receptionLoad = await getReception(idReception)
|
||||||
|
const receptionType = receptionLoad.receptionType
|
||||||
|
const auth = useAuthStore()
|
||||||
|
const isBtWeight = ref(true)
|
||||||
|
const isMerchandise = ref(receptionType.code === 'MARCHANDISES')
|
||||||
|
|
||||||
|
// Transporteur sélectionné dans le formulaire
|
||||||
|
const selectedCarrier = computed(() =>
|
||||||
|
carriers.value.find((carrier) => String(carrier.id) === form.carrierId) ?? null
|
||||||
|
)
|
||||||
|
// Indique si le transporteur est LIOT
|
||||||
|
const isLiotCarrier = computed(() => selectedCarrier.value?.code === SUPLLIER_CODE.LIOT)
|
||||||
|
// Adresses disponibles pour le fournisseur sélectionné
|
||||||
|
const supplierAddresses = computed(() => {
|
||||||
|
const supplierId = Number(form.supplierId)
|
||||||
|
if (!Number.isFinite(supplierId)) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return suppliers.value.find((supplier) => supplier.id === supplierId)?.addresses ?? []
|
||||||
|
})
|
||||||
|
// Chauffeurs filtrés par transporteur (LIOT)
|
||||||
|
const filteredDrivers = computed<DriverData[]>(() => {
|
||||||
|
if (!form.carrierId) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return drivers.value.filter((driver) => String(driver.carrier?.id) === form.carrierId)
|
||||||
|
})
|
||||||
|
// Véhicules filtrés par transporteur + type de camion
|
||||||
|
const filteredVehicles = computed<VehicleData[]>(() => {
|
||||||
|
if (!form.carrierId) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return vehicles.value.filter(
|
||||||
|
(vehicle) =>
|
||||||
|
String(vehicle.carrier?.id) === form.carrierId &&
|
||||||
|
(!form.truckId || String(vehicle.truck?.id) === form.truckId)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Supprime les données bovines si on change de type de réception
|
||||||
|
const clearReceptionBovines = async (receptionIri: string) => {
|
||||||
|
const existing = await getReceptionBovineList(receptionIri)
|
||||||
|
for (const selection of existing) {
|
||||||
|
await deleteReceptionBovine(selection.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const hydrateFromUser = (reception: ReceptionData | null)=> {
|
||||||
|
if (!reception) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isHydrating.value = true
|
||||||
|
form.licensePlate = reception?.licensePlate ?? ''
|
||||||
|
form.receptionDate = reception?.receptionDate ?? new Date().toISOString().slice(0, 10)
|
||||||
|
form.userId = reception?.user?.id
|
||||||
|
? String(reception.user.id)
|
||||||
|
: form.userId
|
||||||
|
form.supplierId = reception?.supplier?.id
|
||||||
|
? String(reception.supplier.id)
|
||||||
|
: ''
|
||||||
|
form.addressId = reception?.address?.id
|
||||||
|
? String(reception.address.id)
|
||||||
|
: ''
|
||||||
|
form.truckId = reception?.truck?.id
|
||||||
|
? String(reception.truck.id)
|
||||||
|
: ''
|
||||||
|
form.carrierId = reception?.carrier?.id
|
||||||
|
? String(reception.carrier.id)
|
||||||
|
: ''
|
||||||
|
form.driverId = reception?.driver?.id
|
||||||
|
? String(reception.driver.id)
|
||||||
|
: ''
|
||||||
|
isHydrating.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => idReception,
|
||||||
|
async (id) => {
|
||||||
|
if (id === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isLoading.value = true
|
||||||
|
try {
|
||||||
|
const user = await getReception(id)
|
||||||
|
hydrateFromUser(user)
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{immediate: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Charge la liste des users pour le select
|
||||||
|
const loadUsers = async () => {
|
||||||
|
isLoadingUsers.value = true
|
||||||
|
try {
|
||||||
|
users.value = await getUsers()
|
||||||
|
} finally {
|
||||||
|
isLoadingUsers.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charge la liste des fournisseurs pour le select
|
||||||
|
const loadSuppliers = async () => {
|
||||||
|
isLoadingSuppliers.value = true
|
||||||
|
try {
|
||||||
|
suppliers.value = await getSupplierList()
|
||||||
|
} finally {
|
||||||
|
isLoadingSuppliers.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charge la liste des camions pour le select
|
||||||
|
const loadTrucks = async () => {
|
||||||
|
isLoadingTrucks.value = true
|
||||||
|
try {
|
||||||
|
trucks.value = await getTruckList()
|
||||||
|
} finally {
|
||||||
|
isLoadingTrucks.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charge la liste des transporteurs pour le select
|
||||||
|
const loadCarriers = async () => {
|
||||||
|
isLoadingCarriers.value = true
|
||||||
|
try {
|
||||||
|
carriers.value = await getCarrierList()
|
||||||
|
} finally {
|
||||||
|
isLoadingCarriers.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charge la liste des chauffeurs pour le select
|
||||||
|
const loadDrivers = async () => {
|
||||||
|
isLoadingDrivers.value = true
|
||||||
|
try {
|
||||||
|
drivers.value = await getDriverList()
|
||||||
|
} finally {
|
||||||
|
isLoadingDrivers.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charge la liste des véhicules pour le select
|
||||||
|
const loadVehicles = async () => {
|
||||||
|
isLoadingVehicles.value = true
|
||||||
|
try {
|
||||||
|
vehicles.value = await getVehicleList()
|
||||||
|
} finally {
|
||||||
|
isLoadingVehicles.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// On met le user connecté par défaut dans le select
|
||||||
|
const setDefaultUser = () => {
|
||||||
|
if (form.userId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (authStore.user?.id) {
|
||||||
|
form.userId = String(authStore.user.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// On récupère toutes les données des selects au chargement du composant
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadUsers()
|
||||||
|
await loadSuppliers()
|
||||||
|
await loadTrucks()
|
||||||
|
await loadCarriers()
|
||||||
|
await loadDrivers()
|
||||||
|
await loadVehicles()
|
||||||
|
await authStore.ensureSession()
|
||||||
|
setDefaultUser()
|
||||||
|
})
|
||||||
|
|
||||||
|
// Ajuste driver/vehicle quand le transporteur change (logique LIOT)
|
||||||
|
watch(
|
||||||
|
() => [form.supplierId, suppliers.value],
|
||||||
|
() => {
|
||||||
|
if (!form.supplierId) {
|
||||||
|
form.addressId = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!form.addressId && supplierAddresses.value.length === 1) {
|
||||||
|
form.addressId = String(supplierAddresses.value[0].id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!form.addressId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const matches = supplierAddresses.value.some(
|
||||||
|
(address) => String(address.id) === form.addressId
|
||||||
|
)
|
||||||
|
if (!matches) {
|
||||||
|
form.addressId = ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{immediate: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Valide/auto-sélectionne le véhicule selon camion + transporteur (LIOT)
|
||||||
|
watch(
|
||||||
|
() => form.carrierId,
|
||||||
|
() => {
|
||||||
|
if (isHydrating.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!form.carrierId && idReception == null) {
|
||||||
|
form.driverId = ''
|
||||||
|
form.vehicleId = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!isLiotCarrier.value && idReception == null) {
|
||||||
|
form.driverId = ''
|
||||||
|
form.vehicleId = ''
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (filteredDrivers.value.length === 1) {
|
||||||
|
form.driverId = String(filteredDrivers.value[0].id)
|
||||||
|
}
|
||||||
|
if (filteredVehicles.value.length === 1) {
|
||||||
|
form.vehicleId = String(filteredVehicles.value[0].id)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{immediate: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Récupère la plaque depuis le véhicule choisi (LIOT)
|
||||||
|
watch(
|
||||||
|
() => [form.truckId, form.carrierId, vehicles.value],
|
||||||
|
() => {
|
||||||
|
if (!isLiotCarrier.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (filteredVehicles.value.length === 1) {
|
||||||
|
form.vehicleId = String(filteredVehicles.value[0].id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!form.vehicleId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const matches = filteredVehicles.value.some(
|
||||||
|
(vehicle) => String(vehicle.id) === form.vehicleId
|
||||||
|
)
|
||||||
|
if (!matches) {
|
||||||
|
form.vehicleId = ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{immediate: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Auto-renseigne le véhicule si la plaque correspond (LIOT)
|
||||||
|
watch(
|
||||||
|
() => [form.vehicleId, form.carrierId, vehicles.value],
|
||||||
|
() => {
|
||||||
|
if (!isLiotCarrier.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (isHydrating.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const selected = filteredVehicles.value.find(
|
||||||
|
(vehicle) => String(vehicle.id) === form.vehicleId
|
||||||
|
)
|
||||||
|
if (selected) {
|
||||||
|
form.licensePlate = selected.plate
|
||||||
|
allowAnyLicensePlate.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [form.licensePlate, form.carrierId, vehicles.value],
|
||||||
|
() => {
|
||||||
|
if (!isLiotCarrier.value || form.vehicleId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const match = filteredVehicles.value.find(
|
||||||
|
(vehicle) => vehicle.plate === form.licensePlate
|
||||||
|
)
|
||||||
|
if (match) {
|
||||||
|
form.vehicleId = String(match.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Valide le formulaire et crée/met à jour la réception
|
||||||
|
async function validate() {
|
||||||
|
const normalizedLicensePlate = form.licensePlate.trim()
|
||||||
|
const normalizedReceptionDate = form.receptionDate.trim()
|
||||||
|
const normalizedUserId = form.userId.trim()
|
||||||
|
const normalizedSupplierId = form.supplierId.trim()
|
||||||
|
const normalizedAddressId = form.addressId.trim()
|
||||||
|
const normalizedTruckId = form.truckId.trim()
|
||||||
|
const normalizedCarrierId = form.carrierId.trim()
|
||||||
|
const normalizedDriverId = form.driverId.trim()
|
||||||
|
const userIri = normalizedUserId
|
||||||
|
? `/api/users/${normalizedUserId}`
|
||||||
|
: null
|
||||||
|
const supplierIri = normalizedSupplierId
|
||||||
|
? `/api/suppliers/${normalizedSupplierId}`
|
||||||
|
: null
|
||||||
|
const addressIri = normalizedAddressId
|
||||||
|
? `/api/addresses/${normalizedAddressId}`
|
||||||
|
: null
|
||||||
|
const truckIri = normalizedTruckId
|
||||||
|
? `/api/trucks/${normalizedTruckId}`
|
||||||
|
: null
|
||||||
|
const carrierIri = normalizedCarrierId
|
||||||
|
? `/api/carriers/${normalizedCarrierId}`
|
||||||
|
: null
|
||||||
|
const driverIri = normalizedDriverId
|
||||||
|
? `/api/drivers/${normalizedDriverId}`
|
||||||
|
: null
|
||||||
|
|
||||||
|
const basePayload = {
|
||||||
|
licensePlate: normalizedLicensePlate,
|
||||||
|
receptionDate: normalizedReceptionDate,
|
||||||
|
user: userIri,
|
||||||
|
supplier: supplierIri,
|
||||||
|
address: addressIri,
|
||||||
|
truck: truckIri,
|
||||||
|
carrier: carrierIri
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
...basePayload,
|
||||||
|
...(isLiotCarrier.value && driverIri ? {driver: driverIri} : {})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idReception) {
|
||||||
|
const updated = await receptionStore.updateReception(idReception,{
|
||||||
|
...payload
|
||||||
|
})
|
||||||
|
if (updated) {
|
||||||
|
await router.push(`/reception/update/${updated.id}`)
|
||||||
|
}
|
||||||
|
router.push("/reception/finish-reception")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -41,6 +41,14 @@ export interface WeightEntryData {
|
|||||||
weighedAt: string | null
|
weighedAt: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface WeightFormData {
|
||||||
|
id: number
|
||||||
|
weight: number
|
||||||
|
type: 'gross' | 'tare'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type ReceptionPayload = {
|
export type ReceptionPayload = {
|
||||||
licensePlate?: string | null
|
licensePlate?: string | null
|
||||||
receptionDate?: string
|
receptionDate?: string
|
||||||
@@ -59,3 +67,27 @@ export type ReceptionPayload = {
|
|||||||
carrier?: string | null
|
carrier?: string | null
|
||||||
driver?: string | null
|
driver?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ReceptionFormData = {
|
||||||
|
licensePlate: string
|
||||||
|
receptionDate: string
|
||||||
|
receptionTypeId: string
|
||||||
|
userId: string
|
||||||
|
supplierId: string
|
||||||
|
addressId: string
|
||||||
|
truckId: string
|
||||||
|
carrierId: string
|
||||||
|
driverId: string
|
||||||
|
vehicleId: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ReceptionFormWeight = {
|
||||||
|
weights: WeightFormData[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReceptionUpdatePayload {
|
||||||
|
weights: {
|
||||||
|
id: number
|
||||||
|
weight: number
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,5 +16,8 @@ export async function createWeight(payload: WeightPayload) {
|
|||||||
|
|
||||||
export async function updateWeight(id: number, payload: Partial<WeightPayload>) {
|
export async function updateWeight(id: number, payload: Partial<WeightPayload>) {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
return api.patch<WeightEntryData>(`weights/${id}`, payload)
|
return api.patch<WeightEntryData>(`weights/${id}`, payload,{
|
||||||
|
toastErrorKey: 'errors.weight.update',
|
||||||
|
toastSuccessKey: 'success.weight.update'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
2
makefile
2
makefile
@@ -79,7 +79,7 @@ migration-migrate:
|
|||||||
$(SYMFONY_CONSOLE) --no-interaction doctrine:migrations:migrate --allow-no-migration
|
$(SYMFONY_CONSOLE) --no-interaction doctrine:migrations:migrate --allow-no-migration
|
||||||
|
|
||||||
fixtures:
|
fixtures:
|
||||||
$(SYMFONY_CONSOLE) --no-interaction doctrine:fixtures:load
|
$(SYMFONY_CONSOLE) doctrine:fixtures:load
|
||||||
|
|
||||||
# Attention, supprime votre bdd local
|
# Attention, supprime votre bdd local
|
||||||
db-reset:
|
db-reset:
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace DoctrineMigrations;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
|
||||||
*/
|
|
||||||
final class Version20260204101625 extends AbstractMigration
|
|
||||||
{
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('CREATE TABLE bovin_shipment (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, nb_bovin_send INT NOT NULL, shipment_id INT DEFAULT NULL, shipment_type_id INT DEFAULT NULL, PRIMARY KEY (id))');
|
|
||||||
$this->addSql('CREATE INDEX IDX_7049F4507BE036FC ON bovin_shipment (shipment_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_7049F4502EE48A36 ON bovin_shipment (shipment_type_id)');
|
|
||||||
$this->addSql('CREATE TABLE customer (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, label VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY (id))');
|
|
||||||
$this->addSql('CREATE TABLE customer_address (customer_id INT NOT NULL, address_id INT NOT NULL, PRIMARY KEY (customer_id, address_id))');
|
|
||||||
$this->addSql('CREATE INDEX IDX_1193CB3F9395C3F3 ON customer_address (customer_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_1193CB3FF5B7AF75 ON customer_address (address_id)');
|
|
||||||
$this->addSql('CREATE TABLE shipment (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, licence_plate VARCHAR(255) NOT NULL, identification_number VARCHAR(20) DEFAULT NULL, current_step INT DEFAULT 0 NOT NULL, is_valid BOOLEAN NOT NULL, shipment_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, carrier_id INT DEFAULT NULL, vehicle_id INT DEFAULT NULL, truck_id INT DEFAULT NULL, customer_id INT DEFAULT NULL, PRIMARY KEY (id))');
|
|
||||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_2CB20DC347639A5 ON shipment (identification_number)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_2CB20DC21DFC797 ON shipment (carrier_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_2CB20DC545317D1 ON shipment (vehicle_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_2CB20DCC6957CCE ON shipment (truck_id)');
|
|
||||||
$this->addSql('CREATE INDEX IDX_2CB20DC9395C3F3 ON shipment (customer_id)');
|
|
||||||
$this->addSql('CREATE TABLE shipment_type (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, label VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, PRIMARY KEY (id))');
|
|
||||||
$this->addSql('ALTER TABLE bovin_shipment ADD CONSTRAINT FK_7049F4507BE036FC FOREIGN KEY (shipment_id) REFERENCES shipment (id)');
|
|
||||||
$this->addSql('ALTER TABLE bovin_shipment ADD CONSTRAINT FK_7049F4502EE48A36 FOREIGN KEY (shipment_type_id) REFERENCES shipment_type (id)');
|
|
||||||
$this->addSql('ALTER TABLE customer_address ADD CONSTRAINT FK_1193CB3F9395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE CASCADE');
|
|
||||||
$this->addSql('ALTER TABLE customer_address ADD CONSTRAINT FK_1193CB3FF5B7AF75 FOREIGN KEY (address_id) REFERENCES address (id) ON DELETE CASCADE');
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC21DFC797 FOREIGN KEY (carrier_id) REFERENCES carrier (id) NOT DEFERRABLE');
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC545317D1 FOREIGN KEY (vehicle_id) REFERENCES vehicle (id)');
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DCC6957CCE FOREIGN KEY (truck_id) REFERENCES truck (id) NOT DEFERRABLE');
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT FK_2CB20DC9395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('ALTER TABLE bovin_shipment DROP CONSTRAINT FK_7049F4507BE036FC');
|
|
||||||
$this->addSql('ALTER TABLE bovin_shipment DROP CONSTRAINT FK_7049F4502EE48A36');
|
|
||||||
$this->addSql('ALTER TABLE customer_address DROP CONSTRAINT FK_1193CB3F9395C3F3');
|
|
||||||
$this->addSql('ALTER TABLE customer_address DROP CONSTRAINT FK_1193CB3FF5B7AF75');
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC21DFC797');
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC545317D1');
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DCC6957CCE');
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT FK_2CB20DC9395C3F3');
|
|
||||||
$this->addSql('DROP TABLE bovin_shipment');
|
|
||||||
$this->addSql('DROP TABLE customer');
|
|
||||||
$this->addSql('DROP TABLE customer_address');
|
|
||||||
$this->addSql('DROP TABLE shipment');
|
|
||||||
$this->addSql('DROP TABLE shipment_type');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace DoctrineMigrations;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Auto-generated Migration: Please modify to your needs!
|
|
||||||
*/
|
|
||||||
final class Version20260204102423 extends AbstractMigration
|
|
||||||
{
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this up() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP CONSTRAINT fk_2cb20dc545317d1');
|
|
||||||
$this->addSql('DROP INDEX idx_2cb20dc545317d1');
|
|
||||||
$this->addSql('ALTER TABLE shipment DROP vehicle_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD vehicle_id INT DEFAULT NULL');
|
|
||||||
$this->addSql('ALTER TABLE shipment ADD CONSTRAINT fk_2cb20dc545317d1 FOREIGN KEY (vehicle_id) REFERENCES vehicle (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
|
||||||
$this->addSql('CREATE INDEX idx_2cb20dc545317d1 ON shipment (vehicle_id)');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -35,27 +35,27 @@ class Address
|
|||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 120)]
|
#[ORM\Column(length: 120)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
|
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||||
private string $label = '';
|
private string $label = '';
|
||||||
|
|
||||||
#[ORM\Column(length: 180)]
|
#[ORM\Column(length: 180)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
|
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||||
private string $street = '';
|
private string $street = '';
|
||||||
|
|
||||||
#[ORM\Column(name: 'street2', length: 180, nullable: true)]
|
#[ORM\Column(name: 'street2', length: 180, nullable: true)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
|
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||||
private ?string $street2 = null;
|
private ?string $street2 = null;
|
||||||
|
|
||||||
#[ORM\Column(name: 'postal_code', length: 20)]
|
#[ORM\Column(name: 'postal_code', length: 20)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
|
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||||
private string $postalCode = '';
|
private string $postalCode = '';
|
||||||
|
|
||||||
#[ORM\Column(length: 120)]
|
#[ORM\Column(length: 120)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'reception:read', 'customer:read', 'shipment:read'])]
|
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||||
private string $city = '';
|
private string $city = '';
|
||||||
|
|
||||||
#[ORM\Column(name: 'country_code', length: 2)]
|
#[ORM\Column(name: 'country_code', length: 2)]
|
||||||
#[Groups(['address:read', 'supplier:read', 'customer:read'])]
|
#[Groups(['address:read', 'supplier:read'])]
|
||||||
private string $countryCode = '';
|
private string $countryCode = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
|
||||||
|
|
||||||
#[ORM\Entity]
|
|
||||||
#[ORM\Table(name: 'bovin_shipment')]
|
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['bovin-shipment:read']],
|
|
||||||
),
|
|
||||||
new GetCollection(
|
|
||||||
normalizationContext: ['groups' => ['bovin-shipment:read']],
|
|
||||||
),
|
|
||||||
|
|
||||||
// new Get(
|
|
||||||
// uriTemplate: '/receptions/weigh',
|
|
||||||
// openapi: new OpenApiOperation(
|
|
||||||
// summary: 'Fetch the current weight reading',
|
|
||||||
// description: 'Queries the pont-bascule and returns the weight data.',
|
|
||||||
// ),
|
|
||||||
// normalizationContext: ['groups' => ['reception:weigh:read']],
|
|
||||||
// output: PontBasculeReading::class,
|
|
||||||
// provider: ReceptionWeighingProvider::class,
|
|
||||||
// ),
|
|
||||||
// new Get(
|
|
||||||
// uriTemplate: '/receptions/{id}/receipt',
|
|
||||||
// requirements: ['id' => '\d+'],
|
|
||||||
// openapi: new OpenApiOperation(
|
|
||||||
// summary: 'Render a reception receipt',
|
|
||||||
// description: 'Returns a PDF receipt for the reception.',
|
|
||||||
// ),
|
|
||||||
// output: false,
|
|
||||||
// provider: ReceptionReceiptProvider::class,
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
)]
|
|
||||||
class BovinShipment
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment:read', 'bovine-shipment:read'])]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'shipment_types')]
|
|
||||||
#[Groups(['bovine-shipment:read'])]
|
|
||||||
private ?Shipment $shipment = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
|
||||||
#[Groups(['shipment:read', 'bovine-shipment:read'])]
|
|
||||||
private ?ShipmentType $shipmentType = null;
|
|
||||||
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment:read', 'bovine-shipment:read'])]
|
|
||||||
private ?int $nbBovinSend = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShipment(): ?Shipment
|
|
||||||
{
|
|
||||||
return $this->shipment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShipment(?Shipment $shipment): void
|
|
||||||
{
|
|
||||||
$this->shipment = $shipment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShipmentType(): ?ShipmentType
|
|
||||||
{
|
|
||||||
return $this->shipmentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShipmentType(?ShipmentType $shipmentType): void
|
|
||||||
{
|
|
||||||
$this->shipmentType = $shipmentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNbBovinSend(): ?int
|
|
||||||
{
|
|
||||||
return $this->nbBovinSend;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setNbBovinSend(?int $nbBovinSend): void
|
|
||||||
{
|
|
||||||
$this->nbBovinSend = $nbBovinSend;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,11 +26,13 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
new Post(
|
new Post(
|
||||||
normalizationContext: ['groups' => ['carrier:read']],
|
normalizationContext: ['groups' => ['carrier:read']],
|
||||||
denormalizationContext: ['groups' => ['carrier:write']],
|
denormalizationContext: ['groups' => ['carrier:write']],
|
||||||
|
security: "is_granted('ROLE_ADMIN')"
|
||||||
),
|
),
|
||||||
new Patch(
|
new Patch(
|
||||||
requirements: ['id' => '\d+'],
|
requirements: ['id' => '\d+'],
|
||||||
normalizationContext: ['groups' => ['carrier:read']],
|
normalizationContext: ['groups' => ['carrier:read']],
|
||||||
denormalizationContext: ['groups' => ['carrier:write']],
|
denormalizationContext: ['groups' => ['carrier:write']],
|
||||||
|
security: "is_granted('ROLE_ADMIN')"
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
security: "is_granted('ROLE_USER')",
|
security: "is_granted('ROLE_USER')",
|
||||||
@@ -40,15 +42,15 @@ class Carrier
|
|||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read', 'shipment:read'])]
|
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read'])]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 180)]
|
#[ORM\Column(length: 180)]
|
||||||
#[Groups(['carrier:read', 'carrier:write', 'driver:read', 'vehicle:read', 'reception:read', 'shipment:read'])]
|
#[Groups(['carrier:read', 'carrier:write', 'driver:read', 'vehicle:read', 'reception:read'])]
|
||||||
private string $name = '';
|
private string $name = '';
|
||||||
|
|
||||||
#[ORM\Column(length: 30, nullable: true)]
|
#[ORM\Column(length: 30, nullable: true)]
|
||||||
#[Groups(['carrier:read', 'carrier:write', 'driver:read', 'vehicle:read', 'reception:read', 'shipment:read'])]
|
#[Groups(['carrier:read', 'carrier:write', 'driver:read', 'vehicle:read', 'reception:read'])]
|
||||||
private ?string $code = null;
|
private ?string $code = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiProperty;
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
|
||||||
|
|
||||||
#[ORM\Entity]
|
|
||||||
#[ORM\Table(name: 'customer')]
|
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['customer:read']],
|
|
||||||
),
|
|
||||||
new GetCollection(
|
|
||||||
normalizationContext: ['groups' => ['customer:read']],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
security: "is_granted('ROLE_USER')",
|
|
||||||
)]
|
|
||||||
class Customer
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment:read', 'customer:read'])]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
#[Groups(['customer:read', 'shipment:read'])]
|
|
||||||
private ?string $label = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
#[Groups(['customer:read', 'shipment:read'])]
|
|
||||||
private ?string $code = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Collection<int, Address>
|
|
||||||
*/
|
|
||||||
#[ORM\ManyToMany(targetEntity: Address::class, inversedBy: 'customers')]
|
|
||||||
#[ORM\JoinTable(name: 'customer_address')]
|
|
||||||
#[Groups(['customer:read'])]
|
|
||||||
#[ApiProperty(readableLink: true)]
|
|
||||||
private Collection $addresses;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->addresses = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLabel(): ?string
|
|
||||||
{
|
|
||||||
return $this->label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setLabel(?string $label): void
|
|
||||||
{
|
|
||||||
$this->label = $label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCode(): ?string
|
|
||||||
{
|
|
||||||
return $this->code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCode(?string $code): void
|
|
||||||
{
|
|
||||||
$this->code = $code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAddresses(): Collection
|
|
||||||
{
|
|
||||||
return $this->addresses;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAddresses(Collection $addresses): void
|
|
||||||
{
|
|
||||||
$this->addresses = $addresses;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,244 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiProperty;
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
|
||||||
use ApiPlatform\Metadata\Patch;
|
|
||||||
use ApiPlatform\Metadata\Post;
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Context;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
|
||||||
|
|
||||||
#[ORM\Entity]
|
|
||||||
#[ORM\Table(name: 'shipment')]
|
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['shipment:read']],
|
|
||||||
),
|
|
||||||
new GetCollection(
|
|
||||||
normalizationContext: ['groups' => ['shipment:read']],
|
|
||||||
),
|
|
||||||
new Post(
|
|
||||||
normalizationContext: ['groups' => ['shipment:read']],
|
|
||||||
denormalizationContext: ['groups' => ['shipment:write']],
|
|
||||||
),
|
|
||||||
new Patch(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['shipment:read']],
|
|
||||||
denormalizationContext: ['groups' => ['shipment:write']],
|
|
||||||
),
|
|
||||||
// new Get(
|
|
||||||
// uriTemplate: '/shipments/weigh',
|
|
||||||
// openapi: new OpenApiOperation(
|
|
||||||
// summary: 'Fetch the current weight reading',
|
|
||||||
// description: 'Queries the pont-bascule and returns the weight data.',
|
|
||||||
// ),
|
|
||||||
// normalizationContext: ['groups' => ['shipment:weigh:read']],
|
|
||||||
// output: PontBasculeReading::class,
|
|
||||||
// provider: shipmentWeighingProvider::class,
|
|
||||||
// ),
|
|
||||||
// new Get(
|
|
||||||
// uriTemplate: '/shipments/{id}/receipt',
|
|
||||||
// requirements: ['id' => '\d+'],
|
|
||||||
// openapi: new OpenApiOperation(
|
|
||||||
// summary: 'Render a shipment receipt',
|
|
||||||
// description: 'Returns a PDF receipt for the shipment.',
|
|
||||||
// ),
|
|
||||||
// output: false,
|
|
||||||
// provider: shipmentReceiptProvider::class,
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
)]
|
|
||||||
class Shipment
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment:read'])]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
private ?string $licencePlate = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 20, unique: true, nullable: true)]
|
|
||||||
#[Groups(['shipment:read'])]
|
|
||||||
private ?string $identificationNumber = null;
|
|
||||||
|
|
||||||
#[ORM\Column(options: ['default' => 0])]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
private int $currentStep = 0;
|
|
||||||
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
private ?bool $isValid = null;
|
|
||||||
|
|
||||||
#[ORM\Column(name: 'shipment_date', type: 'datetime_immutable')]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
#[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
|
|
||||||
private ?DateTimeImmutable $shipmentDate = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
|
||||||
#[ORM\JoinColumn(nullable: true)]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
#[ApiProperty(readableLink: true)]
|
|
||||||
private ?Carrier $carrier = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
|
||||||
#[ORM\JoinColumn(nullable: true)]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
#[ApiProperty(readableLink: true)]
|
|
||||||
private ?Truck $truck = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
private ?Customer $customer = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Collection<int, BovinShipment>
|
|
||||||
*/
|
|
||||||
#[ORM\OneToMany(targetEntity: BovinShipment::class, mappedBy: 'shipment')]
|
|
||||||
#[Groups(['shipment:read', 'shipment:write'])]
|
|
||||||
private Collection $bovinShipments;
|
|
||||||
|
|
||||||
public function __construct(Collection $bovinShipments)
|
|
||||||
{
|
|
||||||
$this->bovinShipments = $bovinShipments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLicencePlate(): ?string
|
|
||||||
{
|
|
||||||
return $this->licencePlate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setLicencePlate(?string $licencePlate): void
|
|
||||||
{
|
|
||||||
$this->licencePlate = $licencePlate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIdentificationNumber(): ?string
|
|
||||||
{
|
|
||||||
return $this->identificationNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setIdentificationNumber(?string $identificationNumber): void
|
|
||||||
{
|
|
||||||
$this->identificationNumber = $identificationNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrentStep(): int
|
|
||||||
{
|
|
||||||
return $this->currentStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCurrentStep(int $currentStep): void
|
|
||||||
{
|
|
||||||
$this->currentStep = $currentStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIsValid(): ?bool
|
|
||||||
{
|
|
||||||
return $this->isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setIsValid(?bool $isValid): void
|
|
||||||
{
|
|
||||||
$this->isValid = $isValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShipmentDate(): ?DateTimeImmutable
|
|
||||||
{
|
|
||||||
return $this->shipmentDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShipmentDate(?DateTimeImmutable $shipmentDate): void
|
|
||||||
{
|
|
||||||
$this->shipmentDate = $shipmentDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCarrier(): ?Carrier
|
|
||||||
{
|
|
||||||
return $this->carrier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCarrier(?Carrier $carrier): void
|
|
||||||
{
|
|
||||||
$this->carrier = $carrier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getVehicle(): ?Vehicle
|
|
||||||
{
|
|
||||||
return $this->vehicle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setVehicle(?Vehicle $vehicle): void
|
|
||||||
{
|
|
||||||
$this->vehicle = $vehicle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTruck(): ?Truck
|
|
||||||
{
|
|
||||||
return $this->truck;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTruck(?Truck $truck): void
|
|
||||||
{
|
|
||||||
$this->truck = $truck;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCustomer(): ?Customer
|
|
||||||
{
|
|
||||||
return $this->customer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCustomer(?Customer $customer): void
|
|
||||||
{
|
|
||||||
$this->customer = $customer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBovinShipments(): Collection
|
|
||||||
{
|
|
||||||
return $this->bovinShipments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBovinShipments(Collection $bovinShipments): void
|
|
||||||
{
|
|
||||||
$this->bovinShipments = $bovinShipments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addPelletBuilding(BovinShipment $bovinShipments): self
|
|
||||||
{
|
|
||||||
if (!$this->bovinShipments->contains($bovinShipments)) {
|
|
||||||
$this->bovinShipments->add($bovinShipments);
|
|
||||||
$bovinShipments->setReception($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removePelletBuilding(BovinShipment $bovinShipments): self
|
|
||||||
{
|
|
||||||
if ($this->bovinShipments->removeElement($bovinShipments)) {
|
|
||||||
if ($bovinShipments->getReception() === $this) {
|
|
||||||
$bovinShipments->setReception(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
|
||||||
use ApiPlatform\Metadata\Get;
|
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Symfony\Component\Serializer\Attribute\Groups;
|
|
||||||
|
|
||||||
#[ORM\Entity]
|
|
||||||
#[ORM\Table(name: 'shipment_type')]
|
|
||||||
#[ApiResource(
|
|
||||||
operations: [
|
|
||||||
new Get(
|
|
||||||
requirements: ['id' => '\d+'],
|
|
||||||
normalizationContext: ['groups' => ['shipment-type:read']],
|
|
||||||
),
|
|
||||||
new GetCollection(
|
|
||||||
normalizationContext: ['groups' => ['shipment-type:read']],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
security: "is_granted('ROLE_USER')",
|
|
||||||
)]
|
|
||||||
class ShipmentType
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
#[Groups(['shipment-type:read', 'shipment:read'])]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
#[Groups(['shipment-type:read', 'shipment:read'])]
|
|
||||||
private ?string $label = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
#[Groups(['shipment-type:read', 'shipment:read'])]
|
|
||||||
private ?string $code = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLabel(): ?string
|
|
||||||
{
|
|
||||||
return $this->label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setLabel(string $label): static
|
|
||||||
{
|
|
||||||
$this->label = $label;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCode(): ?string
|
|
||||||
{
|
|
||||||
return $this->code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCode(string $code): self
|
|
||||||
{
|
|
||||||
$this->code = $code;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user