style(transport) : tableau prix consultation — code du site (département) + en-têtes Forfait/Tonne (€) (ERP-172)
Pull Request — Quality gate / Backend (PHP CS + PHPUnit) (pull_request) Successful in 3m15s
Pull Request — Quality gate / Frontend (lint + Vitest + build) (pull_request) Successful in 1m31s

This commit is contained in:
2026-06-17 17:46:58 +02:00
parent 9fcf5c24f6
commit 7ddf495d7f
2 changed files with 14 additions and 4 deletions
+2 -2
View File
@@ -558,8 +558,8 @@
"carrier": "Transporteurs",
"aproOrSite": "Adresse sites",
"delivery": "Adresse livraisons",
"forfait": "Forfait ",
"tonne": "Tonne ",
"forfait": "Forfait (€)",
"tonne": "Tonne (€)",
"indexation": "Indexation",
"state": "État du prix",
"export": "Exporter",
@@ -253,6 +253,7 @@ import {
showArchiveAction,
showRestoreAction,
type CarrierPriceRead,
type Relation,
} from '~/modules/transport/utils/forms/carrierMappers'
import { extractApiErrorMessage } from '~/shared/utils/api'
@@ -354,16 +355,25 @@ function formatAmount(value: string | null | undefined): string {
return `${n.toLocaleString('fr-FR', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} €`
}
/** Code du site = département (2 premiers chiffres du code postal, ex: 86 / 17 / 82). */
function siteCode(relation: Relation): string {
if (!relation || typeof relation === 'string') {
return ''
}
const postalCode = relation.postalCode as string | undefined
return postalCode ? postalCode.slice(0, 2) : ''
}
/**
* Construit une ligne d'affichage depuis un prix embarqué (maquette Prix) :
* - « Adresse sites » = le site (Châtellerault / Saint-Jean / Pommevic…) ;
* - « Adresse sites » = le CODE du site (département, ex: 86 / 17 / 82) ;
* - « Adresse livraisons » = l'adresse (voie) du client/fournisseur ;
* - le prix tombe dans Forfait € OU Tonne € selon `pricingUnit`.
*/
function toPriceRow(price: CarrierPriceRead): PriceRowView {
const isClient = price.direction === 'CLIENT'
return {
apro: isClient ? labelOfRelation(price.departureSite) : labelOfRelation(price.deliverySite),
apro: isClient ? siteCode(price.departureSite) : siteCode(price.deliverySite),
delivery: isClient ? labelOfRelation(price.clientDeliveryAddress) : labelOfRelation(price.supplierSupplyAddress),
forfait: price.pricingUnit === 'FORFAIT' ? formatAmount(price.price) : '',
tonne: price.pricingUnit === 'TONNE' ? formatAmount(price.price) : '',