"""Document categories for the retail back-office taxonomy. Five business categories the UI and DB organize around. Each maps to one or more internal `doc_type`s the pipeline classifies/extracts. """ from __future__ import annotations CATEGORIES = [ {"id": "orders", "label": "Orders", "icon": "๐Ÿงพ", "doc_types": ["purchase_order", "complex_form"], "description": "Purchase orders, order forms, and multi-vendor requisitions."}, {"id": "receipts", "label": "Receipts", "icon": "๐Ÿงพ", "doc_types": ["receipt"], "description": "Store and supplier receipts."}, {"id": "invoices", "label": "Invoices", "icon": "๐Ÿ“„", "doc_types": ["invoice"], "description": "Accounts-payable invoices."}, {"id": "contracts", "label": "Contracts", "icon": "๐Ÿ“œ", "doc_types": ["contract"], "description": "Master service agreements, NDAs, supplier contracts."}, {"id": "subscription_memo", "label": "Subscription Memos", "icon": "๐Ÿ”", "doc_types": ["subscription_memo"], "description": "Recurring subscription / renewal memos and notices."}, {"id": "other", "label": "Other", "icon": "๐Ÿ—‚๏ธ", "doc_types": ["other"], "description": "Unclassified documents."}, ] _DOCTYPE_TO_CATEGORY = { dt: c["id"] for c in CATEGORIES for dt in c["doc_types"] } CATEGORY_IDS = [c["id"] for c in CATEGORIES] def category_for_doc_type(doc_type: str | None) -> str: return _DOCTYPE_TO_CATEGORY.get(doc_type or "", "other") def category_meta(category_id: str) -> dict | None: return next((c for c in CATEGORIES if c["id"] == category_id), None) def list_categories() -> list[dict]: return CATEGORIES