Import Vouchers from a Function

Discussion in 'Tally Developer' started by Arun Prasath, Aug 7, 2023.

    
  1. Arun Prasath

    Arun Prasath Member


    Dear Experts,

    I have wrote a function to import vouchers from a collection (Excel or any data source), My issue is item quantity and rate not appearing.

    Rgds,
    Arun
    Code:
    [Function: PurcInvoiceImport]
       
    Variable : Counter : Number
    Variable: NAcQty : Quantity
    Variable    : NaRate : Rate
    
    01 : Set: NAcQty : $$AsQty:"1.000"
    01a : Set: NaRate : $$AsRate:"100"
    ;;01a :
    ;02 : SET : Counter : 0
    ;03 : START PROGRESS     : ($$NumItems:NGSTPurchaseStockItemColl) : "Vouchers Importing " : @@CmpMailName : "Purchase Importing ..."
    ;;04 : WALK COLLECTION     : NGSTPurchaseStockItemColl
    05 : NEW OBJECT : Voucher
    06 : SET : SVViewName : $$SysName:InvVchView
    07 : Set Value :IsInvoice :"YES"
    
    10 : SET VALUE : VoucherTypeName : "Purchase" ;;##purchaseimportvar2
    15 : Set Value: VoucherNumber :"1234"
    20 : Set Value:  Date            :$$Date:"01.04.2023" ;; $$Date:@@EVchDatePost
    30 : Log: $Date
    40 : Set Value: PartyLedgerName : "123" ;;$$String:$_3
    50 : SET VALUE : PartyName : $Name:Ledger:"123" ;;$$String:$_3
    60    : SET VALUE : Amount        : "100.00" ;;$_9
    
    70 : INSERT COLLECTION OBJECT : LEDGERENTRIES
    80 : SET VALUE : LedgerName : "123" ;; $$String:$_3
    90 : SET VALUE : IsDeemedPositive : No
    100 : SET VALUE : IsPartyLedger : Yes
    110 : SET VALUE : Amount :  "100.00"  ;; $_9
    120  : SET TARGET : ..
    130 : INSERT COLLECTION OBJECT : LEDGERENTRIES
    140 : SET VALUE : LedgerName : "Purchase" ;;$$String:$_3
    150 : SET TARGET : ..
    180 : INSERT COLLECTION OBJECT : INVENTORYENTRIES
    190 : SET VALUE : StockItemName :"DID 35-1R";;  $_5
    210 : SET VALUE : ActualQty : ##NAcQty ;; $_6
    220 : SET VALUE : BilledQty :  ##NAcQty  ;; $_7
    230 : SET VALUE : Rate : ##NaRate ;;  $_8
    240 : SET VALUE : Amount :"100" ;;  $_9
    
    
    
    250 : INSERT COLLECTION OBJECT : BATCHALLOCATIONS
    260 : SET VALUE : GodownName : "Main Location"
    ;270 : SET VALUE : BatchName : $$FileReadCell:##Counter:11
    280 : SET VALUE : ActualQty : ##NAcQty
    290 : SET VALUE : BilledQty :##NAcQty
    300 : SET VALUE : Rate : ##NaRate
    310 : SET VALUE : Amount : "100"
    320 : SET TARGET : ..
    
    330 : INSERT COLLECTION OBJECT : ACCOUNTING ALLOCATIONS
    340 : SET VALUE : LedgerName : "Purchase"  ;;$$String:@@purgl
    360 : SET VALUE : Amount : "100.00" ;;$$AsAmount:$$FileReadCell:##Counter:7
    361 : Set Value: IsDeemedPositive : Yes
    370 : SET TARGET : ..
    
    
    380  : Set Value : Narration: "13dfdsfds" ;; $_10
    ;1255A : Set Value:ENGNOPURCHASE:$$FileReadCell:##Counter:12
    390: SET VALUE : PersistedView : ##SVViewName
    
    ;410 : INCREMENT : Counter
    ;420 :  SHOW PROGRESS : ##Counter
    
    430 :Create Target
    ;;450 : END WALK
    ;460 : END PROGRESS
    470 : RETURN
    
    
     


  2. Prateek Mudugal

    Prateek Mudugal New Member


    Change Your Code from
    01 : Set: NAcQty : $$AsQty:"1.000"
    01a : Set: NaRate : $$AsRate:"100"

    to this
    01 : Set: NAcQty : $$TgtObject:$$AsQty:"1.000"
    01a : Set: NaRate : ($$AsAmount:100 /##NAcQty)
     


Share This Page