import ast
import os
import sys

sys.path.insert(0, os.path.abspath("."))
if hasattr(sys.stdout, "reconfigure"):
    sys.stdout.reconfigure(encoding="utf-8")


def analyze_invoice_service():
    target = "app/services/invoice_processing_service.py"
    with open(target, "r", encoding="utf-8") as f:
        tree = ast.parse(f.read())

    classes = [n.name for n in tree.body if isinstance(n, ast.ClassDef)]
    funcs = [n.name for n in tree.body if isinstance(n, ast.FunctionDef)]

    print(f"=== CLASSES IN {target} ===")
    for c in classes:
        print(f"  - class {c}")

    print(f"\n=== TOP-LEVEL FUNCTIONS IN {target} ===")
    for fn in funcs:
        print(f"  - def {fn}()")


if __name__ == "__main__":
    analyze_invoice_service()
