无法在 Tally API 中使用 XML 请求获取 UDF 字段

问题描述 投票:0回答:1

我正在使用以下 xml 请求从 Tally 获取优惠券,并给出以下输出。

<ENVELOPE>
    <HEADER>
        <VERSION>1</VERSION>
        <TALLYREQUEST>Export</TALLYREQUEST>
        <TYPE>Data</TYPE>
        <ID>DaybookGR</ID>
    </HEADER>
    <BODY>
        <DESC>
            <STATICVARIABLES>
                <EXPLODEFLAG>Yes</EXPLODEFLAG>
                <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
            
            </STATICVARIABLES>
            <TDL>
                <TDLMESSAGE>
                    <REPORT NAME="DaybookGR">
                        <FORMS>DaybookGR</FORMS>
                        <TITLE>DaybookGR </TITLE>
                    </REPORT>
                    <FORM NAME="DaybookGR">
                        <TOPPARTS>DaybookGR</TOPPARTS>
                        <XMLTAG>"TallyGraphs"</XMLTAG>
                    </FORM>
                    <PART NAME="DaybookGR">
                        <TOPLINES>Daybook Line Title, Daybook Details</TOPLINES>
                        <REPEAT>Daybook Details : GetLedgerCollAmt</REPEAT>
                        <SCROLLED>Vertical</SCROLLED>
                        <COMMONBORDERS>Yes</COMMONBORDERS>
                    </PART>
                    <PART NAME="Ledgerlist Line Title">
                        <TOPLINES>Ledger Details</TOPLINES>
                        <REPEAT>Ledger Details:LedgerEntries</REPEAT>
                        <SCROLLED>Vertical</SCROLLED>
                        <COMMONBORDERS>Yes</COMMONBORDERS>
                    </PART>
                   
                    <LINE NAME="Daybook Line Title">
                        <USE>Daybook Details</USE>
                        <LOCAL>Field : Default : Type : String </LOCAL>
                        <LOCAL>Field : Field Amount : Set as: "Amount"</LOCAL>
                    </LINE>
                    <LINE NAME="Ledgerlist Line Title">
                        <USE>Ledger Details</USE>
                        <LOCAL>Field : Default : Type : String </LOCAL>
                        <LOCAL>Field : Field Amount : Set as: "Amount"</LOCAL>
                    </LINE>
                    <LINE NAME="Daybook Details">
                        <LEFTFIELDS>PartyLedgerName</LEFTFIELDS>
                        <RIGHTFIELDS>vchType,VoucherNumber,Amount,Date</RIGHTFIELDS>
                        <XMLTAG>Voucher</XMLTAG>
                        <EXPLODE>Ledgerlist Line Title</EXPLODE>
                    </LINE>
                    <LINE NAME="Ledger Details">
                        <LEFTFIELDS>PartyLedgerName,PartyAmount,IsPartyLedger</LEFTFIELDS>
                        <RIGHTFIELDS>UserD</RIGHTFIELDS>
                        <XMLTAG>LedgerList</XMLTAG>
                    </LINE>
                    
                    <FIELD NAME="PartyLedgerName">
                        <USE>Name Field</USE>
                        <SET>$LedgerName</SET>
                    </FIELD>
                    <FIELD NAME="PartyAmount">
                        <USE>Name Field</USE>
                        <SET>$Amount</SET>
                    </FIELD>
                    <FIELD NAME="IsPartyLedger">
                        <USE>Name Field</USE>
                        <SET>$ISPARTYLEDGER</SET>
                    </FIELD>
                    <LINE NAME="UserD Details">
                        <LEFTFIELDS>UserD</LEFTFIELDS>
                        <XMLTAG>UserList</XMLTAG>
                    </LINE>
                    <FIELD NAME="UserD">
                        <USE>Name Field</USE>
                        <SET>$USERDESCRIPTION</SET>
                    </FIELD>
                    <FIELD NAME="Date">
                        <USE>Long Date Field</USE>
                        <SET>$$DDMMYYYYDateFormat:$Date:"-"</SET>
                    </FIELD>
                    <FIELD NAME="VoucherNumber">
                        <USE>Name Field</USE>
                        <SET>$VoucherNumber</SET>
                    </FIELD>
                    <FIELD NAME="Amount">
                        <USE>Amount Field</USE>
                        <SET>$Amount</SET>
                    </FIELD>
                    <COLLECTION NAME="AllVouchers" ISMODIFY="No">
                        <TYPE>Voucher</TYPE>
                        <BELONGSTO>YES</BELONGSTO>
                    </COLLECTION>
                    
                    <COLLECTION NAME="GetLedgerCollAmt" ISMODIFY="No">
                        <SourceCOLLECTION>AllVouchers</SourceCOLLECTION>
                        <FILTER>IsOptionalFilter</FILTER>
                        <FETCH>Ledgerentries.*</FETCH>
                    </COLLECTION>
                    <SYSTEM TYPE="Formulae" NAME="IsOptionalFilter">NOT $IsOptional</SYSTEM>
                </TDLMESSAGE>
            </TDL>
        </DESC>
    </BODY>
