Note: I LEFT MY CAREER AS A PHP DEVELOPER LONG AGO, AND DON'T HAVE ANY PRACTICE FOR BOTH PHP AND TALLY. I APOLOGIZE IN ADVANCE, I CAN'T SOLVE YOUR QUERIES ABOUT THIS POST.
<!--
First of all, we have to enable cURL of PHP. Then only we can directly import the XML file to Tally via PHP.
1. Click on the WAMP icon of the system tray. then
PHP -> PHP extensions -> php_curl
2. Click on the WAMP icon of System tray. Then PHP and then open the php.ini file. Then search for extension=php_curl.dll. Remove semicolon (;) before this line.
Now ready for the following code.
-->
<!-- This is an HTML form to insert an accounting voucher in tally. In this form, we have taken an input box for Ledger's name. The accounting voucher entry for that specified Ledger will be inserted directly. -->
<form action="" method="post">
<table width="100%" border="1">
<tr>
<th scope="col">Name</th>
<td><input name="nm" id="nm" type="text" /></td>
</tr>
<tr>
<td colspan="4"><div align="center">
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</div></td>
</tr>
</table>
</form>
<?php
/* This is PHP code to insert an entry in Tally. All required XML tags by Tally are taken here in a string and the name for Ledger is taken by posted value from HTML form. */
if(isset($_POST['Submit']))
{
$name = $_POST['nm'];
$requestXML = '<?xml version="1.0"?>
<ENVELOPE>
<HEADER>
<TALLYREQUEST>Import Data</TALLYREQUEST>
</HEADER>
<BODY>
<IMPORTDATA>
<REQUESTDESC>
<REPORTNAME>Vouchers</REPORTNAME>
<STATICVARIABLES>
<SVCURRENTCOMPANY>SAVH</SVCURRENTCOMPANY>
</STATICVARIABLES>
</REQUESTDESC>
<REQUESTDATA>
<TALLYMESSAGE xmlns:UDF="TallyUDF">
<VOUCHER REMOTEID="123" VCHTYPE="Receipt" VCHKEY="321" ACTION="Create" OBJVIEW="Accounting Voucher View">
<OLDAUDITENTRIES.LIST> </OLDAUDITENTRIES.LIST>
<ACCOUNTAUDITENTRIES.LIST> </ACCOUNTAUDITENTRIES.LIST>
<AUDITENTRIES.LIST> </AUDITENTRIES.LIST>
<OLDAUDITENTRYIDS.LIST TYPE="Number">
<OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS>
</OLDAUDITENTRYIDS.LIST>
<DATE>20130401</DATE>
<GUID>f6c10ce3-4a15-42b8-961e-143a512a9e62-00000009</GUID>
<VOUCHERTYPENAME>Receipt</VOUCHERTYPENAME>
<VOUCHERNUMBER>5</VOUCHERNUMBER>
<PARTYLEDGERNAME>'.$name.'</PARTYLEDGERNAME>
<CSTFORMISSUETYPE/>
<CSTFORMRECVTYPE/>
<FBTPAYMENTTYPE>Default</FBTPAYMENTTYPE>
<PERSISTEDVIEW>Accounting Voucher View</PERSISTEDVIEW>
<VCHGSTCLASS/>
<DIFFACTUALQTY>No</DIFFACTUALQTY>
<AUDITED>No</AUDITED>
<FORJOBCOSTING>No</FORJOBCOSTING>
<ISOPTIONAL>No</ISOPTIONAL>
<EFFECTIVEDATE>20130401</EFFECTIVEDATE>
<ISFORJOBWORKIN>No</ISFORJOBWORKIN>
<ALLOWCONSUMPTION>No</ALLOWCONSUMPTION>
<USEFORINTEREST>No</USEFORINTEREST>
<USEFORGAINLOSS>No</USEFORGAINLOSS>
<USEFORGODOWNTRANSFER>No</USEFORGODOWNTRANSFER>
<USEFORCOMPOUND>No</USEFORCOMPOUND>
<ALTERID>20</ALTERID>
<EXCISEOPENING>No</EXCISEOPENING>
<USEFORFINALPRODUCTION>No</USEFORFINALPRODUCTION>
<ISCANCELLED>No</ISCANCELLED>
<HASCASHFLOW>Yes</HASCASHFLOW>
<ISPOSTDATED>No</ISPOSTDATED>
<USETRACKINGNUMBER>No</USETRACKINGNUMBER>
<ISINVOICE>No</ISINVOICE>
<MFGJOURNAL>No</MFGJOURNAL>
<HASDISCOUNTS>No</HASDISCOUNTS>
<ASPAYSLIP>No</ASPAYSLIP>
<ISCOSTCENTRE>No</ISCOSTCENTRE>
<ISSTXNONREALIZEDVCH>No</ISSTXNONREALIZEDVCH>
<ISEXCISEMANUFACTURERON>No</ISEXCISEMANUFACTURERON>
<ISBLANKCHEQUE>No</ISBLANKCHEQUE>
<ISDELETED>No</ISDELETED>
<ASORIGINAL>No</ASORIGINAL>
<VCHISFROMSYNC>No</VCHISFROMSYNC>
<MASTERID>9</MASTERID>
<VOUCHERKEY>177657027231784</VOUCHERKEY>
<INVOICEDELNOTES.LIST> </INVOICEDELNOTES.LIST>
<INVOICEORDERLIST.LIST> </INVOICEORDERLIST.LIST>
<INVOICEINDENTLIST.LIST> </INVOICEINDENTLIST.LIST>
<ATTENDANCEENTRIES.LIST> </ATTENDANCEENTRIES.LIST>
<ORIGINVOICEDETAILS.LIST> </ORIGINVOICEDETAILS.LIST>
<INVOICEEXPORTLIST.LIST> </INVOICEEXPORTLIST.LIST>
<ALLLEDGERENTRIES.LIST>
<AMOUNT>200000.00</AMOUNT>
<OLDAUDITENTRYIDS.LIST TYPE="Number">
<OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS>
</OLDAUDITENTRYIDS.LIST>
<LEDGERNAME>'.$name.'</LEDGERNAME>
<GSTCLASS/>
<ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE>
<LEDGERFROMITEM>No</LEDGERFROMITEM>
<REMOVEZEROENTRIES>No</REMOVEZEROENTRIES>
<ISPARTYLEDGER>Yes</ISPARTYLEDGER>
<ISLASTDEEMEDPOSITIVE>No</ISLASTDEEMEDPOSITIVE>
<BANKALLOCATIONS.LIST></BANKALLOCATIONS.LIST>
<BILLALLOCATIONS.LIST></BILLALLOCATIONS.LIST>
<INTERESTCOLLECTION.LIST></INTERESTCOLLECTION.LIST>
<OLDAUDITENTRIES.LIST></OLDAUDITENTRIES.LIST>
<ACCOUNTAUDITENTRIES.LIST></ACCOUNTAUDITENTRIES.LIST>
<AUDITENTRIES.LIST></AUDITENTRIES.LIST>
<TAXBILLALLOCATIONS.LIST></TAXBILLALLOCATIONS.LIST>
<TAXOBJECTALLOCATIONS.LIST></TAXOBJECTALLOCATIONS.LIST>
<TDSEXPENSEALLOCATIONS.LIST></TDSEXPENSEALLOCATIONS.LIST>
<VATSTATUTORYDETAILS.LIST></VATSTATUTORYDETAILS.LIST>
<COSTTRACKALLOCATIONS.LIST></COSTTRACKALLOCATIONS.LIST>
</ALLLEDGERENTRIES.LIST>
<ALLLEDGERENTRIES.LIST>
<OLDAUDITENTRYIDS.LIST TYPE="Number">
<OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS>
</OLDAUDITENTRYIDS.LIST>
<LEDGERNAME>Bank of Maharashtra</LEDGERNAME>
<GSTCLASS/>
<ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
<LEDGERFROMITEM>No</LEDGERFROMITEM>
<REMOVEZEROENTRIES>No</REMOVEZEROENTRIES>
<ISPARTYLEDGER>Yes</ISPARTYLEDGER>
<ISLASTDEEMEDPOSITIVE>Yes</ISLASTDEEMEDPOSITIVE>
<AMOUNT>-200000.00</AMOUNT>
<BANKALLOCATIONS.LIST>
<DATE>20130401</DATE>
<INSTRUMENTDATE>20130401</INSTRUMENTDATE>
<BANKBRANCHNAME>Warje</BANKBRANCHNAME>
<TRANSACTIONTYPE>Cheque/DD</TRANSACTIONTYPE>
<BANKNAME>AXIS</BANKNAME>
<PAYMENTFAVOURING>'.$name.'</PAYMENTFAVOURING>
<INSTRUMENTNUMBER>50026</INSTRUMENTNUMBER>
<UNIQUEREFERENCENUMBER>38ROUrdV00QEKOhl</UNIQUEREFERENCENUMBER>
<STATUS>No</STATUS>
<CHEQUEPRINTED>-1</CHEQUEPRINTED>
<AMOUNT>-200000.00</AMOUNT>
</BANKALLOCATIONS.LIST>
<BILLALLOCATIONS.LIST></BILLALLOCATIONS.LIST>
<INTERESTCOLLECTION.LIST></INTERESTCOLLECTION.LIST>
<OLDAUDITENTRIES.LIST></OLDAUDITENTRIES.LIST>
<ACCOUNTAUDITENTRIES.LIST></ACCOUNTAUDITENTRIES.LIST>
<AUDITENTRIES.LIST></AUDITENTRIES.LIST>
<TAXBILLALLOCATIONS.LIST></TAXBILLALLOCATIONS.LIST>
<TAXOBJECTALLOCATIONS.LIST></TAXOBJECTALLOCATIONS.LIST>
<TDSEXPENSEALLOCATIONS.LIST></TDSEXPENSEALLOCATIONS.LIST>
<VATSTATUTORYDETAILS.LIST> </VATSTATUTORYDETAILS.LIST>
<COSTTRACKALLOCATIONS.LIST> </COSTTRACKALLOCATIONS.LIST>
</ALLLEDGERENTRIES.LIST>
<ATTDRECORDS.LIST> </ATTDRECORDS.LIST>
</VOUCHER>
</TALLYMESSAGE>
<TALLYMESSAGE xmlns:UDF="TallyUDF">
<COMPANY>
<REMOTECMPINFO.LIST MERGE="Yes">
<NAME>12</NAME>
<REMOTECMPNAME>SAVH</REMOTECMPNAME>
<REMOTECMPSTATE>Maharashtra</REMOTECMPSTATE>
</REMOTECMPINFO.LIST>
<REMOTECMPINFO.LIST MERGE="Yes">
<NAME>f6c10ce3-4a15-42b8-961e-143a512a9e62</NAME>
<REMOTECMPNAME>SAVH</REMOTECMPNAME>
<REMOTECMPSTATE>Maharashtra</REMOTECMPSTATE>
</REMOTECMPINFO.LIST>
</COMPANY>
</TALLYMESSAGE>
<TALLYMESSAGE xmlns:UDF="TallyUDF">
<COMPANY>
<REMOTECMPINFO.LIST MERGE="Yes">
<NAME>12</NAME>
<REMOTECMPNAME>SAVH</REMOTECMPNAME>
<REMOTECMPSTATE>Maharashtra</REMOTECMPSTATE>
</REMOTECMPINFO.LIST>
<REMOTECMPINFO.LIST MERGE="Yes">
<NAME>f6c10ce3-4a15-42b8-961e-143a512a9e62</NAME>
<REMOTECMPNAME>SAVH</REMOTECMPNAME>
<REMOTECMPSTATE>Maharashtra</REMOTECMPSTATE>
</REMOTECMPINFO.LIST>
</COMPANY>
</TALLYMESSAGE>
</REQUESTDATA>
</IMPORTDATA>
</BODY>
</ENVELOPE>';
/* Actual code for importing goes here */
$server = 'localhost:9000';
$headers = array( "Content-type: text/xml" ,"Content-length: ".strlen($requestXML) ,"Connection: close" );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $server);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
if(curl_errno($ch)){
print curl_error($ch);
echo " something went wrong..... try later";
}else{
echo " request accepted";
print $data;
curl_close($ch);
}
}
?>
Hi, i followed your post but I'm getting this error - request accepted Could not set 'SVCurrentCompany' to 'SAVH'
ReplyDeleteHi Dheeraj,
DeleteThanks for using my code. Actually you have to enter your company name from Tally in SVCURRENTCOMPANY tag.
can you tell me , actually this is accounting voucher type, so if we suppose to import inventory voucher type
Deletewhat we suppose to do, thanks in advance
I have found this code very useful and it has worked exactly as it is stated here but now I want to make a bunch of vouchers and import them in to Tally in one go. What changes would I need to make in some of the fields mentioned above? I want to know especially how to get the UNIQUEREFERENCENUMBER and some of the other fields. Please help. Thanks in advance!
ReplyDeletePHP code for Export data
ReplyDeletehttp://coimbatore-biz.com/blog/techsupport/Tally%20Integration%20Capabilitiesp0st412
Hey! Your code worked perfectly. Thanks a lot.
ReplyDeleteThank you so much.
DeleteHello Ketan,
ReplyDeletecan you help me to get UDF field value of a ledger using XML.
message:-License server is Running but data not posted in tally.....provide solution
ReplyDeleteCheck the port number where tally is running and try running
Deletehi got this error: request accepted Proper Pay Link Name not given for 'Bank of Maharashtra'! 0 0 0 0 0 0 0 1 0
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeletehi ketan
ReplyDeleteit gives me error that ledger does not exist
first create ledger in tally
Deleteoutput: request accepted 0 0 0 0 0 0 1 0
ReplyDeletebut data not inserted in tally whats reason.
please explain the unique reference number in bankallocation.list tag
ReplyDeleteI Got a message...
ReplyDelete"request accepted Voucher totals do not match! Dr: Cr: 2,00,000.00 Cr Diff: 2,00,000.00 Cr 0 0 0 0 0 0 0 1 0"
But data not inserted into Tally..
Deleteexecuting above code gives the following error : - Recv failure: Connection was reset something went wrong..... try later
ReplyDeleteThis happens when try to insert the same data (execute the above script) twice, the first one will be successfull by if you try again this error will come and tally will shutdown, seems crashing, any one can help why?
Deletepriyanka have u done tally integration?
ReplyDeleteHi,
ReplyDeletewhile insert ladger more than one company i am not success only inserted in a company all ledger please help me for import xml data in group company and also provide xml file
How GUID, AlterId and MasterId is generated for XML tally. Also is there any resource where I can get detailed reference on tally XML formats so that I can generate XML file for different tally operations?
ReplyDeletegetting this error request accepted Ledger 'piyu' does not exist! 0 0 0 0 0 0 1
ReplyDelete