Skip to main content
Glama
svharivinod

TallyPrime MCP Server

by svharivinod

create_sales_voucher

Create a sales invoice in TallyPrime by specifying date, customer, sales ledger, amount, and optional tax details.

Instructions

Create a sales invoice in TallyPrime.

Args: date: Voucher date YYYYMMDD. party_ledger: Customer ledger name (must exist in Tally). sales_ledger: Sales account ledger name. amount: Invoice amount excluding tax. narration: Optional description or invoice number. tax_ledger: GST or tax ledger name (optional). tax_amount: Tax amount (optional, default 0).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes
party_ledgerYes
sales_ledgerYes
amountYes
narrationNo
tax_ledgerNo
tax_amountNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler for 'create_sales_voucher'. Defines parameters (date, party_ledger, sales_ledger, amount, narration, tax_ledger, tax_amount), calls client.create_sales_voucher, and formats the result string.
    async def create_sales_voucher(
        date: str,
        party_ledger: str,
        sales_ledger: str,
        amount: float,
        narration: str = "",
        tax_ledger: str = "",
        tax_amount: float = 0.0,
    ) -> str:
        """
        Create a sales invoice in TallyPrime.
    
        Args:
            date: Voucher date YYYYMMDD.
            party_ledger: Customer ledger name (must exist in Tally).
            sales_ledger: Sales account ledger name.
            amount: Invoice amount excluding tax.
            narration: Optional description or invoice number.
            tax_ledger: GST or tax ledger name (optional).
            tax_amount: Tax amount (optional, default 0).
        """
        try:
            result = await client.create_sales_voucher(
                date=date, party_ledger=party_ledger, sales_ledger=sales_ledger,
                amount=amount, narration=narration, tax_ledger=tax_ledger, tax_amount=tax_amount,
            )
            if result["success"]:
                total = amount + tax_amount
                msg = f"Sales voucher created. Party: {party_ledger}, Amount: {amount:.2f}"
                if tax_amount:
                    msg += f" + Tax: {tax_amount:.2f}"
                msg += f", Total: {total:.2f}, Date: {date}"
                return msg
            return f"Failed: {result['message']}"
        except TallyError as e:
            return f"Error: {e}"
  • The input schema/parameters for create_sales_voucher defined via the function signature and docstring (date, party_ledger, sales_ledger, amount, narration, tax_ledger, tax_amount).
    async def create_sales_voucher(
        date: str,
        party_ledger: str,
        sales_ledger: str,
        amount: float,
        narration: str = "",
        tax_ledger: str = "",
        tax_amount: float = 0.0,
    ) -> str:
        """
        Create a sales invoice in TallyPrime.
    
        Args:
            date: Voucher date YYYYMMDD.
            party_ledger: Customer ledger name (must exist in Tally).
            sales_ledger: Sales account ledger name.
            amount: Invoice amount excluding tax.
            narration: Optional description or invoice number.
            tax_ledger: GST or tax ledger name (optional).
            tax_amount: Tax amount (optional, default 0).
  • Registration via @mcp.tool() decorator on the create_sales_voucher function inside the register() function (line 5).
    def register(mcp, client: TallyClient):
    
        @mcp.tool()
        async def get_vouchers(from_date: str, to_date: str, voucher_type: str = "") -> str:
            """
            Fetch vouchers from TallyPrime Day Book for a date range.
    
            Args:
                from_date: Start date YYYYMMDD (e.g. '20250401').
                to_date: End date YYYYMMDD (e.g. '20250430').
                voucher_type: Filter — 'Sales', 'Purchase', 'Payment', 'Receipt', 'Journal'. Empty = all.
            """
            try:
                vouchers = await client.get_vouchers(from_date, to_date, voucher_type)
                if not vouchers:
                    return "No vouchers found for the given period."
                label = f" ({voucher_type})" if voucher_type else ""
                text = f"Found {len(vouchers)} vouchers{label} from {from_date} to {to_date}:\n\n"
                for v in vouchers:
                    text += (
                        f"  [{v['date']}]  {v['type']}  #{v['number']}"
                        f"  Amount: {v['amount']}"
                        + (f"  -- {v['narration']}" if v["narration"] else "")
                        + "\n"
                    )
                return text
            except TallyError as e:
                return f"Error: {e}"
    
        @mcp.tool()
        async def create_sales_voucher(
            date: str,
            party_ledger: str,
            sales_ledger: str,
            amount: float,
            narration: str = "",
            tax_ledger: str = "",
            tax_amount: float = 0.0,
        ) -> str:
            """
            Create a sales invoice in TallyPrime.
    
            Args:
                date: Voucher date YYYYMMDD.
                party_ledger: Customer ledger name (must exist in Tally).
                sales_ledger: Sales account ledger name.
                amount: Invoice amount excluding tax.
                narration: Optional description or invoice number.
                tax_ledger: GST or tax ledger name (optional).
                tax_amount: Tax amount (optional, default 0).
            """
            try:
                result = await client.create_sales_voucher(
                    date=date, party_ledger=party_ledger, sales_ledger=sales_ledger,
                    amount=amount, narration=narration, tax_ledger=tax_ledger, tax_amount=tax_amount,
                )
                if result["success"]:
                    total = amount + tax_amount
                    msg = f"Sales voucher created. Party: {party_ledger}, Amount: {amount:.2f}"
                    if tax_amount:
                        msg += f" + Tax: {tax_amount:.2f}"
                    msg += f", Total: {total:.2f}, Date: {date}"
                    return msg
                return f"Failed: {result['message']}"
            except TallyError as e:
                return f"Error: {e}"
    
        @mcp.tool()
        async def create_purchase_voucher(
            date: str,
            party_ledger: str,
            purchase_ledger: str,
            amount: float,
            narration: str = "",
            tax_ledger: str = "",
            tax_amount: float = 0.0,
        ) -> str:
            """
            Create a purchase invoice in TallyPrime.
    
            Args:
                date: Voucher date YYYYMMDD.
                party_ledger: Supplier ledger name.
                purchase_ledger: Purchase account ledger name.
                amount: Invoice amount excluding tax.
                narration: Optional description.
                tax_ledger: GST or tax ledger name (optional).
                tax_amount: Tax amount (optional, default 0).
            """
            try:
                result = await client.create_purchase_voucher(
                    date=date, party_ledger=party_ledger, purchase_ledger=purchase_ledger,
                    amount=amount, narration=narration, tax_ledger=tax_ledger, tax_amount=tax_amount,
                )
                if result["success"]:
                    total = amount + tax_amount
                    msg = f"Purchase voucher created. Supplier: {party_ledger}, Amount: {amount:.2f}"
                    if tax_amount:
                        msg += f" + Tax: {tax_amount:.2f}"
                    msg += f", Total: {total:.2f}, Date: {date}"
                    return msg
                return f"Failed: {result['message']}"
            except TallyError as e:
                return f"Error: {e}"
    
        @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}"
    
        @mcp.tool()
        async def create_receipt_voucher(
            date: str,
            bank_ledger: str,
            party_ledger: str,
            amount: float,
            narration: str = "",
        ) -> str:
            """
            Create a receipt voucher in TallyPrime (money coming in).
    
            Args:
                date: Voucher date YYYYMMDD.
                bank_ledger: Bank or cash ledger receiving the payment.
                party_ledger: Customer ledger to credit.
                amount: Receipt amount.
                narration: Optional description or reference.
            """
            try:
                result = await client.create_receipt_voucher(
                    date=date, bank_ledger=bank_ledger,
                    party_ledger=party_ledger, amount=amount, narration=narration,
                )
                if result["success"]:
                    return f"Receipt voucher created. Received in: {bank_ledger}, From: {party_ledger}, Amount: {amount:.2f}, Date: {date}"
                return f"Failed: {result['message']}"
            except TallyError as e:
                return f"Error: {e}"
    
        @mcp.tool()
        async def create_journal_voucher(
            date: str,
            debit_ledger: str,
            credit_ledger: str,
            amount: float,
            narration: str = "",
        ) -> str:
            """
            Create a journal voucher in TallyPrime (adjustment or contra entry).
    
            Args:
                date: Voucher date YYYYMMDD.
                debit_ledger: Ledger to debit.
                credit_ledger: Ledger to credit.
                amount: Journal amount.
                narration: Optional description.
            """
            try:
                result = await client.create_journal_voucher(
                    date=date, debit_ledger=debit_ledger,
                    credit_ledger=credit_ledger, amount=amount, narration=narration,
                )
                if result["success"]:
                    return f"Journal voucher created. Dr: {debit_ledger}, Cr: {credit_ledger}, Amount: {amount:.2f}, Date: {date}"
                return f"Failed: {result['message']}"
            except TallyError as e:
                return f"Error: {e}"
  • TallyClient.create_sales_voucher — async helper that builds XML via create_sales_voucher_xml, sends it to TallyPrime, parses the response, and returns the import result dict.
    async def create_sales_voucher(self, **kwargs) -> dict:
        from .xml_builder import create_sales_voucher_xml
        return self._check_import_result(self._parse(await self.send_xml(create_sales_voucher_xml(**kwargs))))
  • create_sales_voucher_xml — builds the TDL XML string for creating a Sales voucher, including party ledger, sales ledger, optional tax entry, and wraps it in a voucher import envelope.
    def create_sales_voucher_xml(
        date: str,
        party_ledger: str,
        sales_ledger: str,
        amount: float,
        narration: str = "",
        tax_ledger: str = "",
        tax_amount: float = 0.0,
    ) -> str:
        total = amount + tax_amount
        tax_entry = ""
        if tax_ledger and tax_amount:
            tax_entry = f"""<ALLLEDGERENTRIES.LIST>
                <LEDGERNAME>{tax_ledger}</LEDGERNAME>
                <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE>
                <AMOUNT>{tax_amount}</AMOUNT>
              </ALLLEDGERENTRIES.LIST>"""
    
        voucher = f"""<VOUCHER ACTION="Create" VCHTYPE="Sales">
              <DATE>{date}</DATE>
              <VOUCHERTYPENAME>Sales</VOUCHERTYPENAME>
              <NARRATION>{narration}</NARRATION>
              <ALLLEDGERENTRIES.LIST>
                <LEDGERNAME>{party_ledger}</LEDGERNAME>
                <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
                <AMOUNT>-{total}</AMOUNT>
              </ALLLEDGERENTRIES.LIST>
              <ALLLEDGERENTRIES.LIST>
                <LEDGERNAME>{sales_ledger}</LEDGERNAME>
                <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE>
                <AMOUNT>{amount}</AMOUNT>
              </ALLLEDGERENTRIES.LIST>
              {tax_entry}
            </VOUCHER>"""
        return _voucher_import_envelope(voucher)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It only mentions that party_ledger must exist in Tally and the date format. It does not describe error handling, side effects, required permissions, or success conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise: one sentence for purpose followed by a clear argument list. No redundant information, and the most important info (purpose) is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the 7 parameters and the existence of an output schema, the description covers all parameters adequately but lacks usage guidance and behavioral context. It does not mention prerequisites like company selection or constraints on date range.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description provides detailed parameter info: date format, ledger existence requirement, amount excluding tax, optional narration, and tax fields with defaults. This adds significant meaning beyond the schema titles.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description explicitly states 'Create a sales invoice in TallyPrime.' The verb 'Create' and resource 'sales invoice' are clear. It distinguishes from sibling tools like create_purchase_voucher and create_receipt_voucher by specifying 'sales invoice'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for creating sales invoices but does not explicitly state when to use this tool over alternatives like create_purchase_voucher. No exclusions or alternative suggestions are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/svharivinod/tallyprime-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server