mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 12:30:58 +00:00
rule engine and configration and fix booking for custoemr
This commit is contained in:
15
apps/edr-freight-api/src/common/utils/generate-code.util.ts
Normal file
15
apps/edr-freight-api/src/common/utils/generate-code.util.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Derives a stable, uppercase, underscore-separated code from a human-readable name.
|
||||
*
|
||||
* Examples:
|
||||
* "Hazard Surcharge" → "HAZARD_SURCHARGE"
|
||||
* "20ft Dry Container" → "20FT_DRY_CONTAINER"
|
||||
* "Kality Yard (ET)" → "KALITY_YARD_ET"
|
||||
*/
|
||||
export function generateCode(name: string): string {
|
||||
return name
|
||||
.trim()
|
||||
.toUpperCase()
|
||||
.replace(/[^A-Z0-9]+/g, '_')
|
||||
.replace(/^_+|_+$/g, '');
|
||||
}
|
||||
Reference in New Issue
Block a user