</ENVELOPE>

这是我的输出:

<TALLYGRAPHS>
    <VOUCHER>
        <PARTYLEDGERNAME>Think Era</PARTYLEDGERNAME>
        <VOUCHERTYPENAME>Sales</VOUCHERTYPENAME>
        <VOUCHERNUMBER></VOUCHERNUMBER>
        <AMOUNT>-10000.00</AMOUNT>
        <DATE></DATE>
        <LEDGERLIST>
            <PARTYLEDGERNAME>Think Era</PARTYLEDGERNAME>
            <PARTYAMOUNT>10,000.00</PARTYAMOUNT>
            <ISPARTYLEDGER>Yes</ISPARTYLEDGER>
            <USERD></USERD>
        </LEDGERLIST>
        <LEDGERLIST>
            <PARTYLEDGERNAME>Website Development</PARTYLEDGERNAME>
            <PARTYAMOUNT>10,000.00</PARTYAMOUNT>
            <ISPARTYLEDGER>No</ISPARTYLEDGER>
            <USERD></USERD>
        </LEDGERLIST>
    </VOUCHER>
    <VOUCHER>
        <PARTYLEDGERNAME>Think Era</PARTYLEDGERNAME>
        <VOUCHERTYPENAME>Sales</VOUCHERTYPENAME>
        <VOUCHERNUMBER></VOUCHERNUMBER>
        <AMOUNT>-10000.00</AMOUNT>
        <DATE></DATE>
        <LEDGERLIST>
            <PARTYLEDGERNAME>Think Era</PARTYLEDGERNAME>
            <PARTYAMOUNT>10,000.00</PARTYAMOUNT>
            <ISPARTYLEDGER>Yes</ISPARTYLEDGER>
            <USERD></USERD>
        </LEDGERLIST>
        <LEDGERLIST>
            <PARTYLEDGERNAME>Website Development</PARTYLEDGERNAME>
            <PARTYAMOUNT>10,000.00</PARTYAMOUNT>
            <ISPARTYLEDGER>No</ISPARTYLEDGER>
            <USERD>Testinbg Created</USERD>
        </LEDGERLIST>
    </VOUCHER>
    <VOUCHER>
        <PARTYLEDGERNAME>IBIRDS</PARTYLEDGERNAME>
        <VOUCHERTYPENAME>Sales</VOUCHERTYPENAME>
        <VOUCHERNUMBER></VOUCHERNUMBER>
        <AMOUNT>-5000.00</AMOUNT>
        <DATE></DATE>
        <LEDGERLIST>
            <PARTYLEDGERNAME>IBIRDS</PARTYLEDGERNAME>
            <PARTYAMOUNT>5,000.00</PARTYAMOUNT>
            <ISPARTYLEDGER>Yes</ISPARTYLEDGER>
            <USERD></USERD>
        </LEDGERLIST>
        <LEDGERLIST>
            <PARTYLEDGERNAME>Mobile App</PARTYLEDGERNAME>
            <PARTYAMOUNT>5,000.00</PARTYAMOUNT>
            <ISPARTYLEDGER>No</ISPARTYLEDGER>
            <USERD></USERD>
        </LEDGERLIST>
    </VOUCHER>
    <VOUCHER>
        <PARTYLEDGERNAME>Think Era</PARTYLEDGERNAME>
        <VOUCHERTYPENAME>Sales</VOUCHERTYPENAME>
        <VOUCHERNUMBER></VOUCHERNUMBER>
        <AMOUNT>-46000.00</AMOUNT>
        <DATE></DATE>
        <LEDGERLIST>
            <PARTYLEDGERNAME>Think Era</PARTYLEDGERNAME>
            <PARTYAMOUNT>46,000.00</PARTYAMOUNT>
            <ISPARTYLEDGER>Yes</ISPARTYLEDGER>
            <USERD></USERD>
        </LEDGERLIST>
        <LEDGERLIST>
            <PARTYLEDGERNAME>Other Payables</PARTYLEDGERNAME>
            <PARTYAMOUNT>6,000.00</PARTYAMOUNT>
            <ISPARTYLEDGER>No</ISPARTYLEDGER>
            <USERD>This Is Great</USERD>
        </LEDGERLIST>
        <LEDGERLIST>
            <PARTYLEDGERNAME>Website Development</PARTYLEDGERNAME>
            <PARTYAMOUNT>40,000.00</PARTYAMOUNT>
            <ISPARTYLEDGER>No</ISPARTYLEDGER>
            <USERD>New E-Commerce</USERD>
        </LEDGERLIST>
    </VOUCHER>
