;; ===================================================================== ;; 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 [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 [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 Fetch : MasterID, Date, VoucherTypeName, VoucherNumber, Narration, 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 Ledger, ATF DB DrCr, ATF DB Amount, ATF DB Company, ATF DB Narration, ATF DB Hash [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