"""Shared constants for StatementSetu. Single source of truth for the closed ledger-category list (spec section 1.4) and a couple of derived helpers used across the pipeline. """ # Fixed, closed set of ledger heads. Keeping this closed-set means the small # model can never invent a head -- anything off-list is mapped to Suspense. CATEGORIES = [ "Sales / Receipts from Debtors", "Purchases / Payments to Creditors", "Salary & Wages", "Office Rent", "Electricity & Utilities", "Telephone & Internet", "Bank Charges", "Interest Received", "Interest Paid", "GST Payment", "TDS Payment", "Income Tax Payment", "Loan EMI", "Cash Deposit", "Cash Withdrawal", "Transfer between Own Accounts (Contra)", "Insurance", "Professional Fees", "Travel & Conveyance", "Repairs & Maintenance", "Drawings", "Capital Introduced", "Suspense / Unclassified", ] SUSPENSE = "Suspense / Unclassified" CONTRA = "Transfer between Own Accounts (Contra)" # Confidence below this is forced to Suspense -- a CA trusts "I don't know" # over a confident wrong answer. CONFIDENCE_FLOOR = 0.5 CATEGORY_SET = set(CATEGORIES) def voucher_type_for(debit, credit, category=None): """Derive the Tally voucher type from amounts and category. debit -> Payment, credit -> Receipt; own-account transfers -> Contra. """ if category == CONTRA: return "Contra" if debit is not None and debit > 0: return "Payment" if credit is not None and credit > 0: return "Receipt" return "Payment"