create_payment_voucher
Record outgoing payments by creating a payment voucher in TallyPrime, debiting an expense or party ledger and crediting a bank or cash ledger.
Instructions
Create a payment voucher in TallyPrime (money going out).
Args: date: Voucher date YYYYMMDD. bank_ledger: Bank or cash ledger to pay from. expense_ledger: Expense or party ledger to debit. amount: Payment amount. narration: Optional description or reference.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | ||
| bank_ledger | Yes | ||
| expense_ledger | Yes | ||
| amount | Yes | ||
| narration | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- MCP tool handler that creates a payment voucher. Decorated with @mcp.tool(), it accepts date, bank_ledger, expense_ledger, amount, narration and calls client.create_payment_voucher().
@mcp.tool() async def create_payment_voucher( date: str, bank_ledger: str, expense_ledger: str, amount: float, narration: str = "", ) -> str: """ Create a payment voucher in TallyPrime (money going out). Args: date: Voucher date YYYYMMDD. bank_ledger: Bank or cash ledger to pay from. expense_ledger: Expense or party ledger to debit. amount: Payment amount. narration: Optional description or reference. """ try: result = await client.create_payment_voucher( date=date, bank_ledger=bank_ledger, expense_ledger=expense_ledger, amount=amount, narration=narration, ) if result["success"]: return f"Payment voucher created. Paid from: {bank_ledger}, To: {expense_ledger}, Amount: {amount:.2f}, Date: {date}" return f"Failed: {result['message']}" except TallyError as e: return f"Error: {e}" - TallyClient helper that builds the XML via create_payment_voucher_xml, sends it, parses the response, and checks the import result.
async def create_payment_voucher(self, **kwargs) -> dict: from .xml_builder import create_payment_voucher_xml return self._check_import_result(self._parse(await self.send_xml(create_payment_voucher_xml(**kwargs)))) - XML builder that constructs the TallyPrime Payment voucher XML with expense ledger (debit) and bank ledger (credit) entries.
def create_payment_voucher_xml( date: str, bank_ledger: str, expense_ledger: str, amount: float, narration: str = "", ) -> str: voucher = f"""<VOUCHER ACTION="Create" VCHTYPE="Payment"> <DATE>{date}</DATE> <VOUCHERTYPENAME>Payment</VOUCHERTYPENAME> <NARRATION>{narration}</NARRATION> <ALLLEDGERENTRIES.LIST> <LEDGERNAME>{expense_ledger}</LEDGERNAME> <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE> <AMOUNT>-{amount}</AMOUNT> </ALLLEDGERENTRIES.LIST> <ALLLEDGERENTRIES.LIST> <LEDGERNAME>{bank_ledger}</LEDGERNAME> <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE> <AMOUNT>{amount}</AMOUNT> </ALLLEDGERENTRIES.LIST> </VOUCHER>""" return _voucher_import_envelope(voucher) - src/tallyprime_mcp/tools/__init__.py:7-11 (registration)Entry point for tool registration. register_all() calls vouchers.register(mcp, client) which registers all voucher tools including create_payment_voucher.
def register_all(mcp: FastMCP, client: TallyClient): company.register(mcp, client) ledgers.register(mcp, client) vouchers.register(mcp, client) reports.register(mcp, client) - src/tallyprime_mcp/server.py:10-13 (registration)Server startup: creates FastMCP instance and calls register_all() to register all tools including create_payment_voucher.
mcp = FastMCP("tallyprime-mcp") _client = TallyClient(url=TALLY_URL, timeout=TALLY_TIMEOUT) register_all(mcp, _client)