Purchase Vouchers With Multiple Items
Published
This exercise imports Purchase Invoices that carry several stock items.
Rows sharing the same Invoice No. become one voucher with one stock
item line per row. It builds on the previous exercise, using
SCROLL to loop through all the rows for each record, and sum
the Invoice Amount using curly braces {}.
The Excel sheet
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | INV NO. | DATE | SUPPLIER'S NAME | PURCHASE LEDGER | STOCK ITEM | QTY | UNIT | RATE | AMOUNT | NARRATION |
| 2 | 4817 | 01/04/2026 | Vero Beach Embroidery | Purchase Account | Silk Thread | 10 | Nos | 10 | 100 | Silk |
| 3 | 4817 | 01/04/2026 | Vero Beach Embroidery | Purchase Account | Cotton Fabric | 3 | Mtr | 40 | 120 | Cotton |
| 4 | 4817 | 01/04/2026 | Vero Beach Embroidery | Purchase Account | Embroidery Needle | 10 | Nos | 20 | 200 | Needle |
| 5 | 7392 | 01/04/2026 | A R S Marketing | Purchase Account | Cotton Fabric | 5 | Mtr | 40 | 200 | Cotton |
| 6 | 2658 | 01/04/2026 | Lee Homeservices | Purchase Account | Silk Thread | 30 | Nos | 10 | 300 | Silk |
| 7 | 2658 | 01/04/2026 | Lee Homeservices | Purchase Account | Cotton Fabric | 3 | Mtr | 40 | 120 | Cotton |
| 8 | 9143 | 01/04/2026 | V S Traders | Purchase Account | Embroidery Needle | 20 | Nos | 20 | 400 | Needle |
| 9 | 6025 | 01/04/2026 | Parimal Arts | Purchase Account | Cotton Fabric | 12.5 | Mtr | 40 | 500 | Cotton |
Step 1 — Create the masters
The voucher refers to four masters: the Supplier Ledger (Column C), the Purchase
Ledger (Column D), the Unit (Column G) and the Stock Item (Column E).
udiMagic processes MASTER tags before VOUCHER tags,
so anything that doesn't exist yet in Tally is created in the same import.
The UNIT master must come before the STOCKITEM,
because the Stock Item uses the Unit as its base unit.
<!-- Create Supplier LEDGER Master (Column C) -->
<MASTER TYPE="LEDGER">
<NAME.LIST>
<NAME COLUMNREFERENCE="C"/>
</NAME.LIST>
<!-- Group is hard coded -->
<PARENT>Sundry Creditors</PARENT>
<ISBILLWISEON>Yes</ISBILLWISEON>
<AFFECTSSTOCK>No</AFFECTSSTOCK>
<ISCOSTCENTRESON>No</ISCOSTCENTRESON>
</MASTER>
<!-- Create Purchase LEDGER Master (Column D) -->
<MASTER TYPE="LEDGER">
<NAME.LIST>
<NAME COLUMNREFERENCE="D"/>
</NAME.LIST>
<PARENT>Purchase Accounts</PARENT>
<ISBILLWISEON>No</ISBILLWISEON>
<ISCOSTCENTRESON>No</ISCOSTCENTRESON>
<!-- Yes, because this ledger is used with Stock Items -->
<AFFECTSSTOCK>Yes</AFFECTSSTOCK>
<USEFORVAT>No</USEFORVAT>
</MASTER>
<!-- Create UNIT Master (Column G). Must come before the StockItem. -->
<MASTER TYPE="UNIT">
<!-- The UNIT Master does not support Aliases : use NAME directly -->
<NAME COLUMNREFERENCE="G"/>
<ISSIMPLEUNIT>Yes</ISSIMPLEUNIT>
</MASTER>
<!-- Create STOCKITEM Master (Column E) -->
<MASTER TYPE="STOCKITEM">
<NAME.LIST>
<NAME COLUMNREFERENCE="E"/>
</NAME.LIST>
<!-- Empty PARENT = no Stock Group (udiMagic default) -->
<PARENT/>
<BASEUNITS COLUMNREFERENCE="G"/>
</MASTER>
Step 2 — Declare the key column and scroll the stock items
CELLREFERENCE="A1" on XMLTAGS declares Column A
(Invoice No.) as the key field. SCROLL="YES" on ALLINVENTORYENTRIES.LIST then
tells udiMagic to keep adding one stock-item block for every following row
that carries the same Invoice No. (see
udiMagic XML tags).
<XMLTAGS xmlns:UDF="TallyUDF" CELLREFERENCE="A1"> ... <ALLINVENTORYENTRIES.LIST SCROLL="YES">
| Invoice No. | Excel rows | Stock item lines in the voucher |
|---|---|---|
| 4817 | 2–4 | 3 (Silk Thread, Cotton Fabric, Embroidery Needle) |
| 7392 | 5 | 1 |
| 2658 | 6–7 | 2 (Silk Thread, Cotton Fabric) |
| 9143 | 8 | 1 |
| 6025 | 9 | 1 |
Step 3 — Write the Voucher tags
The Supplier Ledger is credited under LEDGERENTRIES.LIST with the
total of all item amounts of the invoice
using curly braces {}, both in the ledger entry and in
its bill allocation. Each scrolled stock-item block carries the Stock Item,
Qty, Rate and Amount of its own row, and debits the Purchase Ledger through
its ACCOUNTINGALLOCATIONS.LIST.
<!-- VOUCHER : one invoice can contain multiple stock-item rows -->
<VOUCHER>
<!-- Unique voucher ID from Invoice No. (Column A) -->
<GUID FORMULA="=+"udi-PRCHSE-MULTI" & A#"/>
<DATE COLUMNREFERENCE="B"/>
<EFFECTIVEDATE COLUMNREFERENCE="B"/>
<VOUCHERTYPENAME>Purchase</VOUCHERTYPENAME>
<VOUCHERNUMBER COLUMNREFERENCE="A"/>
<REFERENCE COLUMNREFERENCE="A"/>
<!-- Narration mapped directly from Column J -->
<NARRATION COLUMNREFERENCE="J"/>
<ISINVOICE>Yes</ISINVOICE>
<PERSISTEDVIEW>Invoice Voucher View</PERSISTEDVIEW>
<!-- Party (Supplier) from Column C -->
<PARTYNAME COLUMNREFERENCE="C"/>
<PARTYLEDGERNAME COLUMNREFERENCE="C"/>
<BASICBASEPARTYNAME COLUMNREFERENCE="C"/>
<BASICBUYERNAME COLUMNREFERENCE="C"/>
<!--
Supplier total:
accumulated for all item rows belonging to the invoice.
-->
<LEDGERENTRIES.LIST>
<LEDGERNAME COLUMNREFERENCE="C"/>
<ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE>
<AMOUNT FORMULA="={Round(I#,2)}"/>
<BILLALLOCATIONS.LIST SKIP="=Len(trim(A#))=0">
<NAME COLUMNREFERENCE="A"/>
<BILLTYPE>New Ref</BILLTYPE>
<AMOUNT FORMULA="={Round(I#,2)}"/>
</BILLALLOCATIONS.LIST>
</LEDGERENTRIES.LIST>
<!--
Stock-item rows are scrolled according to Invoice No. in Column A.
Therefore:
Invoice 4817 -> 3 item rows
Invoice 2658 -> 2 item rows
while invoices with one row remain one-item vouchers.
-->
<ALLINVENTORYENTRIES.LIST SCROLL="YES">
<STOCKITEMNAME COLUMNREFERENCE="E"/>
<ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
<RATE COLUMNREFERENCE="H"/>
<AMOUNT FORMULA="=+I#*-1"/>
<ACTUALQTY COLUMNREFERENCE="F"/>
<BILLEDQTY COLUMNREFERENCE="F"/>
<!-- Purchase Ledger from Column D -->
<ACCOUNTINGALLOCATIONS.LIST>
<LEDGERNAME COLUMNREFERENCE="D"/>
<ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
<AMOUNT FORMULA="=+I#*-1"/>
</ACCOUNTINGALLOCATIONS.LIST>
<!-- Existing inventory/godown structure retained -->
<BATCHALLOCATIONS.LIST>
<GODOWNNAME>Main Location</GODOWNNAME>
<BATCHNAME>Primary Batch</BATCHNAME>
<DESTINATIONGODOWNNAME>Main Location</DESTINATIONGODOWNNAME>
<AMOUNT FORMULA="=+I#*-1"/>
<ACTUALQTY COLUMNREFERENCE="F"/>
<BILLEDQTY COLUMNREFERENCE="F"/>
</BATCHALLOCATIONS.LIST>
</ALLINVENTORYENTRIES.LIST>
</VOUCHER>
- To see the exact structure Tally uses, enter one sample invoice and export it from
Gateway of Tally >> Display >> Daybook >> Alt+E. - Master tags are processed before the voucher, and the
UNITmaster must precede theSTOCKITEMmaster that uses it. - The
UNITmaster doesn't support aliases, soNAMEis used directly instead of aNAME.LIST. - The Purchase Ledger has
AFFECTSSTOCKset toYesbecause it is used with Stock Items; the Supplier Ledger has it set toNo. - The Supplier Ledger is credited with the invoice total (a curly-brace
{}formula over the invoice's rows), and the Purchase Ledger is debited with each row's amount (as a negative value,=+I#*-1) through the accounting allocation, so the voucher nets to zero. - Invoice 4817 therefore posts a Supplier credit of 420 (100 + 120 + 200); invoice 2658 posts 420 (300 + 120).
- The Godown (
Main Location) and Batch (Primary Batch) are hard-coded because the sheet has no columns for them. - Quantities can be decimals, such as 12.5 Mtr in the last row.
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