Can anyone tell how this code is working

Discussion in 'Tally Developer' started by Vivian Fernandes, Feb 13, 2023.

    
  1. Vivian Fernandes

    Vivian Fernandes New Member


    I have seen a video on YouTube and I have a similar requirement but i want to do it for stock item not for ledgers. I don't want to contact this developer because he has very high ego. Everyone says that he is a fraud. He doesn't talk nicely on calls, either.



    This is the video.

    Can anyone please tell how this collection is working.
     


  2. Himanshu-2002

    Himanshu-2002 Active Member


    It's simple tdl, But Explaining the whole logic will be difficult because It will be lengthy...You can start building UI...I'll try to help you Print/Export Function
     


  3. Vivian Fernandes

    Vivian Fernandes New Member


    ok sir
    I will prepare the whole UI, then ask u for the help.

    Thank you so much for helping :D:oops:
     


  4. ch ruchitha

    ch ruchitha Member


    Yes sir.
     


  5. Vivian Fernandes

    Vivian Fernandes New Member


    please tell
     


  6. Vivian Fernandes

    Vivian Fernandes New Member


    Hello sir, I have prepared the UI of the report, now can you please help me to get the required filter in the collection.
    From the given, example, I want that selected part will show the entries of item 1 and 4 only.

    My code is given below the image.

    Screenshot 2023-02-21 145813.jpg


    Code:
    [#Menu:gateway of tally]
    Add :     Key Item        : "T : Item Retails Sales"            : T : Alter        : ItemList
    
    [Report:ItemList]
        Form:ItemList
        Object:company
       
    [Form:ItemList]
        Part:ItemList
        No Confirm:Yes
        Horizontal Align: Left
        On:Form Accept:Yes:Form Accept
        On:Form Accept:Yes:Display:ItemDisplay
           
    [Part:ItemList]
        Line:ItemListTitle, ItemList
        Repeat:ItemList:ItemListVAL
        Break On:#ItemList = $$SysName:Endoflist
        Scroll:Vertical
       
    [Line:ItemList title]
        Field:Sno, ItemList
        Local:Field:Sno:Info:"Sr No."
        Local:Field:ItemList:Info:"Select item list"
        Local:Field:default:Delete:Storage
        Border:column titles
       
    [Line:ItemList]
        Field:Sno, ItemList
       
    [Field:sno]
        Use:name field
        Set as:$$LocaleString:$$Line + "."
        Width:5
        Align:Right
        Space Right:1
        Skip:Yes
        Border:thin right
       
    [Field:ItemList]
        Use:name field
        Table: ItemList,Endoflist
        Show Table: Always
        Storage:ItemList
        Width:28
    
    [System:UDF]
        ItemListVAL:Aggregate:935
        ItemList:String:931
    
    [Collection:ItemList]
        Title: "Stock Item List"
        Sub Title: "Name", "Group", "Category", "StkItmName"
        Type:Stockitem
        Fetch:*
        Align:Right
        Full Height:Yes
        Format: $stockitemname, 35
        Format: $parent, 15
        Format: $category, 20
        Format: $baseStkItmNames, 10
    
    ;;===================================== Report ItemDisplay =======================================
    [Report:ItemDisplay]
        Form:ItemDisplay
        Variable:svtodate, Svfromdate, ExplodeFlag
        Set: SVFromDate : $$CurrentDate - 7
        Set: SVtoDate : $$CurrentDate
        Set: Explode Flag : no
    
    [Form:ItemDisplay]
        Top Part: ItemDisplay Heading, ItemDisplay titles
        Part: ItemDisplay Details
        Bottom Part: ItemDisplay Total;, Dev by
        Button: Change period, Explode Flag
    
    ;;--------------------------------------------------- Heading part
       
    [Part:ItemDisplay Heading]
        Line:ItemDisplay Heading, DateLine
       
    [Line:ItemDisplay Heading]
        Field:ItemDisplay Heading
       
    [Field:ItemDisplay Heading]
        Field:Name field
        Local:Field:Name Field: Info:" ITEM RETAIL SALES "
        Local:Field:Name Field: Align:Center
        Local:Field:Name field: Wide Space: Yes
        Local:Field:Name field: Width:100% page
        Local:Field:Name field: Style:Normal bold
        Local:Field:name field: Local:Style:default:Height:12
       
    [Line:Date line]
        Right Field: Date Field
       
    [Field:Datefield]
        Use:Name field
        Set As : "Form " + $$String:##SVFromDate + " To " + $$String:##SVToDate
    
    ;;;------------------------ Title Part ---------------------------------
    
    [Part:ItemDisplay Titles]
    Line:ItemDisplay Titles
    
    [Line:ItemDisplay Titles]
        Left Field: S no, ID List, Name field, ID Qty, ID PartyName, ID Parent
        Local:Field:S No            : Info        : "Sno"
        Local:Field:ID List            : Info        : "Items Name"
        Local:Field:name field        : Info        : "Sno"
        Local:Field:ID Qty            : Info        : "Qty"
        Local:Field:ID PartyName    : Info        : "Party"
        Local:Field:ID Parent        : Info        : "Market"
    ;    Local:Field:S No            : Width        : 5% screen
        Local:Field:name field        : Width        : 5% screen
    
        Border: Column Titles
    
    [Part:ItemDisplay Details]
        Part:ItemDisplaylist, ItemDisplay Values
       
    [Part:ItemDisplaylist]
        Line            : ItemDisplay List
        Repeat            : ItemDisplay List    : IDColl
        Break On        : $$IsEmpty:#ItemDisplayName
        Scroll            : Vertical
        Common Border    : Yes
       
    [Collection:IDColl]
        Type:ItemListVAL:company
        Child Of:##SVCurrentCompany
       
    [Line:ItemDisplay List]
        Field:S no, ID List
       
    [Field: ID List]
        Use        : Name Field
        Set as    : $ItemList
        Width    : 30% Page
        Border    : thin right
        Indent    : 2
       
    ;;-------------------------------------------------------
    
    [Part: ItemDisplayValues]
        Line:ItemDisplayValues
        Repeat:ItemDisplayValues: IDV COll
        Scroll: Vertical
       
    [Line:ItemDisplayValues]
        Field: Sno, ID StkItmName, ID Qty, ID PartyName, ID Parent
    
    [Field:ID StkItmName]
        Use        : StkItmName Field
        Set as    : $StkItmName
        Width    : 15% Page
        Style    : Normal
    
    [Field:ID Qty]
        Use        : number Field
        Set as    : $qty
        Width    : 7.5% Page
        Style    : Normal
       
    [Field:ID PartyName]
        Use:Name field
        Set as    : $name
        Width    : 25% page
    
    [Field:ID Parent]
        Use        : Name Field
        Set as    : $parent:ledger:#IDPrtName
        Width    : 10% Page
    
    [Collection: IDV Main Coll]
        Type: Vouchers:vouchertype
        Child Of: $$VchTypeSales
        Belongs To: Yes
        Fetch: *
       
    [Collection:IDV Coll]
        Source Collection:IDV Main Coll
        Walk        : All Inventory Entries
        By: name     : $partyledgername
        By: StkItmName    : $Stockitemname
        Aggr Compute: qty : Sum:$billedqty
        Fetch        : stockitemname, partyledgername, billedqty , baseStkItmNames
    ;    Filter        : ID Filter
       
    [System:Formulae]
        ID Filter : $stockitemname = $Itemlist
        ;$(Company,##svcurrentcompany).ItemListVal[1].stockitemname
        ;Contains #IDList
    
    [Part:ItemDisplay Total]
        Line        : ItemDisplay Total
    
    [Line: ItemDisplay Total]
        left Field:Short prompt, ItemDisplay Total
        Local:Field:Short Prompt : Info: "Total :"
        Local:Field:Short Prompt : Space Left: 5
        Local:Field:Short Prompt : Width: 10
        Border: Totals
       
    [Field:ItemDisplay Total]
        Use:Number field
        Set as: 123
        Width: 15% page
        Style:Normal
        Space Left: 2
        Format: "No Zero, decimal : 2"
        Align: Left
    
     


  7. Himanshu-2002

    Himanshu-2002 Active Member


    You can get the data of the Main Report using this:

    [Collection: Parent Report Collection]
    Data Source: Parent Report: Selected

    After creating this collection, In the sub report you can add a filter to your collection and verify if current object belongs to parent Collection.

    Example:

    MyCustomFilter:$$IsStockItemsBelongsTo:$Name

    Now, You need to define the function

    [Function: IsStockItemBelongsTo]
    Parameter: Item Name: String

    Now, walk into the collection and using if return a logical value
     


  8. Vivian Fernandes

    Vivian Fernandes New Member



    Actually, I am learning TDL development and don't know much about [Functions] and walk collection as of now.
    Can u please help me a bit more?
     


  9. Vivian Fernandes

    Vivian Fernandes New Member


    Should I have to do like this ?????


    [Collection:IDV Coll]
    Source Collection:IDV Main Coll
    Walk : All Inventory Entries
    By: name : $partyledgername
    By: StkItmName : $Stockitemname
    Aggr Compute: qty : Sum:$billedqty
    Fetch : stockitemname, partyledgername, billedqty , baseStkItmNames
    Filter : ID Filter

    [System:Formulae]
    ID Filter :$$IsStockItemsBelongsTo:$Name

    [Collection: Parent Report Collection]
    Data Source: Parent Report: Selected

    [Function: IsStockItemsBelongsTo]
    Parameter: Item Name: String
    01 : Walk Collection: Parent Report Collection
    02 :
     


  10. Himanshu-2002

    Himanshu-2002 Active Member


    [Collection:IDV Coll]
    Source Collection:IDV Main Coll
    Walk : All Inventory Entries
    By: name : $partyledgername
    By: StkItmName : $Stockitemname
    Aggr Compute: qty : Sum:$billedqty
    Fetch : stockitemname, partyledgername, billedqty , baseStkItmNames
    Filter : ID Filter

    [System:Formulae]
    ID Filter :$$IsStockItemsBelongsTo:$stockitemname

    [Collection: Parent Report Collection]
    Data Source: Parent Report: Selected

    [Function: IsStockItemsBelongsTo]
    Parameter: Item Name: String
    01 : Walk Collection: Parent Report Collection
    02 :If:($$IsEqual:##ItemName:$Name)
    03:Return:Yes
    04:Else
    05:Return:No
    06:EndWalk

    At Label no 2, I am checking if my stock item name matches with selected one...
     
    Vivian Fernandes likes this.


  11. Vivian Fernandes

    Vivian Fernandes New Member


    I tried this but it doest work properly, so I tried an alternative that worked according to my requirement. Posting the code I used for 2 lines but made the actual code working till 30 lines.

    If anyone has a better solution to that, please help.

    Code:
    [Collection: IDV Main Coll]
        Type: Vouchers:vouchertype
        Child Of: $$VchTypeSales
        Belongs To: Yes
        Fetch: *
       
    [Collection:IDV Coll]
        Source Collection:IDV Main Coll
        Walk        : All Inventory Entries
        By: name     : $partyledgername
        By: unit    : $Stockitemname
        Aggr Compute: qty : Sum:$billedqty
        Fetch        : stockitemname, partyledgername, billedqty , baseunits
        Filter        : ID Filter
       
    [System:Formulae]
        ID Filter : $stockitemname = @@itemlistfltr1 or +
                    $stockitemname = @@itemlistfltr2
    
    [System:Formulae]
    ItemListFltr1 : $$CollectionField:$ItemList:1:IDColl
    ItemListFltr2 : $$CollectionField:$ItemList:2:IDColl
     


  12. Himanshu-2002

    Himanshu-2002 Active Member


    Currently your code will for first two stock item names only, There are many methods for this problems

    1. My Given Solution
    2. CollectionFieldByKey
    3. FilterValue
    4. Function (Using Array instead of Collection to check values)
    5. FilterCount
    6. Function(Construct the Collection based on input using List Variable)
    7. Etc

    Hope this helps :)
     


  13. Vivian Fernandes

    Vivian Fernandes New Member


    I made the actual report for 30 items but I posted for 2 items only so it won't be long here.

    Please provide any alternative method to solve this problem like how can I use these :
    1. My Given Solution
    2. CollectionFieldByKey
    3. FilterValue
    4. Function (Using Array instead of Collection to check values)
    5. FilterCount
    6. Function(Construct the Collection based on input using List Variable)
     


  14. Himanshu-2002

    Himanshu-2002 Active Member


    These are all functions... Check there parameters, Possible use cases... Try to align their use case with yours and implement it
     


Share This Page