Exercise 9

Sales Vouchers With Multiple Items

Published


This exercise imports Sales 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 group the rows, and Sum(Column(...)) to post the invoice total to the Party Ledger.

The Excel sheet

A B C D E F G H I J
1 INV NO. DATE CLIENT'S NAME SALES LEDGER STOCK ITEM QTY UNIT RATE AMOUNT NARRATION
2 11077 01/04/2026 Vero Beach Embroidery Sales Account Silk Thread 10 Nos 10 100 Silk
3 11077 01/04/2026 Vero Beach Embroidery Sales Account Cotton Fabric 3 Mtr 40 120 Cotton
4 11077 01/04/2026 Vero Beach Embroidery Sales Account Embroidery Needle 10 Nos 20 200 Embroidery Needle
5 11078 01/04/2026 A R S Marketing Sales Account Cotton Fabric 5 Mtr 40 200 Cotton
6 11079 01/04/2026 Lee Home Services Ltd. Sales Account Silk Thread 30 Nos 10 150 Silk
7 11079 01/04/2026 Lee Home Services Ltd. Sales Account Cotton Fabric 3 Mtr 40 120 Cotton
8 11080 01/04/2026 V S Traders Sales Account Embroidery Needle 20 Nos 20 400 Embroidery Needle
9 11081 01/04/2026 Parimal Arts Sales Account Cotton Fabric 12.5 Mtr 40 500 Cotton

Step 1 — Create the masters

The voucher refers to four masters: the Party Ledger (Column C), the Sales 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 Party LEDGER Master (Column C) -->
<MASTER TYPE="LEDGER">
  <NAME.LIST>
    <NAME COLUMNREFERENCE="C"/>
  </NAME.LIST>
  <!-- Group is hard coded -->
  <PARENT>Sundry Debtors</PARENT>
  <ISBILLWISEON>Yes</ISBILLWISEON>
  <AFFECTSSTOCK>No</AFFECTSSTOCK>
  <ISCOSTCENTRESON>No</ISCOSTCENTRESON>
</MASTER>

<!-- Create Sales LEDGER Master (Column D) -->
<MASTER TYPE="LEDGER">
  <NAME.LIST>
    <NAME COLUMNREFERENCE="D"/>
  </NAME.LIST>
  <PARENT>Sales 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 rowsStock item lines in the voucher
110772–43 (Silk Thread, Cotton Fabric, Embroidery Needle)
1107851
110796–72 (Silk Thread, Cotton Fabric)
1108081
1108191

Step 3 — Write the Voucher tags

The Party Ledger is debited under LEDGERENTRIES.LIST with the total of all item amounts of the invoice (Round(Sum(Column(I#)),2)*-1), 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 credits the Sales Ledger through its ACCOUNTINGALLOCATIONS.LIST. To see the exact structure Tally uses, enter one sample invoice and export it from Gateway of Tally >> Display >> Daybook >> Alt+E.

<!-- VOUCHER : one invoice can contain multiple stock-item rows -->
<VOUCHER>
  <!-- Unique voucher ID from Invoice No. (Column A) -->
  <GUID FORMULA="=+&quot;udi-MLKIYT&quot; &amp; A#"/>
  <DATE COLUMNREFERENCE="B"/>
  <EFFECTIVEDATE COLUMNREFERENCE="B"/>
  <VOUCHERTYPENAME>Sales</VOUCHERTYPENAME>
  <VOUCHERNUMBER COLUMNREFERENCE="A"/>
  <!-- Narration mapped directly from Column J -->
  <NARRATION COLUMNREFERENCE="J"/>
  <ISINVOICE>Yes</ISINVOICE>
  <PERSISTEDVIEW>Invoice Voucher View</PERSISTEDVIEW>

  <!-- Party (Client) from Column C -->
  <PARTYNAME COLUMNREFERENCE="C"/>
  <PARTYLEDGERNAME COLUMNREFERENCE="C"/>
  <BASICBASEPARTYNAME COLUMNREFERENCE="C"/>
  <BASICBUYERNAME COLUMNREFERENCE="C"/>

  <!-- Party Ledger : Debit = total of all item amounts for the invoice -->
  <LEDGERENTRIES.LIST>
    <LEDGERNAME COLUMNREFERENCE="C"/>
    <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
    <AMOUNT FORMULA="=+Round(Sum(Column(I#)),2)*-1"/>
    <BILLALLOCATIONS.LIST SKIP="=Len(trim(A#))=0">
      <NAME COLUMNREFERENCE="A"/>
      <BILLTYPE>New Ref</BILLTYPE>
      <AMOUNT FORMULA="=+Round(Sum(Column(I#)),2)*-1"/>
    </BILLALLOCATIONS.LIST>
  </LEDGERENTRIES.LIST>

  <!--
    Stock-item rows are scrolled according to Invoice No. in Column A.
    Therefore:
      Invoice 11077 -> 3 item rows
      Invoice 11079 -> 2 item rows
    while invoices with one row remain one-item vouchers.
  -->
  <ALLINVENTORYENTRIES.LIST SCROLL="YES">
    <STOCKITEMNAME COLUMNREFERENCE="E"/>
    <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE>
    <RATE COLUMNREFERENCE="H"/>
    <AMOUNT COLUMNREFERENCE="I"/>
    <ACTUALQTY COLUMNREFERENCE="F"/>
    <BILLEDQTY COLUMNREFERENCE="F"/>
    <!-- Sales Ledger from Column D -->
    <ACCOUNTINGALLOCATIONS.LIST>
      <LEDGERNAME COLUMNREFERENCE="D"/>
      <ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE>
      <AMOUNT COLUMNREFERENCE="I"/>
    </ACCOUNTINGALLOCATIONS.LIST>
    <!-- Existing inventory/godown structure retained -->
    <BATCHALLOCATIONS.LIST>
      <GODOWNNAME>Main Location</GODOWNNAME>
      <BATCHNAME>Primary Batch</BATCHNAME>
      <DESTINATIONGODOWNNAME>Main Location</DESTINATIONGODOWNNAME>
      <AMOUNT COLUMNREFERENCE="I"/>
      <ACTUALQTY COLUMNREFERENCE="F"/>
      <BILLEDQTY COLUMNREFERENCE="F"/>
    </BATCHALLOCATIONS.LIST>
  </ALLINVENTORYENTRIES.LIST>
</VOUCHER>
Remarks:
  • Master tags are processed before the voucher, and the UNIT master must precede the STOCKITEM master that uses it.
  • The UNIT master doesn't support aliases, so NAME is used directly instead of a NAME.LIST.
  • The Sales Ledger has AFFECTSSTOCK set to Yes because it is used with Stock Items; the Party Ledger has it set to No.
  • The Party Ledger is debited with the invoice total as a negative amount (Round(Sum(Column(I#)),2)*-1), and the Sales Ledger is credited with each row's amount through the accounting allocation, so the voucher nets to zero.
  • Invoice 11077 therefore posts a Party debit of 420 (100 + 120 + 200); invoice 11079 posts 270 (150 + 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.
Sample files: Download the sample Excel sheet and matching XML tags file for this exercise. Download sales-vouchers-with-multiple-items.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