Goal : Export Ledgers of all my customers ( Sundry Debtors) and send them a mail with attached ledger asking for payment with 1 click. PS : I have already written a code in python to do the same. But since tally is not integrated with python, my code uses the keyboard to export the ledgers and mail them. Currently , i have put in time delays to ensure tally responds to the script commands. But i realize this is not an efficient solution. I need help to write a code in any software that will export the ledgers of all the customers.
I have already written a code in python where it picks name from customer list( from an excel file ) , opens tally, exports the ledger and mails to the customer ( mail info from same excel file ). But since python cannot interact with tally, i have to use python to put in keystrokes ( DAL , display accounts ledger ) with time delays to allow tally to respond. Since python is just operating the keyboard, any error will mess up the whole sequence. I want to write a code that can actually interact with tally and export all the ledgers and mail them. I have attached my python code.
you can simply send an HTTP XML request to tally asking ledger statement of particular ledger then tally will send you the list of transactions for that ledger, you can also specify from and to dates you want here the process: -> Open Tally (at least one company should be opened) ->Send an HTTP request to http://www.localhost:900 with payload given below -> fetch the response(XML) and write into an excel sheet ->mail that sheet to the customer ->Repeat the same process for the count of customers by changing ledger name and from, to dates in the payload Sample python code (Open Tally and execute this code ) Code: import urllib.request import urllib.parse class Main: def __init__(self): try: led_payload = urllib.parse.unquote_to_bytes(self.get_led_payload("1-Apr-19", "31-Mar-20", "Cash")) req_object = urllib.request.Request("http://localhost:9000", data=led_payload) req_object.add_header('Content-Type', 'text/xml') led_response = urllib.request.urlopen(req_object) print(led_response.read().decode().strip()) except IOError as e: print(str(e)) @staticmethod def get_led_payload(fromdate, todate, ledname): led = "<ENVELOPE><HEADER><VERSION>1</VERSION><TALLYREQUEST>Export</TALLYREQUEST><TYPE>Data</TYPE><ID>LedgerVouchers</ID>" led = led + "</HEADER><BODY><DESC><STATICVARIABLES><SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT><SVFROMDATE Type='Date'>" + fromdate + "</SVFROMDATE><SVTODATE Type='Date'>" + todate + "</SVTODATE><LEDGERNAME>" + ledname + "</LEDGERNAME>" led = led + "</STATICVARIABLES><TDL><TDLMESSAGE><LINE Name='DSPVchDetail' ISMODIFY='YES'><XMLTAG>LEDINFO</XMLTAG>" led = led + "</LINE></TDLMESSAGE></TDL></DESC></BODY></ENVELOPE>" return led if __name__ == "__main__": Main() Payload (Change the ledger name, from and to dates): Code: REQUEST XML <ENVELOPE> <HEADER> <VERSION>1</VERSION> <TALLYREQUEST>Export</TALLYREQUEST> <TYPE>Data</TYPE> <ID>LedgerVouchers</ID> </HEADER> <BODY> <DESC> <STATICVARIABLES> <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT> <SVFROMDATE Type='Date'>1-4-19</SVFROMDATE> <SVTODATE Type='Date'>31-3-20</SVTODATE><LEDGERNAME>Cash</LEDGERNAME> </STATICVARIABLES> <TDL> <TDLMESSAGE> <LINE Name="DSPVchDetail" ISMODIFY="YES"> <XMLTAG>LEDINFO</XMLTAG> </LINE> </TDLMESSAGE> </TDL> </DESC> </BODY> </ENVELOPE> Sample Response : Code: <ENVELOPE> <LEDINFO> <DSPVCHDATE>1-4-2020</DSPVCHDATE> <DSPVCHLEDACCOUNT>Sundry Creditor</DSPVCHLEDACCOUNT> <DSPVCHTYPE>Pymt</DSPVCHTYPE> <DSPVCHDRAMT></DSPVCHDRAMT> <DSPVCHCRAMT>300000.00</DSPVCHCRAMT> </LEDINFO> <LEDINFO> <DSPVCHDATE>1-4-2020</DSPVCHDATE> <DSPVCHLEDACCOUNT>Sales</DSPVCHLEDACCOUNT> <DSPVCHTYPE>Sale</DSPVCHTYPE> <DSPVCHDRAMT>-3600.00</DSPVCHDRAMT> <DSPVCHCRAMT></DSPVCHCRAMT> </LEDINFO> <LEDINFO> <DSPVCHDATE>1-6-2020</DSPVCHDATE> <DSPVCHLEDACCOUNT>Sales</DSPVCHLEDACCOUNT> <DSPVCHTYPE>Sale</DSPVCHTYPE> <DSPVCHDRAMT>-600.00</DSPVCHDRAMT> <DSPVCHCRAMT></DSPVCHCRAMT> </LEDINFO> <LEDINFO> <DSPVCHDATE>1-8-2020</DSPVCHDATE> <DSPVCHLEDACCOUNT>Sales</DSPVCHLEDACCOUNT> <DSPVCHTYPE>Sale</DSPVCHTYPE> <DSPVCHDRAMT>-90000.00</DSPVCHDRAMT> <DSPVCHCRAMT></DSPVCHCRAMT> </LEDINFO> <LEDINFO> <DSPVCHDATE>1-8-2020</DSPVCHDATE> <DSPVCHLEDACCOUNT>Sundry Creditor</DSPVCHLEDACCOUNT> <DSPVCHTYPE>Rcpt</DSPVCHTYPE> <DSPVCHDRAMT>-40000.00</DSPVCHDRAMT> <DSPVCHCRAMT></DSPVCHCRAMT> </LEDINFO> </ENVELOPE> Hope it will help you...
Sir, i learned python 20 days ago in quarantine via youtube. Also i have no/very basic knowledge of TDL. If u could send some links to videos explaining i can learn what code you have given. Alternatively please dm me your mobile number if possible so i can learn directly. P.S i run a small company and dont have any person to make calls to customers so i want to automate it. If u would like to give me a program for the same for some fee i am open to that.
Thanks, your code worked well for me to export 500 ledgers automatically. Just added a check for file exists and all worked well.