style(transport) : tableau prix consultation — code du site (département) + en-têtes Forfait/Tonne (€) (ERP-172)
This commit is contained in:
@@ -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) : '',
|
||||||
|
|||||||
Reference in New Issue
Block a user