afp-backend / app /domain /reference_normalization.py
cdupland
Implement price import functionality with support for CSV and Excel formats. Add API endpoint for starting price imports, including validation and error handling. Introduce new schemas, services, and repositories for price data management. Update documentation to reflect new features and usage. Enhance tests to cover the added functionality.
0f8d56c
"""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