"""pubsalesacc/utils/misc.py — Miscellaneous formatting and helper utilities.""" import logging logger = logging.getLogger(__name__) def currency(value: float, precision: int = 2) -> str: """Format a numeric value as a currency string: $ 1,234.56""" return f"$ {{:,.{precision}f}}".format(value) def ordinal(n: int) -> str: """Convert an integer to its ordinal string representation (1 → '1st').""" if 11 <= (n % 100) <= 13: suffix = "th" else: suffix = ["th", "st", "nd", "rd", "th"][min(n % 10, 4)] return f"{n}{suffix}" def error_prompt(text: str = "", stars: int = 15) -> None: """Print a starred error banner.""" banner = "*" * stars + text + "*" * stars logger.warning(banner) print(banner)