/** Human-facing order number (digits only). */
export function formatOrderNumber(order: {
  displayNumber?: number;
  id: string;
}): string {
  if (order.displayNumber != null && order.displayNumber > 0) {
    return String(order.displayNumber);
  }
  const digits = order.id.replace(/\D/g, "");
  if (digits.length > 0) {
    const slice = digits.length > 9 ? digits.slice(-9) : digits;
    const trimmed = slice.replace(/^0+/, "");
    return trimmed.length > 0 ? trimmed : slice;
  }
  return "0";
}
