Voucher number As Reference number

Discussion in 'Tally Developer' started by Rupal Agarwal, Feb 4, 2023.

    
  1. Rupal Agarwal

    Rupal Agarwal Member


    Hello everyone

    I have imported my purchases from a portal(EvitalRx) into tally using a XML file, all the purchases are imported correctly, but the problem is that it has not updated the voucher number as the purchase invoice number. The purchase invoice numbers are available only at voucher reference number.

    I am able to get the reference number at voucher screen, but I want to change Voucher number as voucher reference number at one.
    Can anyone help me in regarding this (by writing a code for it).

    Screenshot 2023-02-04 175505.jpg
     


  2. Bipin Damania

    Bipin Damania Active Member


    If your Voucher Number is Automatic then it is not possible, you have to set as Manual.
     


  3. Rupal Agarwal

    Rupal Agarwal Member


    Thank you for replying, sir.

    I have set voucher number as manual, and now I am looking for a code which can help in changing the voucher number as reference number without doing it manually for each and every entry.
     


  4. Lynch

    Lynch Member


    you can use the following code.... it will create a voucher collection based on the lines you're selecting and it will fetch voucher number from the excel sheet... (if you configure it properly)
    enter the voucher numbers in a excel sheet in the same order as it is being appeared in the report.... and do change the excel sheet file name and sheet name in the appropriate place in the below code and then add the code


    Code:
       
    [#form:DSP Add Save View Button]
            Add            : Button        : After                        : Fourth Blank Button    :Change details
    
    [Button:Change details]
        Key: Ctrl + W
        Title:"Change Inum"
        Action:call:bulk change inum
        Scope:Selected Lines
           
        [Collection : SelSrcCol]
    
            Data Source : Report : Selected Lines
            Fetch : MasterID , VoucherNumber, PartyLedgerName, Date, LedgerEntries.*
    
    [Function:bulk change inum]
        Variable:vNewvchnum:String
        Variable:vch:String
        Variable:countr:Number:1
        ;00:Log:"Function is working, lets connect with COM interface"   
        ;01:Log:##dscnm
        75 : WALK : SelSrcCol
            75a:Set:SVexportlocation:"G:/My Drive/2022-23/Files to be shared with Auditors/Ksquared/Sales buffer/" + ($$DDMMYYYYDateFormat:##SVFromDate:"-") + "/"
            75b:Set:vch:($$LocaleString:"ID :"+$$LocaleString:@@GSTCurntVchrMSTID)
            75c:Set:vNewvchnum:$$CollectionField:$vouchrnumber:##counter:ExcelInfo
            75d: Modify Object:(Voucher, ##VCh).VoucherNumber:$vouchrnumber
            75e:Increment:counter
        90 : END WALK
        91:Browse Url:##SVexportlocation
       
    [Collection: ExcelInfo]
        ODBC            : "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + $$Localestring:##ExcelFile;replace this variable(##ExcelFile) with the excel file path
        SQL                : "Select * From ["+$$Localestring:##sheetname+"$]";replace this variable(##sheetname) with the excel sheet name
        Fetch            : *.*
        SQLObject: ExcelInfo
       
    [Object:ExcelInfo]
        vouchrnumber    :    $_1
    
     
    Rupal Agarwal likes this.


  5. Bipin Damania

    Bipin Damania Active Member


    Check you XML, if your XML contains voucher as you required then delete all previously imported voucher & reimport the same.
     


  6. sattam

    sattam Active Member


    have you written any code?
     


  7. Rupal Agarwal

    Rupal Agarwal Member


    OMG!!

    A big thanks to you buddy. Hope this will surely help me in solving my problem.
    Also can you please provide the format of the excel file according to which u made this?
     


  8. Rupal Agarwal

    Rupal Agarwal Member


    can we make it without the help of excel?

    Like it takes the Reference number from the selected line and changes the voucher number according to that.
     


  9. Lynch

    Lynch Member


    aahn yeah... How did I miss that... yes we can do that... slightly modified code below...


    Code:
    
    [#form:DSP Add Save View Button]
            Add            : Button        : After                        : Fourth Blank Button    :Change details
    
    [Button:Change details]
        Key: Ctrl + W
        Title:"Change Inum"
        Action:call:bulk change inum
        Scope:Selected Lines
        
        [Collection : SelSrcCol]
    
            Data Source : Report : Selected Lines
            Fetch : MasterID , VoucherNumber, PartyLedgerName, Date, Reference, LedgerEntries.*
    
    [Function:bulk change inum]
        Variable:vNewvchnum:String
        Variable:vch:String
        Variable:countr:Number:1
        ;00:Log:"Function is working, lets connect with COM interface"
        ;01:Log:##dscnm
        75 : WALK : SelSrcCol
            75b:Set:vch:($$LocaleString:"ID :"+$$LocaleString:@@GSTCurntVchrMSTID)
            75c:Set:vNewvchnum:$Reference
            75d: Modify Object:(Voucher, ##VCh).VoucherNumber:##vNewvchnum
            75e:Increment:counter
        90 : END WALK
      
    
    
     
    Last edited: Feb 8, 2023


  10. Rupal Agarwal

    Rupal Agarwal Member


    Thank you buddy, now it's working better.

    But is it possible that it will automatically change the voucher number line after line, because I have nearly, 10500 purchase entries, and doing it manually for every entry is such a big task.
     


  11. Lynch

    Lynch Member


    What I have given is the temporary solution to change the existing vouchers... you need to change your code which is posting these entries.....so that it will be done while importing itself....
    as our well versed member @sattam sir asked, if you've written the code for importing, changing the code is not at all matters.....
     


  12. sattam

    sattam Active Member


    Is your problem solved?
     


  13. Rupal Agarwal

    Rupal Agarwal Member


    Yes sir, my problem is solved, but not by the above given code.

    My query is solved by the following code :

    Code:
    [#Menu        : Gate Way of Tally]
        Add:Item:after : @@locDisplayMoreReports : blank
        Add:Key Item:After:@@locDisplayMoreReports:"Change Vch No" : E :Alter :VCHnoRefNo
       
    [Report: VCHnoRefNo]
        Form            : VCHnoRefNo
        Multi Objects    : VCHnoRefNocoll
        Title            : "Voucher No As Reference No"
        Set:SVfromdate:$$MonthStart:$$CurrentDate
        Set:SVtodate:$$MonthEnd:$$CurrentDate
        Variable:svtodate, Svfromdate
    
    [Form: VCHnoRefNo]
        Parts         : Form SubTitle, VCHnoRefNo
        Local: Field: Form SubTitle    : Set As    : "Press CTRL+A to Except"
        Button: Change period
    
    [Part: VCHnoRefNo]
        Lines             : VchRefT, VchRefD
        Repeat             : VchRefD    : VCHnoRefNocoll
        Scroll            : Vertical
        Common Border    : Yes
       
    [Line: VchRefT]
        Use        : VchRefD
        Local    : Field    : Default            : Type        : String
        Local    : Field    : Default            : Delete    : Storage
        Local    : Field    : Default            : Line        : 0
        Local    : Field    : Default            : Align        : Center
        Local    : Field    : VchRefD Party        : Info        : "Party"
        Local    : Field    : VchRefD No        : Info        : "Voucher Number"
        Local    : Field    : VchRefD Date        : Info        : "Voucher Date"
        Local    : Field    : VchRefD Type        : Info        : "Voucher Type Name"
        Local    : Field    : VchRefD Narration    : Info        : "Narration"
        Border    : Column Titles
    
    ;;---------------------------------------------------------------------------------------------------------
    
    [Line: VchRefD]
        Fields    : VchRefD Date, VchRefD Party, VchRefD REF, VchRefD No, VchRefD Type, VchRefD Narration
        Local    : Field    : Default    : Style: Normal
    
    [Field: VchRefD Date]
        Use            : Uni Date Field
        Storage        : Date
        skip         : yes
        Width        : 10% page
    
    [Field: VchRefD Party]
        Use            : Name Field
        Storage        : Partyledgername
        Border        : Thin Left
        Skip        : Yes
        Width        : 20% page
    
    [Field: VchRefD REF]
        Use            : Short Name Field
        Storage        : reference
        Border        : Thin Left Right   
        Width        : 15% page
    
    [Field: VchRefD No]
        Use            : Short Name Field
        Set as        : #VchRefDREF
        Storage        : VoucherNumber
        Border        : Thin Left Right   
        Set Always    : Yes
        Width        : 15% page
    
    [Field: VchRefD Type]
        Use            : Name Field
        Storage        : VoucherTypeName
        Skip        : Yes
        Width        : 10% page
    
    [Field: VchRefD Narration]
        Use            : Name Field
        Storage        : Narration
        Border        : Thin Left
        Skip        : Yes
        Width        : 30% page
    
    ;;---------------------------------------------------------------------------------------------------------
    
    [Collection: VCHnoRefNocoll]
        Type:vouchers:vouchertype
        Child Of: $$VchTypePurchase
        ;Filter: novch
       
    [System:Formulae]
        novch : $$IsEmpty:$vouchernumber
     


Share This Page