File size: 404 Bytes
0f8d56c
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
"""Mirror of public.normalize_reference_number(text) in Postgres."""


def normalize_reference(value: str | None) -> str | None:
    """Strip leading whitespace, then remove a single leading lowercase 'a'."""
    if value is None:
        return None
    v = value.strip()
    if not v:
        return None
    normalized = v[1:] if v.startswith("a") else v
    return normalized if normalized else None