Save Logical UDF on Voucher Save

Discussion in 'Tally Developer' started by Poojan Shah, Apr 21, 2021.

    
  1. Poojan Shah

    Poojan Shah New Member


    Dear Experts,

    I am new to tdl programming language. I need your expert opinion and help.

    I am trying to make a terms & conditions tdl which can be set in the voucher type and also be reviewed/modified in sales voucher but my issue is when I save the sales voucher, it takes the value stored during the voucher type and not new values modified in the sales voucher.

    Please find my code below

    Code:
    ;; ============================================= Set/Alter Terms in Voucher Type =====================================================
    [#Part: VTYP BehaviourMain]
        Option    : PT VTYP TNC    : @@IsVTYPSales
    
        [!Part: PT VTYP TNC]
            Add    : Line    : After    : VTYP Decl    : PT VTYP TNC
           
            [Line: PT VTYP TNC]
                Field    : Long Prompt, Logical Field
                Local    : Field    : Long Prompt    : Set as    : $$LocaleString:"Set/Alter Terms :"
                Local    : Field    : Long Prompt    : Width        : @@LongWidth
               
                Local    : Field    : Logical Field    : Storage    : PTEnableTNC
                Local    : Field    : Logical Field    : trigger    : PT TermsNConditions    : $$Value = "Yes"
               
    ;; ================================================= Create Terms & Conditions =============================================================
    [#Menu: Popaya]
        Add    : Key Item    : Terms & Conditions    : T    : Alter    : PT TermsNConditions
        Add    : Item        : Blank
       
    [Report: PT TermsNConditions]
        Title    : Terms & Conditions
       
        Form    : PT TermsNConditions
        Object    : Company
       
        Variable: PTPrintTNC
       
        [Form: PT TermsNConditions]
            Parts    : PT TermsNConditionsTitle, PT TermsNConditions
           
            Full Width    : Yes
            Full Height    : Yes
            Height        : 100% Screen
           
            Background    : White
           
            [Part: PT TermsNConditionsTitle]
                Lines        : PT TermsNConditionsTitle
                Space Bottom: 1.00
               
                [Line: PT TermsNConditionsTitle]
                    Fields    : Short Name Field, PT TermsNConditionsTitle
                   
                    Local    : Field    : Short Name Field    : Info    : $$LocaleString:"Title"
                    Local    : Field    : Short Name Field    : Align    : Right
                   
                    [Field: PT TermsNConditionsTitle]
                        Use            : Name Field
                        Storage        : PTTNCTitle
                        Full Width    : Yes
                        Max            : 64
                        Set as        : $PTTNCTitle
                        Set Always    : Yes
               
            [Part: PT TermsNConditions]
                Lines    : PT CMP TermsNConditionsTitle, PT CMP TermsNConditions
                Repeat    : PT CMP TermsNConditions    : PTTNC
                Break On: $$IsEmpty:$PTTermsNCondition
               
                Scroll    : Vertical
                Common Borders    : YEs
               
                [Line: PT CMP TermsNConditionsTitle]
                    Fields    : Simple Field, Name Field, Info Field
                    Border    : Flush Totals
                   
                    Local    : Field    : Simple Field        : Info            : $$LocaleString:"Sr. No."
                    Local    : Field    : Simple Field        : Width            : 5% Screen
                    Local    : Field    : Simple Field        : Align            : Right
                    Local    : Field    : Simple Field        : Border        : Thin Right
                   
                    Local    : Field    : Name Field        : Info            : $$LocaleString:"List of Terms & Conditions"
                    Local    : Field    : Name Field        : Style            : Normal
                    Local    : Field    : Name Field        : Full Width    : Yes
                    Local    : Field    : Name Field        : Skip            : Yes
                   
                    Local    : Field    : Info Field        : Info            : $$LocaleString:"Print"
                    Local    : Field    : Info Field        : Width            : @@ShortWidth - 4
                    Local    : Field    : Info Field        : Skip            : Yes
                    Local    : Field    : Info Field        : Align            : Center
                    Local    : Field    : Info Field        : Border        : Thin Left
               
                [Line: PT CMP TermsNConditions]
                    Fields    : MultiSNo, PT CMP TermsNConditions, PT PrintTNC
                    Border    : Thin Bottom
                   
                    Local    : Field    : MultiSNo    : Width    : 5% Screen
                   
                    Space Top    : 0.25
                   
                    [Field: PT CMP TermsNConditions]
                        Type    : String
                        Max        : 255
                        Style    : Normal
                        Full Width    : Yes
                        Storage        : PTTermsNCondition
                       
                    [Field: PT PrintTNC]
                        Use            : Logical Field
                        Align        : Center
                        Modifies    : PTPrintTNC    : YEs
                        Width        : @@ShortWidth - 4
                        Skip        : $$IsEmpty:$PTTermsNCondition
                        Storage        : PTPrintTNC
                       
    ;; ======================================================== Review Terms & Conditions in Voucher ============================================
    [#Part: VCH Narration]
        Add    : Option    : PT ReviewTNC    : @@IsSales
       
        [!Part: PT ReviewTNC]
            Add    : Lines    : At Beginning    : PT ReviewTNC
           
            [Line: PT ReviewTNC]
                Fields    : Medium Prompt, PT ReviewTNC
                Local    : Field    : Medium Prompt    : Info    : $$LocaleString:"Review Terms & Conditions :"
               
                [Field: PT ReviewTNC]
                    Use        : Logical Field
                    Storage    : PTReviewTNC
                    Set as    : IF $$IsEmpty:$$Value THEN "No" ELSE $$Value
                    Sub Form: PTReviewTNC    : $$Value = "Yes"
                   
    [Report: PTReviewTNC]
        Use        : DSP Template
        Form    : PT CMP ReviewTNC
       
        [Form: PT CMP ReviewTNC]
            Use        : DSP Template
            Parts    : PT CMP ReviewTNC
           
            Height    : 90% Screen
            Button    : PTButtonTNC
           
            [Part: PT CMP ReviewTNC]
                Lines            : PT ReviewTNC Title, PT ReviewTNC Body
                Repeat            : PT ReviewTNC Body    : CollPTReviewTNC
               
                Common Border    : Yes
                Scroll            : Vertical
               
                [Line: PT ReviewTNC Title]
                    Use            : PT CMP TermsNConditionsTitle
                   
                [Line: PT ReviewTNC Body]
                    Fields    : MultiSNo, PT Review TermsNConditions, PT Review PrintTNC
                    Border    : Thin Bottom
                   
                    Local    : Field    : MultiSNo    : Width    : 5% Screen
                   
                    Space Top    : 0.25
                   
                    [Field: PT Review TermsNConditions]
                        Set as    : $PTTermsNCondition
                        Full Width: Yes
                        Skip    : Yes
                   
                    [Field: PT Review PrintTNC]
                        Use            : Logical Field
                        Storage        : PTPrintTNC
                        Set Always    : YEs
                        Width        : @@ShortWidth - 4
                        Align        : Center
                        ;;Skip        : YES
                        Sub Form    : PT TermsNConditions    : $$IsEnd:$$CollectionField:$PTPrintTNC:2:CollPTReviewTNC
                       
    [Button: PTButtonTNC]
        Key        : Alt + C
        Action    : Alter    : PT TermsNConditions
        Title    : $$LocaleString:"Alter TNC"
                       
    [Collection: Coll PT TermsNConditions]
        Type    : PTTNC    : Company
        Child Of: ##SVCurrentCompany
       
        Fetch    : PTTermsNConditions, PTPrintTNC
        Format    : $PTTermsNCondition, 10
        Format    : $PTPrintTNC, 8
        Title    : Terms & Conditions
       
    [Collection: Coll PT ReviewTNC]
        Type    : PTTNC    : Company
        Child Of: ##SVCurrentCompany
        Fetch    : PTTermsNCondtion, PTPrintTNC
       
    [System: UDF]
        PTTNC                : Aggregate    : 231
        PTTermsNCondition    : String    : 232
        PTPrintTNC            : Logical    : 233
        PTTNCTitle            : String    : 234
        PTEnableTNC            : Logical    : 235
       
    [Variable: PTPrintTNC]
        Type        : Logical
        Persistent    : Yes
        Volatile    : YEs
        Default        : NO
       
    [System: Variable]
        PTPrintTNC    : No
       
    ;; ================================================================ Print Terms in Invoice =============================================================
    [#Part: PT EXPINV FooterLeft]
        Option    : PT EXPINV TNC    : Yes
       
        [!Part: PT EXPINV TNC]
            Add    : Parts    : AT END    : PT EXPINV PrintTNC
           
            [Part: PT EXPINV PrintTNC]
                Lines    : PT EXPINV TNC, PT EXPINV PrintTNC
                Repeat    : PT EXPINV PrintTNC    : CollPTReviewTNC
               
                Vertical: Yes
    
            [Line: PT EXPINV TNC]
                Fields    : Name Field
               
                Local    : Field    : Name Field    : Set as    : $PTTNCTitle:Company:##SVCurrentCompany
                Local    : Field    : Name FIeld    : Style        : PT Bold
               
            [Line: PT EXPINV PrintTNC]
                Fields    : PT EXPINV MultiSNo, PT EXPINV PrintTNC
               
                Local    : Field    : Default    : Delete    : Border
                Local    : Field    : Default    : Style        : PT SmallText
               
                Empty if    : $PTPrintTNC = "No"
               
                [Field: PT EXPINV MultiSNo]
                    Width        : 3.5
                    Skip        : Yes
                    Fixed        : Yes
                    Info        : @LineNum
                    LineNum        : IF $PTPrintTNC = "Yes" THEN $$String:$$Line + "." ELSE ""
                    Set Always    : NO
                    Align        : Right
                    Inactive    : IF $PTPrintTNC = "Yes" THEN No ELSE YES
               
                [Field: PT EXPINV PrintTNC]
                    Use        : Simple Field
                    SET AS    : IF $PTPrintTNC = "Yes" THEN $PTTermsNCondition ELSE ""
                    INACTIVE: IF $PTPrintTNC = "Yes" THEN NO ELSE Yes
    And also if possible to store values inside each voucher.
     


  2. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Which Tally version does [#Part: PT EXPINV FooterLeft] belongs to. There is no such PART.
     


  3. Poojan Shah

    Poojan Shah New Member


    That is a custom part created in invoice customization. You can replace it with EXPINV Declaration if you like.
     


  4. Poojan Shah

    Poojan Shah New Member


    Can any experts help me?
     


  5. garima

    garima Well-Known Member


    You should share the Sample Test Data(Tally), you must have created, so that it can be experimented.. I guess you want to set terms and conditions in Sales voucher from the list of terms you created ( i mean a reference to the terms list)..

    So here...
    Repeat : PT ReviewTNC Body : CollPTReviewTNC ( this is good for display/print purpose only, if already saved in voucher)

    you need to use a separate aggregate UDF (Storage) to save to the references no of Terms/Conditions .

    after doing it, you need to modify your print/display report accordingly to show the list of terms/conditions
     


  6. Poojan Shah

    Poojan Shah New Member


    Does it mean that I need to share the tdl file?

    Yes, this is fetching the data from the report which can be accessed is sales voucher type.

    I will give it a try

    Thanks for your help!
     


Share This Page