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", "carrier": "Transporteurs",
"aproOrSite": "Adresse sites", "aproOrSite": "Adresse sites",
"delivery": "Adresse livraisons", "delivery": "Adresse livraisons",
"forfait": "Forfait ", "forfait": "Forfait (€)",
"tonne": "Tonne ", "tonne": "Tonne (€)",
"indexation": "Indexation", "indexation": "Indexation",
"state": "État du prix", "state": "État du prix",
"export": "Exporter", "export": "Exporter",
@@ -253,6 +253,7 @@ import {
showArchiveAction, showArchiveAction,
showRestoreAction, showRestoreAction,
type CarrierPriceRead, type CarrierPriceRead,
type Relation,
} from '~/modules/transport/utils/forms/carrierMappers' } from '~/modules/transport/utils/forms/carrierMappers'
import { extractApiErrorMessage } from '~/shared/utils/api' 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 })} €` 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) : * 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 ; * - « Adresse livraisons » = l'adresse (voie) du client/fournisseur ;
* - le prix tombe dans Forfait € OU Tonne € selon `pricingUnit`. * - le prix tombe dans Forfait € OU Tonne € selon `pricingUnit`.
*/ */
function toPriceRow(price: CarrierPriceRead): PriceRowView { function toPriceRow(price: CarrierPriceRead): PriceRowView {
const isClient = price.direction === 'CLIENT' const isClient = price.direction === 'CLIENT'
return { 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), delivery: isClient ? labelOfRelation(price.clientDeliveryAddress) : labelOfRelation(price.supplierSupplyAddress),
forfait: price.pricingUnit === 'FORFAIT' ? formatAmount(price.price) : '', forfait: price.pricingUnit === 'FORFAIT' ? formatAmount(price.price) : '',
tonne: price.pricingUnit === 'TONNE' ? formatAmount(price.price) : '', tonne: price.pricingUnit === 'TONNE' ? formatAmount(price.price) : '',