Reached a new milestone in collections

Discussion in 'Tally Developer' started by Lynch, Sep 26, 2021.

    
  1. Lynch

    Lynch Member


    When I first enter into the TDL programming dimension, I was some how okay with the Interface objects such as Reports, Forms, Parts, etc.,

    Creating a form to retain the values entered therein, require a basic understanding of Aggregate Data type. And to display the form, I need to study the Collection and that's where I stumped upon couple of years. Slowly, the importing functions and its collection objects let me understand a little bit.

    And, One day I saw a post for using MS-Suite to print various reports...That's where I learned to use the "by" keywords of Collection, And now, I'm posting the new learning outcome, the Keyword "Compute". I've used it to read GSTR2B Json file and bypass it to a collection and then populate it to my report.

    Here's the code I'm pasting, may be new learners in TDL can use it and they might can extend the code to further use
    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;File Configuration Screen;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    [Report:GSTR2B Reckon config]
        Form:GSTR2B Json file selector
       
        [Form:GSTR2B Json file Selector]
            Part:Form Subtitle, File selector Body
            Local:Field:Form Subtitle:Set as:"Select the GSTR2B Json File"
       
            [Part:File Selector Body]
                Line:json file path
                   
                [Line:Json file path]
                    Space Top:2
                    Left Field:Medium Prompt, json folder
                    Right Field:short Prompt, Json File Path
                    Local:Field:short Prompt:Set as:"Select the File:"
                    Local:Field:Medium Prompt:Set as:"Select the Folder:"
                    Local:Field:Medium Prompt:Width       : @@MediumWidth*2
                    Local:Field:Medium Prompt:Space Left:2
                    Local:Field:Medium Prompt:Background:Blue
                    Local:Field:Medium Prompt:Color:White
                    Local:Field:Medium Prompt:Border:Thin Box pink
                    Local:Field:short prompt:Width       : @@ShortWidth + @@ShortWidth/2
                    Local:Field:short Prompt:Space Left:2
                    Local:Field:short Prompt:Background:Blue
                    Local:Field:short Prompt:Color:White
                    Local:Field:short Prompt:Border:Thin Box pink
           
                   
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GSTR2B Report populated from Json file downloaded from GST Common Portal;;;;;;;;;;;;;;;;;;;;;;
    [Report:GSTR2B Recon]
        Form:GSTR2B Recon
        [Form:GSTR2B Recon]
            Parts:form subtitle, GSTR2B Body
            Local:Field:form subtitle:Info:"GSTR2B Reconciliation"
            [Part: GSTR2B Body]
                Part            : GSTR2B Body part, GSTR2B Bottom part
                Vertical        : Yes
            [Part:GSTR2B Body Part]       
                Line: GSTR2A title line, GSTIN from Jason
                Repeat:GSTIN from Jason:my json b2b collection
                Total: GSTR2Btaxable value, GSTR2BIGST, GSTR2BCGST, GSTR2BSGST, InvocietotValue
                Common Border:Yes
                Scroll:Both
                [Line:GSTR2A title line]
                    left Field: InvoiceDate,    InvoiceNumber,     SupplierGSTIN,    SupplyName
                    Right Field: GSTR2Btaxable value, GSTR2Brate, GSTR2BIGST, GSTR2BCGST, GSTR2BSGST, InvocietotValue,    Supplyfileddt,    Supplyprd,    ITCAvailable,    PlaceofSupply
                    Fixed:Yes
                    Local    :    Field    :    InvoiceDate        :    Type    :    String
                    Local    :    Field    :    InvoiceDate        :    Set as    :    $$LocaleString:"InvoiceDate"
                    Local    :    Field    :    InvoiceNumber    :    Set as    :    "InvoiceNumber"
                    Local    :    Field    :    SupplierGSTIN    :    Set as    :    "SupplierGSTIN"
                    Local    :    Field    :    SupplyName        :    Set as    :    "Supplier Name"
                    Local    :    Field    :    InvocietotValue    :    Type    :    String
                    Local    :    Field    :    InvocietotValue    :    Align    :    Left
                    Local    :    Field    :    InvocietotValue    :    Set as    :    $$LocaleString:"InvocietotValue"
                    Local    :    Field    :    Supplyfileddt    :    Type    :    String
                    Local    :    Field    :    Supplyfileddt    :    Set as    :    $$LocaleString:"Supplyfileddt"
                    Local    :    Field    :    Supplyprd        :    Set as    :    "Supplyprd"
                    Local    :    Field    :    ITCAvailable    :    Type    :    String
                    Local    :    Field    :    ITCAvailable    :    Set as    :    $$LocaleString:"ITCAvailable"
                    Local    :    Field    :    PlaceofSupply    :    Set as    :    "PlaceofSupply"
                    Local    :    Field    :    GSTR2Btaxable value    :    Type    :    String
                    Local    :    Field    :    GSTR2Btaxable value    :    Set as    :    "Taxable value"
                    Local    :    Field    :    GSTR2Brate    :    Type    :    String
                    Local    :    Field    :    GSTR2Brate    :    Set as    :    "Rate"
                    Local    :    Field    :    GSTR2BIGST    :    Type    :    String
                    Local    :    Field    :    GSTR2BIGST    :    Set as    :    "IGST"
                    Local    :    Field    :    GSTR2BCGST    :    Type    :    String
                    Local    :    Field    :    GSTR2BCGST    :    Set as    :    "CGST"
                    Local    :    Field    :    GSTR2BSGST    :    Type    :    String
                    Local    :    Field    :    GSTR2BSGST    :    Set as    :    "SGST"
                    Border:  Flush Column Titles
                [Line:GSTIN from Jason]
                    left Field: InvoiceDate,    InvoiceNumber,     SupplierGSTIN,    SupplyName
                    Right Field: GSTR2Btaxable value, GSTR2Brate, GSTR2BIGST, GSTR2BCGST, GSTR2BSGST, InvocietotValue,    Supplyfileddt,    Supplyprd,    ITCAvailable,    PlaceofSupply
            [Part:GSTR2B Bottom part]
                Line: Gross total line
                [Line:Gross total line]
                    Fixed:Yes
                    Use:GSTR2A title line
                    Local    :    Field    :    InvoiceDate        :    Type    :    String
                    Local    :    Field    :    InvoiceDate        :    Set as    :    $$LocaleString:""
                    Local    :    Field    :    InvoiceNumber    :    Set as    :    ""
                    Local    :    Field    :    SupplierGSTIN    :    Set as    :    ""
                    Local    :    Field    :    SupplyName        :    Width    :    @@LongWidth + @@ratewidth - 3
                    Local    :    Field    :    SupplyName        :    Set as    :    "Gross Total"
                    Local    :    Field    :    GSTR2Btaxable value    : Set as    : $$Total:GSTR2Btaxablevalue
                    Local    :    Field    :    GSTR2BIGST    : Set as    : $$Total:GSTR2BIGST
                    Local    :    Field    :    GSTR2BCGST    : Set as    : $$Total:GSTR2BCGST
                    Local    :    Field    :    GSTR2BSGST    : Set as    : $$Total:GSTR2BSGST
                    Local    :    Field    :    InvocietotValue        :      Set as    :    $$Total:InvocietotValue
                    Local    :    Field    :    Supplyfileddt    :    Type    :    String
                    Local    :    Field    :    Supplyfileddt    :    Set as    :    $$LocaleString:""
                    Local    :    Field    :    Supplyprd        :    Set as    :    ""
                    Local    :    Field    :    ITCAvailable    :    Type    :    String
                    Local    :    Field    :    ITCAvailable    :    Set as    :    $$LocaleString:""
                    Local    :    Field    :    PlaceofSupply    :    Set as    :    ""
                    Local    :    Field    :    GSTR2Brate    :    Type    :    String
                    Local    :    Field    :    GSTR2Brate    :    Set as    :    ""
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Fields' Section;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    [Field:InvoiceDate]
        Use:uni date field
        Width:@@ShortDateWidth * 2
        Set as:$$Date:$InvoiceDate
        Border:thin left right
    [Field:invoice number]
        Use:name Field
        Set as:$InvoiceNumber
        Width:20
    [Field:SupplierGSTIN]
        Use:name field
        Width:20
        Set as:$SupplierGSTIN
        Border:thin left right
    [Field:SupplyName]
        Use:name field
        Width:@@LongWidth + @@ratewidth
        Border:thin left right
        Set as:$SupplyName
        Full Width:Yes
        Border:thin left right
    [Field:GSTR2BTaxable value]
        Use:Amount field
        Align:Right
        Width:@@NumberWidth*2
        Format:"Decimals:2"
        Set as:$$AsAmount:$Taxablevalue
        Border:thin left right   
    [Field:GSTR2Brate]
        Use:number field
        Align:Right
        Width:@@RateWidth
        Format:"Decimals:0"
        Set as:$ratex
        Border:thin left right   
    [Field:GSTR2BIGST]
        Use:Amount field
        Align:Right
        Width:@@NumberWidth*2
        Format:"Decimals:2"
        Set as:if $$IsEmpty:$IGST then $$AsAmount:0 else $$AsAmount:$IGST
        Border:thin left right   
    [Field:GSTR2BCGST]
        Use:Amount field
        Align:Right
        Width:@@NumberWidth*2
        Format:"Decimals:2"
        Set as:if $$IsEmpty:$CGST then $$AsAmount:0 else $$AsAmount:$CGST
        Border:thin left right   
    [Field:GSTR2BSGST]
        Use:Amount field
        Align:Right
        Width:@@NumberWidth*2
        Format:"Decimals:2"
        Set as:if $$IsEmpty:$SGST then $$AsAmount:0 else $$AsAmount:$SGST
        Border:thin left right   
    [Field:InvocietotValue]
        Use:number field
        Align:Right
        Width:@@NumberWidth*2
        Format:"Decimals:2"
        Set as:$InvocietotValue
        Border:thin left right
    [Field:Supplyfileddt]
        Use:uni date field
        Width:@@ShortDateWidth * 2
        Set as:$$Date:$Supplyfileddt
        Border:thin left right
    [Field:Supplyprd]
        Use:name field
        Width:@@ratewidth
        Set as:$Supplyprd
        Border:thin left right
    [Field:ITCAvailable]
        Use:logical field
        Width:@@ratewidth
        Set as:$$chklogic:$ITCAvailable
        Border:thin left right
    [Field:PlaceofSupply]
        Use:name field
        Set as: $$getGSTStateName:$PlaceofSupply
        Border:thin left
       
    [Field:JsonFolder]
        Use:cfg cmp data path
        Delete:Storage
        Background:deep grey
        Color:yellow
        Width:@@Longwidth
        Full Width:Yes
        Show Table:On Blank
        Set as:##JsonFolder
        Modifies:jsonFolder
        Border:Thin Box pink
    [Field:Json File Path]
        Use:Name Field
        Background:deep grey
        Color:yellow
        Width:@@Longwidth
        Table:JFIlepath
        Full Width:Yes
        Set as:##JsonFilePath
        modifies:JsonFilePath
        Show Table:Always
        Border:Thin Box pink
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Menus' section;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       
    [#Menu:Gateway of Tally]
        Add:Item:GSTR2B Recon:Menu:GSTR2B Recon
           
    [Menu:GSTR2B Recon]
        Item:configure:Alter:GSTR2B Reckon config
        Item:Reckon:Display:GSTR2B Recon
        Item:refresh tdl:Refresh TDL
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Formulas' section;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    [System:Formula]
        jsonlength:($$StringLength:##jsonFolder)-1
        jsonextn:$$StringPart:##jsonFolder:@@jsonlength:1
        jsonFilter:@@jsonextn="json"
        jsonfolderhasslash:if @@jsonextn="\" then ##jsonFolder else ##jsonFolder + "\"
       
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Variables' Section;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    [System:Variable]
        jsonfolder:""
        JsonFilePath:""
        jsonfile:""
       
    [Variable:jsonfile]
        Type:String
       
    [Variable:jsonfolder]
        Type:String
    [Variable:JsonFilePath]
        Type:String
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Function Part;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    [Function:chklogic]
        Parameter:pinput:String
        Returns:Logical
        10:Do If:##pinput = "Y":Return:Yes
        20:Do If:##pinput = "N":Return:No
           
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Necessary Collections;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                   
    [Collection : JFIlepath]
       
        Data Source : Directory : #JsonFolder;
        Format : $Name, 25
        Format : $FileSize, 15
        Format : $IsReadOnly, 15
        Format : $LastModifiedDate, 15
        Format : $LastModifiedTime, 15
    [Collection:gstr2b]
        Data Source:File JSON:@@jsonfolderhasslash +  ##JsonFilePath
        JSON Object Path:"docdata:1:data:1"
        Fetch: *.*, data.docdata.*
       
    [Collection:b2b collection]
        Source Collection:gstr2b
        Walk:b2b
        Compute:supplierGST:$ctin
        Compute:TradeName:$trdnm
        Compute:supplierfileddate:$supfildt
        Compute:supplierRTPRD:$supprd
       
        Fetch:*.*, inv.*, inv.items.*
       
    [Collection:my json b2b collection]
        Source Collection:b2b collection
        Source Var            : VendGSTIN    : String    : $supplierGST
        Source Var            : VendName    : String    : $TradeName
        Source Var            : Vendfileddt    : String    : $supplierfileddate
        Source Var            : Vendprd    : String    : $supplierRTPRD
       
        Walk    : inv
        Compute        : SupplierGSTIN        : ##vendGSTIN
        Compute        : SupplyName        : ##VendName
        Compute        : Supplyfileddt        : ##Vendfileddt
        Compute        : Supplyprd            : ##Vendprd
        Compute        : InvoiceNumber     : $inum
        Compute        : InvoiceDate        : $dt
        Compute        : InvocietotValue    : $$Number:$val
        Compute        : ITCAvailable        : $itcavl
        Compute        : PlaceofSupply        : $pos
       
            walk : items
            Compute    : ratex            :    $rt
            Compute    : Taxablevalue    :    $txval
            Compute    : IGST            :    if $$IsEmpty:$igst then $$InitValue:Amount else $igst       
            Compute    : CGST            :    if $$IsEmpty:$cgst then $$InitValue:Amount else $cgst
            Compute    : SGST            :    if $$IsEmpty:$sgst then $$InitValue:Amount else $sgst
            Aggr Compute:Taxablevaluetot:Sum:$txval
           
            Fetch:*.*, items.*
           
    
    
     
    Last edited: Sep 26, 2021
    Rajnish Kapahi likes this.


  2. Jayashri

    Jayashri Member


    ERROR
     

    Attached Files:



  3. Lynch

    Lynch Member


    Sorry about that, I've used definitions already presented in my one of the other report, non inclusion of the definitions [excel file path] has given you the error, Have rectified the code so as to no be depend on other definitions. you can check the code again. Also, had arranged the definitions in the manner in which it will be easy to go through.


     



  4. Dear Sir,

    i have load your code but still no file xls or json pulling it is showing blank when recon
     


Share This Page