Exercise 15

Cash Payment Voucher

Published


This exercise imports Cash Payment Vouchers — expenses paid in cash — from Excel into Tally Prime. Each row is one voucher: the expenses are spread across several columns (one column per expense ledger) and the Total is credited to Cash. It builds on the Cash Receipt Vouchers exercise, and shows how SCROLLHORIZONTALLY reads the expense columns one after another and how SKIP ignores the empty ones.

The Excel sheet

The expense ledger names are the column headings from column E onward. An empty cell means that expense does not apply to that voucher.

A B C D E F G H
1 Vch-no Date Ledger Name Total Stationery Exp Xerox Books Fuel Exp
2 1 01/04/2026 Cash 500 50 100 150 200
3 2 01/04/2026 Cash 700 200 500
4 3 02/04/2026 Cash 1000 100 200 300 400
5 4 02/04/2026 Cash 1200 300 400 500
6 5 02/04/2026 Cash 1500 400 500 600

Step 1 — Create the Expense Ledger masters

SCROLLHORIZONTALLY repeats the MASTER tag for every column starting from column E, moving to the right, for as long as the condition holds true — here, until a column has no heading. Columns whose amount is zero are skipped through SKIP. The ledger name is the heading in row 1 (E$1), and the group is fixed as "Expenses Indirect".

<!--  Master for the Expense Ledger
    Uses SCROLLHORIZONTALLY to read all the columns starting from Column E, moving to the right, for
    as long as a condition holds true.
-->
<MASTER TYPE="LEDGER" SKIP="=+Round(E#,2)=0" SCROLLHORIZONTALLY="=Len(trim(E$1))>0">
    <NAME.LIST>
        <NAME FORMULA="=+E$1"/>
    </NAME.LIST>
    <!--  Group is fixed here  -->
    <PARENT>Expenses Indirect</PARENT>
    <ISBILLWISEON>No</ISBILLWISEON>
    <AFFECTSSTOCK>No</AFFECTSSTOCK>
    <ISCOSTCENTRESON>No</ISCOSTCENTRESON>
</MASTER>

The Cash ledger normally already exists in every Tally company under the built-in "Cash-in-Hand" group, so it doesn't need a MASTER tag of its own.

Step 2 — Write the Voucher tags

The voucher is a Payment voucher. The same SCROLLHORIZONTALLY and SKIP attributes are used on the ALLLEDGERENTRIES.LIST tag, so one debit entry is created for every expense column that has an amount. The amount is multiplied by -1 and ISDEEMEDPOSITIVE set to "Yes" (debit). The last entry credits the ledger named in column C (Cash) with the Total from column D (ISDEEMEDPOSITIVE "No").

<VOUCHER>
    <GUID FORMULA="=A# & &quot;-&quot; & B# & &quot;-&quot; & "payment""/>
    <DATE COLUMNREFERENCE="B"/>
    <EFFECTIVEDATE COLUMNREFERENCE="B"/>
    <VOUCHERTYPENAME>Payment</VOUCHERTYPENAME>
    <VOUCHERNUMBER COLUMNREFERENCE="A"/>
    <!--  
        Ledger Entries for the Expenses: Starting from Column E, keep reading columns one after another, moving to the right, for
        as long as a condition holds true.
        - Stop when a column has no heading.
        - Skip if the amount in the column is zero.
    -->
    <ALLLEDGERENTRIES.LIST SKIP="=+Round(E#,2)=0" SCROLLHORIZONTALLY="=Len(trim(E$1))>0">
        <LEDGERNAME FORMULA="=+E$1"/>
        <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
        <AMOUNT FORMULA="=ROUND(E#,2)*-1"/>
    </ALLLEDGERENTRIES.LIST>
    <!-- Cash or Bank ledger -->
    <ALLLEDGERENTRIES.LIST>
        <LEDGERNAME FORMULA="=+C#"/>
        <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE>
        <AMOUNT FORMULA="=ROUND(D#,2)"/>
    </ALLLEDGERENTRIES.LIST>
    </VOUCHER>
</XMLTAGS>
Remarks:
  1. The GUID is built from the Vch-no, Date and Vch-type (columns A, B and 'payment'). The Cash ledger name in column C is used as the credit ledger. Note: A different cash or bank ledger can be used on any row.
  2. Expense ledgers are created automatically under the group "Expenses Indirect".
  3. To add another expense, just add a new column with its heading to the right of "Fuel Exp" — no change in the XML tags is needed.
  4. Keep the Total equal to the sum of the expense columns for each row; Tally will otherwise show an unbalanced voucher.
Sample files: Download the sample Excel sheet and matching XML tags file for this exercise. Download cash-payment-vouchers.zip

Ready to import your Excel data into Tally?

Download udiMagic and start a 14-day free trial — no credit card required.

Download udiMagic View Pricing