;; ===================================================================== ;; AutoTally.tdl — Tally Definition Language connector for Auto-Tally ;; --------------------------------------------------------------------- ;; Exposes clean, machine-readable XML reports over the Tally gateway so ;; the Auto-Tally web app can pull LIVE data from TallyPrime and render ;; reports in any format. Standard Tally exports are verbose/inconsistent; ;; these custom reports emit a tight, stable schema the app parses ;; deterministically. ;; ;; Reports requested by name via over XML-over-HTTP: ;; - "AutoTally Trial Balance" -> ledger name, parent, closing balance ;; - "AutoTally Outstanding" -> party-wise receivable/payable closing ;; - "AutoTally Day Book" -> vouchers in a date range ;; ;; Auto-install: the Auto-Tally agent writes this file beside Tally and ;; registers it in tally.ini under [User TDL]. Validate on your TallyPrime ;; (schema is config-sensitive) before production use. ;; ===================================================================== ;; ---------- Dedup UDF ---------- ;; A per-voucher String UDF that Auto-Tally stamps with the bank line's dedup ;; hash on import. Reading it back in the Day Book lets the app skip a voucher ;; that already exists EXACTLY (survives re-uploads and Tally restores), instead ;; of guessing by date+narration. The INDEX must match config.dedup_udf_index. [System: UDF] AutoTallyHash : String : 20001 [Collection: AT Ledgers] Type : Ledger Fetch : Name, Parent, ClosingBalance, OpeningBalance ;; ---------- Trial Balance ---------- [Report: AutoTally Trial Balance] Form : AutoTally Trial Balance [Form: AutoTally Trial Balance] XMLTag : "ATTRIALBALANCE" Part : AutoTally TB Part [Part: AutoTally TB Part] Lines : AutoTally TB Line Repeat : AutoTally TB Line : AT Ledgers Scrolled : Vertical [Line: AutoTally TB Line] XMLTag : "LEDGER" Fields : ATF Name, ATF Parent, ATF Closing, ATF Opening, ATF TB DrCr [Field: ATF Name] XMLTag : "NAME" Set as : $Name [Field: ATF Parent] XMLTag : "PARENT" Set as : $Parent [Field: ATF Closing] XMLTag : "CLOSING" Set as : $$String:$ClosingBalance [Field: ATF Opening] XMLTag : "OPENING" Set as : $$String:$OpeningBalance ;; Dr/Cr flag so the backend can sign the (magnitude) closing balance and tie out ;; the balance sheet. $ClosingBalance renders as a magnitude in this collection, ;; so use $$IsDebit (true for a debit balance) to get the real side. [Field: ATF TB DrCr] XMLTag : "DRCR" Set as : if $$IsDebit:$ClosingBalance then "Dr" else "Cr" ;; ---------- Outstanding (party balances: debtors + creditors) ---------- ;; IMPORTANT: use $$IsLedOfGrp so parties in SUB-GROUPS of Sundry Debtors / ;; Sundry Creditors are included (e.g. "Consultancy Debtors" under "Sundry ;; Debtors"). A plain $Parent = "Sundry Debtors" check misses them. Only parties ;; with a non-zero closing balance are emitted. [Collection: AT Parties] Type : Ledger Fetch : Name, Parent, ClosingBalance, PartyGSTIN Filter : AT Is Party, AT Has Balance [System: Formula] AT Is Party : $$IsLedOfGrp:$Name:$$GroupSundryDebtors OR $$IsLedOfGrp:$Name:$$GroupSundryCreditors AT Has Balance : NOT $$IsEmpty:$ClosingBalance AND $ClosingBalance != 0 AT Vch In Period : ($$IsEmpty:##SVFROMDATE OR $Date >= ##SVFROMDATE) AND ($$IsEmpty:##SVTODATE OR $Date <= ##SVTODATE) AT Vch Live : NOT $IsCancelled AND NOT $IsOptional [Report: AutoTally Outstanding] Form : AutoTally Outstanding [Form: AutoTally Outstanding] XMLTag : "ATOUTSTANDING" Part : AutoTally OS Part [Part: AutoTally OS Part] Lines : AutoTally OS Line Repeat : AutoTally OS Line : AT Parties Scrolled : Vertical [Line: AutoTally OS Line] XMLTag : "PARTY" Fields : ATF Name, ATF Parent, ATF Closing, ATF GSTIN, ATF TB DrCr [Field: ATF GSTIN] XMLTag : "GSTIN" Set as : $PartyGSTIN ;; ---------- Day Book (LEDGER-ENTRY level) ---------- ;; The collection WALKS each voucher's ledger entries, so it emits ONE ;; per ledger line (a 2-line voucher -> 2 entries, 3-line -> 3) within the ;; requested period (SVFROMDATE/SVTODATE). $Amount here is the per-entry amount ;; (Tally sign: negative = Debit, positive = Credit). Group/parent/nature are ;; re-derived on the server from the synced ledger master. [Collection: AT DB Vouchers] Type : Voucher Walk : AllLedgerEntries Filter : AT Vch In Period, AT Vch Live Fetch : MasterID, Date, VoucherTypeName, VoucherNumber, Narration, PartyLedgerName, LedgerName, Amount, IsDeemedPositive, AutoTallyHash [Report: AutoTally Day Book] Form : AutoTally Day Book [Form: AutoTally Day Book] XMLTag : "ATDAYBOOK" Part : AutoTally DB Part [Part: AutoTally DB Part] Lines : AutoTally DB Line Repeat : AutoTally DB Line : AT DB Vouchers Scrolled : Vertical [Line: AutoTally DB Line] XMLTag : "ENTRY" Fields : ATF DB MID, ATF DB Date, ATF DB VType, ATF DB VNo, ATF DB Party, ATF DB Ledger, ATF DB DrCr, ATF DB Amount, ATF DB Company, ATF DB Narration, ATF DB Hash [Field: ATF DB Party] XMLTag : "PARTY" Set as : $PartyLedgerName:Voucher [Field: ATF DB DrCr] XMLTag : "DRCR" Set as : if $IsDeemedPositive then "Dr" else "Cr" [Field: ATF DB MID] XMLTag : "MASTERID" Set as : $$String:$MasterID [Field: ATF DB Date] XMLTag : "DATE" Set as : $$String:$Date [Field: ATF DB VType] XMLTag : "VTYPE" Set as : $VoucherTypeName [Field: ATF DB VNo] XMLTag : "VNO" Set as : $VoucherNumber [Field: ATF DB Ledger] XMLTag : "LEDGER" Set as : $LedgerName [Field: ATF DB Amount] XMLTag : "AMOUNT" Set as : $$String:$Amount [Field: ATF DB Company] XMLTag : "COMPANY" Set as : ##SVCURRENTCOMPANY [Field: ATF DB Narration] XMLTag : "NARRATION" Set as : $Narration [Field: ATF DB Hash] XMLTag : "HASH" Set as : $AutoTallyHash ;; ===================================================================== ;; v2 ADDITIONS (2026-06-28) — PURELY ADDITIVE. Everything above is ;; unchanged & keeps working. These add: ;; (1) a VERSION marker so the app can tell this v2 connector is loaded; ;; (2) BILL-WISE outstanding over the gateway, so ageing works WITHOUT ;; ODBC (most customers connect remotely, where ODBC is unreachable); ;; (3) the AA_* ODBC TABLES the app's ODBC accelerator queries — these ;; did not exist before, so every ODBC query silently failed. ;; All new definitions reuse functions the reports above already use ;; successfully ($$IsDebit / $$IsLedOfGrp / $$GroupSundryDebtors / $$IsEmpty), ;; so they're low-risk. VALIDATE on your TallyPrime (read-only) before ;; rolling out — bill-object method names can vary slightly by build. ;; ===================================================================== ;; ---------- (1) Version marker ---------- [Report: AutoTally Version] Form : AutoTally Version [Form: AutoTally Version] XMLTag : "ATVERSION" Part : AT Ver Part [Part: AT Ver Part] Line : AT Ver Line [Line: AT Ver Line] XMLTag : "INFO" Fields : ATF Ver No [Field: ATF Ver No] XMLTag : "VERSION" Set as : "3" ;; ---------- shared filters for bills / vouchers ---------- [System: Formula] AT Is Debtor : $$IsLedOfGrp:$Name:$$GroupSundryDebtors AT Is Creditor : $$IsLedOfGrp:$Name:$$GroupSundryCreditors ;; ---------- (2) Bill-wise outstanding (gateway -> ageing, no ODBC) ---------- ;; Walk each party's BillAllocations so we emit ONE per open bill with ;; its date + closing, letting the server bucket ageing properly. The party ;; (outer Ledger) name/group/GSTIN are reached with the ":Ledger" qualifier ;; while the current walked object is the Bill. [Collection: AT Debtor Bills] Type : Ledger Filter : AT Is Debtor Walk : BillAllocations Fetch : Name, Parent, PartyGSTIN [Collection: AT Creditor Bills] Type : Ledger Filter : AT Is Creditor Walk : BillAllocations Fetch : Name, Parent, PartyGSTIN [Report: AutoTally Bills] Form : AutoTally Bills [Form: AutoTally Bills] XMLTag : "ATBILLS" Parts : AT Bills Dr Part, AT Bills Cr Part [Part: AT Bills Dr Part] Lines : AT Bills Line Repeat : AT Bills Line : AT Debtor Bills Scrolled : Vertical [Part: AT Bills Cr Part] Lines : AT Bills Line Repeat : AT Bills Line : AT Creditor Bills Scrolled : Vertical [Line: AT Bills Line] XMLTag : "BILL" Fields : ATF B Party, ATF B Group, ATF B Name, ATF B Date, ATF B Closing, ATF B Due, ATF B GSTIN, ATF B Side [Field: ATF B Party] XMLTag : "PARTY" Set as : $Name:Ledger [Field: ATF B Group] XMLTag : "GROUP" Set as : $Parent:Ledger [Field: ATF B Name] XMLTag : "BILLNAME" Set as : $Name [Field: ATF B Date] XMLTag : "BILLDATE" Set as : $$String:$BillDate [Field: ATF B Closing] XMLTag : "CLOSING" Set as : $$String:$ClosingBalance [Field: ATF B Due] XMLTag : "DUEDATE" Set as : $$String:$BillCreditPeriod [Field: ATF B GSTIN] XMLTag : "GSTIN" Set as : $PartyGSTIN:Ledger [Field: ATF B Side] XMLTag : "SIDE" Set as : if $$IsDebit:$ClosingBalance then "Dr" else "Cr" ;; ===================================================================== ;; NOTE — ODBC tables intentionally NOT defined here. ;; The AA_* ODBC tables (AA_ClosingTB / AA_PartyMasters / AA_BillOutstanding / ;; AA_BillOutstandingCr / AA_GSTDaybook) are ALREADY defined in the firm's own ;; AA_Daybook_srinivas.tdl. Defining them again here makes TallyPrime reject this ;; file with "T0009: duplicate definition". The backend ODBC connector queries ;; those existing tables directly, so this connector only needs the gateway ;; reports above (Trial Balance, Outstanding, Day Book, and the new bill-wise ;; AutoTally Bills) plus the version marker. Do NOT re-add AA_* here. ;; =====================================================================