Soap request to pull last sale value to specific party

Discussion in 'Tally Integration' started by Sigh, Jan 24, 2022.

    
  1. Sigh

    Sigh New Member


    I am trying to pull data from tally. But I don't know the table names or anything.

    SQL equivalent of what I want is

    Select price, discount, qty, itemname from InvoiceVoucher where PartyName ="ABC Company" and stockItem like "%Coca Cola%"

    Xml request or SQL requests.

    I don't know tdl but I know you can do tdl requests in XML requests which is fine.

    Thanks in advance.
     


  2. Sai Vineeth

    Sai Vineeth Active Member

    Last edited: Jan 24, 2022


  3. Sigh

    Sigh New Member


    Thank you for the response.

    Dear Sai,

    I was practically living of that site for the last couple of months until I found this site about 2 weeks ago and I have been reading a lot.

    I sort of understand TDL but I don't where to get the variable names.

    My favorite way of getting data from Tally right now is

    Code:
    <ENVELOPE>
      <HEADER>
        <TALLYREQUEST>Export Data</TALLYREQUEST>
      </HEADER>
      <BODY>
        <EXPORTDATA>
          <REQUESTDESC>
            <REPORTNAME>ODBC Report</REPORTNAME>
            <SQLREQUEST Type="General" Method="Select $Name, $ClosingBalance, $BaseUnits, $MasterID from StockItem where $Name like '%" + searchBoxTB.Text + "%' or $$Alias like '%" + searchBoxTB.Text + "%'"
            <STATICVARIABLES>
              <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
            </STATICVARIABLES>
          </REQUESTDESC>
          <REQUESTDATA />
        </EXPORTDATA>
      </BODY>
    </ENVELOPE>
    After which I am filtering the results with


    Code:
    <ENVELOPE>
      <HEADER>
        <TALLYREQUEST>Export Data</TALLYREQUEST>
      </HEADER>
      <BODY>
        <EXPORTDATA>
          <REQUESTDESC>
            <STATICVARIABLES>
              <SVFROMDATE>20210724</SVFROMDATE>
              <SVTODATE>20220124</SVTODATE>
              <STOCKITEMNAME>Coca Cola</STOCKITEMNAME>
            </STATICVARIABLES>
            <REPORTNAME>STOCKVOUCHERS</REPORTNAME>
          </REQUESTDESC>
        </EXPORTDATA>
      </BODY>
    </ENVELOPE>
    It works but I just want to make it neater. Have it pull once and only the specific data instead of 2 times and full history.
     


  4. Sai Vineeth

    Sai Vineeth Active Member


    D
    Did you gone through xmls provided ?
    It covers your requirements

    the approach , what your are following looks good
    the approach, what you want to achieve is not good as if user as less data it is ok to fetch all data at once , but if we large data in Tally and you try to fetch all stock items at once, request will take so much time or tally will hang
    So follow the 2 step approach only but to get list use xmls in collection folder(as using raw sql is not necessary) and to get individual objects use xmls in objects folder
     


  5. Sigh

    Sigh New Member


    So you are saying SQL is heavier?
     


  6. Sigh

    Sigh New Member


    also is it possible to filter this code with Ledger

    Code:
    <ENVELOPE>
      <HEADER>
        <TALLYREQUEST>Export Data</TALLYREQUEST>
      </HEADER>
      <BODY>
        <EXPORTDATA>
          <REQUESTDESC>
            <STATICVARIABLES>
              <SVFROMDATE>20210724</SVFROMDATE>
              <SVTODATE>20220124</SVTODATE>
              <STOCKITEMNAME>Coca Cola</STOCKITEMNAME>
            </STATICVARIABLES>
            <REPORTNAME>STOCKVOUCHERS</REPORTNAME>
          </REQUESTDESC>
        </EXPORTDATA>
      </BODY>
    </ENVELOPE>
    Code above pulls all sales for Coca Cola I am pulling that and then filtering it in C# for ledger.
     


  7. Sai Vineeth

    Sai Vineeth Active Member


    If you are using c# you can use TallyConnector Library to connect with Tally,
    To get Sales Vouchers by Ledger Use below code
    Code:
    StaticVariables sv = new()
                {
                    SVExportFormat = "XML",
                    SVFromDate = "20210724",
                    SVToDate = "20220124",
                    ViewName = "Accounting Voucher View",
                };
                List<string> Nativelist = new() { "GUID", "*" };
                List<string> Filters = new() { "IsSales"};
                List<string> SystemFilters = new() { "$$IsSales:$VOUCHERTYPENAME" };
    #Change Childof: arg as per your requirements
                string xml = await TTally.GetNativeCollectionXML(rName: "Vouchers", colType: "Vouchers : StockItem", Sv: sv, childof: "Coca Cola",
                                                          NativeFields: Nativelist,Filters:Filters,SystemFilters:SystemFilters);
                List<Voucher> Vouchers = TTally.GetObjfromXml<VoucherEnvelope>(xml).Body.Data.Collection.Vouchers;
    
                Vouchers will be list where you can iterate through
    

    or if you want to use xml only then use
    Code:
    <ENVELOPE>
        <HEADER>
            <VERSION>1</VERSION>
            <TALLYREQUEST>Export</TALLYREQUEST>
            <TYPE>Collection</TYPE>
            <ID>Vouchers</ID>
        </HEADER>
        <BODY>
            <DESC>
                <STATICVARIABLES>
                    <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
                    <SVFROMDATE TYPE="Date">20210724</SVFROMDATE>
                    <SVTODATE TYPE="Date">20220124</SVTODATE>
                    <SVViewName>Accounting Voucher View</SVViewName>
                </STATICVARIABLES>
                <TDL>
                    <TDLMESSAGE>
                        <COLLECTION ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No" NAME="Vouchers">
                            <TYPE>Vouchers : StockItem</TYPE>
                            <CHILDOF>Coca Cola</CHILDOF>
                            <NATIVEMETHOD>GUID</NATIVEMETHOD>
                            <NATIVEMETHOD>*</NATIVEMETHOD>
                            <FILTERS>IsSales</FILTERS>
                        </COLLECTION>
                        <SYSTEM TYPE="Formulae" NAME="IsSales">$$IsSales:$VOUCHERTYPENAME</SYSTEM>
                    </TDLMESSAGE>
                </TDL>
            </DESC>
        </BODY>
    </ENVELOPE>
     


Share This Page