Files
web-frontend/app/composables/useOrderCodePresentation.ts
2026-04-04 15:27:00 +07:00

18 lines
432 B
TypeScript

export function extractOrderCodeShort(code?: string | null) {
const normalized = String(code ?? '').trim();
if (!normalized) {
return '0000';
}
const digits = normalized.replace(/\D/g, '');
if (digits.length >= 4) {
return digits.slice(-4);
}
return normalized.slice(-4).toUpperCase().padStart(4, '0');
}
export function formatOrderCode(code?: string | null) {
return `#${extractOrderCodeShort(code)}`;
}