</TALLYGRAPHS>

这里唯一的问题是我没有获得与 Ledger 关联的所有用户描述。例如,在上面的回复中,我在凭证号 4 下有两个分类帐(其他应付账款)的用户描述,但只得到第一个“这太棒了”。以下是统计中列出的实际数据:

<VOUCHER>
    ...
    <LEDGERLIST>
        ...
        <UDF:USERDESCRIPTION.LIST DESC="`User Description`" ISLIST="YES" TYPE="String" INDEX="29">
            <UDF:USERDESCRIPTION DESC="`User Description`">This is Great</UDF:USERDESCRIPTION>
            <UDF:USERDESCRIPTION DESC="`User Description`">Project-Zuperscore</UDF:USERDESCRIPTION>
            <UDF:USERDESCRIPTION DESC="`User Description`">Chandra Prakash- Working Days 19</UDF:USERDESCRIPTION>
            <UDF:USERDESCRIPTION DESC="`User Description`">125000/22x19=107954.55</UDF:USERDESCRIPTION>
        </UDF:USERDESCRIPTION.LIST>
        ...
    </LEDGERLIST>
</VOUCHER>

如何更改我的请求以获取所有 UDF:USERDESCRIPTION?

xml user-defined-functions tally tdl
1个回答
0
投票

正如我在如何限制Tally XML导出响应中的嵌套字段中提到的,这种类型的xml很复杂并且需要TDL知识

您所指的 USERDESCRIPTION 是集合的一部分,而不是简单的字段,因此它需要自己的部分和行

在“分类帐详细信息”行中添加以下行并删除“UserD”

 <EXPLODE>TC_LedgerEntryUserDescriptionsList:YES</EXPLODE>

添加以下部分和行

<PART
    NAME="TC_LedgerEntryUserDescriptionsList"
    ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No">
    <TOPLINES>
        TC_LedgerEntryUserDescriptionsList</TOPLINES>
    <REPEAT>TC_LedgerEntryUserDescriptionsList
        : USERDESCRIPTION</REPEAT>
    <SCROLLED>Vertical</SCROLLED>
    <XMLTAG>USERDESCRIPTION.LIST</XMLTAG>
</PART>
<LINE
    NAME="TC_LedgerEntryUserDescriptionsList"
    ISMODIFY="No" ISFIXED="No" ISINITIALIZE="No" ISOPTION="No" ISINTERNAL="No">
    <FIELDS>UserD</FIELDS>
</LINE>
© www.soinside.com 2019 - 2024. All rights reserved.