ERP-DocIQ / backend /app /categories.py
kenmandal's picture
Deploy ERP-DocIQ: agentic OCR + IDP (MiniCPM-V 8B, Tesseract)
32b00ed verified
Raw
History Blame Contribute Delete
1.68 kB
"""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