I need help regarding Purchase Voucher Excel Import

Discussion in 'Free Source Codes' started by Aslan Iglesias, Jul 21, 2020.

    
  1. Aslan Iglesias

    Aslan Iglesias New Member


    Dear Experts,


    Seek help regarding TDL, have written code regarding Purchase Import, showing the error:

    Code attached below:

    [Variable: Purc_VAR]
    Variable : Purc_VchDate : String
    Variable : Purc_VchNo : String
    Variable : Purc_Party : string
    Variable : Purc_ProductName : String
    Variable : Purc_ProductQty : Number
    Variable : Purc_ProductRate : Number
    Variable : Purc_ProductUnit : String
    Variable : Purc_ProductTotAmt : Number


    [System : Variable]
    List Variable: Purc_VAR


    [Function: PREMIERPurcVoucherFunc]
    Parameter : PUR_FilePath : String
    Parameter : PUR_FileName : String
    Parameter : PUR_SheetName : String

    Variable : SVFileName : String
    Variable : SvRow : Number : 2
    Variable : SvColum : Number : 1

    100 : List Delete : PURC_VAR
    101 : Set : SVFileName : ##PUR_FilePath + "\" + ##PUR_FileName
    102 : Open File : ##SvFileName : Excel : Read : ASCII
    103 : Set Active Sheet : ##PUR_SheetName
    104 : While : Not $$IsEmpty:$$FileReadCell:##SvRow:1
    105 : List Add : PURC_VAR : ##SvColum : ($$FileReadCell:##SVRow:1):purc_VchDate
    106 : List Add : PURC_VAR : ##SvColum : ($$FileReadCell:##SVRow:2):purc_VchNo
    107 : List Add : PURC_VAR : ##SvColum : ($$FileReadCell:##SVRow:3):purc_Party
    108 : List Add : PURC_VAR : ##SvColum : ($$FileReadCell:##SVRow:4):purc_ProductName
    109 : List Add : PURC_VAR : ##SvColum : ($$FileReadCell:##SVRow:5):purc_ProductQty
    110 : List Add : PURC_VAR : ##SvColum : ($$FileReadCell:##SVRow:6):purc_ProductRate
    111 : List Add : PURC_VAR : ##SvColum : ($$FileReadCell:##SVRow:7):purc_ProductUnit
    112 : List Add : PURC_VAR : ##SvColum : ($$FileReadCell:##SVRow:8):purc_ProductTotAmt

    115 : Increment : SvRow
    116 : Increment : SvColum
    117 : End While
    118 : Call : PREMIERCreatePurcVchFunc : #PUR_FilePath : #PUR_FileName : #PUR_SheetName

    [Function : PREMIERCreatePurcVchFunc]
    Parameter : PUR_FilePath : String
    Parameter : PUR_FileName : String
    Parameter : PUR_SheetName : String
    Variable : AmtDr : Number
    Variable : AMTCr : Number
    Variable : PartyVar : String
    Variable : VchNumVar : String
    Variable : ItemRateVar : Number
    Variable : ProdQty : Number
    Variable : PurcAmt : Number

    000 : Walk Collection : PREMIERPurcVouchersColl
    001 : SET : SVViewName : $$SysName:AcctgVchView
    002 : SET : AMTDr : $PremierPurc_VchTot
    003 : SET : AMTCr : $PremierVchAmountCR
    004 : SET : PartyVar : $PremierPurc_Party
    005 : SET : VchNumVar : $PremierPurc_VchNo



    006 : NEW OBJECT : Voucher

    007 : SET VALUE : Date : $$Date:$PremierPurc_VchDate
    008 : SET VALUE : VoucherTypeName : "Purchase"
    009 : SET VALUE : Voucher Number : $PremierPurc_VchNo
    010 : SET VALUE : IsInvoice : Yes
    011 : SET : SVViewName : "Invoice Voucher View"
    012 : SET VALUE : Persisted View : "Invoice Voucher View"
    013 : SET VALUE : STATENAME : $LedStateName:Ledger:$PremierPurc_Party
    014 : SET VALUE : PartyName : $PremierPurc_Party
    015 : SET VALUE : COUNTRYOFRESIDENCE : $CountryofResidence:Ledger:$PremierPurc_Party
    016 : SET VALUE : PARTYLEDGERNAME : $PremierPurc_Party
    ;017 : SET VALUE : BASICBASEPARTYNAME : $PremierPurc_Party
    017 : SET VALUE : BASICBUYERNAME : ##svCurrentCompany
    018 : SET VALUE : ISINVOICE : Yes
    019 : SET VALUE : FBTPAYMENTTYPE : "Default"
    019a : SET VALUE : BASICDATETIMEOFINVOICE:$$Date:$PremierPurc_VchDate
    019b : SET VALUE : BASICDATETIMEOFREMOVAL:$$Date:$PremierPurc_VchDate


    020 : Walk Collection:pREMIERPurcVouchersCollExtend
    021 : Set:prodQty:$PremierPurc_ProductQty
    022 : Set:ItemRateVar:$PremierPurc_ProductRate
    023 : Log:##ItemRateVar
    024 : Insert Collection Object : INVENTORYENTRIES
    ;025 : Set Target : INVENTORYENTRIES
    026 : SET VALUE : STOCKITEMNAME : $PremierPurc_ProductName
    027 : SET VALUE : ISDEEMEDPOSITIVE : Yes
    028 : SET VALUE : ISLASTDEEMEDPOSITIVE : Yes


    029 : SET VALUE : ACTUALQTY : $$TgtObject:($$AsQty:##ProdQty);*(-1)
    030 : SET VALUE : BILLEDQTY : $$TgtObject:($$AsQty:##ProdQty);*(-1)
    031 : SET VALUE : RATE : $$TgtObject:($$AsRate:##ItemRateVar)
    032 : Set:purcAmt:$PremierPurc_ProductTotAmt
    033 : SET VALUE : AMOUNT : $$TgtObject:$$AsAmount:##PurcAmt*(-1)

    034 : Insert Collection Object : BATCHALLOCATIONS
    035 : SET VALUE : GODOWNNAME : "Main Location"
    036 : SET VALUE : BATCHNAME : "Primary Batch"

    037 : SET VALUE : ACTUALQTY : $$TgtObject:($$AsQty:##ProdQty)
    038 : SET VALUE : BILLEDQTY : $$TgtObject:($$AsQty:##ProdQty)
    039 : SET VALUE : AMOUNT : $$TgtObject:$$AsAmount:##PurcAmt;$$AsAmount:$PremierPurc_ProductTotAmt;*(-1)

    ;040 : Set Target:..
    ;056a : Set Target:..

    041 :Insert Collection Object:ACCOUNTINGALLOCATIONS
    042 : SET VALUE : LEDGERNAME :$$String:"Purchase A/c"
    043 : SET VALUE : ISDEEMEDPOSITIVE : Yes
    044 : SET VALUE : LEDGERFROMITEM : No
    045 : SET VALUE : REMOVEZEROENTRIES : No
    046 : SET VALUE : ISPARTYLEDGER : No
    047 : SET VALUE : ISLASTDEEMEDPOSITIVE : Yes
    048 : SET VALUE : AMOUNT : $$TgtObject:$$AsAmount:##AMTDr*(-1);*(-1);$PremierPurc_ProductTotAmt

    049 : Set Target:..
    049a: Set Target:..


    050 : Insert Collection Object: LEDGERENTRIES
    ;051 : SET TARGET: LEDGERENTRIES
    052 : SET VALUE : LEDGERNAME : $PremierPurc_Party
    053 : SET VALUE : ISDEEMEDPOSITIVE : No
    054 : SET VALUE : LEDGERFROMITEM : No
    055 : SET VALUE : REMOVEZEROENTRIES : No
    056 : SET VALUE : ISPARTYLEDGER : Yes
    057 : SET VALUE : ISLASTDEEMEDPOSITIVE : No
    058 : SET VALUE : AMOUNT : $$TgtObject:$$AsAmount:##AMTDr;*(-1)
    ;026a : Set Target:..





    [Collection:purcExcelFileFetchColl]
    Data Source :Directory:#Pur_FilePath
    Filter :ExcelFiles
    Format :$Name,25

    [Collection : PREMIERPurcListSRC]
    Data Source : Variable : Purc_VAR



    [Collection: PREMIERPurcVouchersColl]
    Source Collection : PREMIERPurcListSRC
    By : PremierPurc_VchNo : $Purc_VchNo
    Compute : PremierPurc_VchDate : $Purc_VchDate
    Compute : PremierPurc_Party : $Purc_Party

    AggrCompute : PremierPurc_VchTot : SUM : $Purc_ProductTotAmt

    [Collection: PREMIERPurcVouchersCollExtend]
    Source Collection : PREMIERRcptListSRC
    Compute : PremierPurc_VchNo : $Purc_VchNo
    Compute : PremierPurc_VchNo : $Purc_VchNo
    Compute : PremierPurc_Party : $Purc_Party
    Compute : PremierPurc_ProductName : $Purc_ProductName
    Compute : PremierPurc_ProductQty : $Purc_ProductQty
    Compute : PremierPurc_ProductRate : $Purc_ProductRate
    Compute : PremierPurc_ProductUnit : $Purc_ProductUnit
    Compute : PremierPurc_ProductTotAmt : $Purc_ProductTotAmt
    Filter : PremierPurc_VoucherNumFilter









    [System : Formulas]
    PremierPurc_VoucherNumFilter : $PremierPurc_VchNo = $$ReqObject:$PremierPurc_VchNo; AND $PremierVchName = $$ReqObject:$PremierVchName


    059 : Insert Collection Object:BILLALLOCATIONS
    060 : Set Value : NAME : $PremierPurc_VchNo
    061 : SET VALUE : BILLTYPE : "New Ref"
    ;028 : SET VALUE : LedgerName : "Purchase A/c"
    ;
    062 : SET VALUE : Amount : $$TgtObject:$$AsAmount:##AMTDr;*(-1)
    063 : Log:##AMTDr
    064 : Log:##PartyVar
    065 : Log:##VchNumVar

    066 :Set Target:..
    ; 066a: Set Target:..


    067 : End Walk
    068: Log:##AMTDr
    ; 069: SET VALUE : PersistedView : ##SVViewName
    070 : Save Target
    071: Log:##AMTDr
    072 : End Walk
    073 : Return

    [Collection:purcExcelFileFetchColl]
    Data Source :Directory:#Pur_FilePath
    Filter :ExcelFiles
    Format :$Name,25

    [Collection : PREMIERPurcListSRC]
    Data Source : Variable : Purc_VAR



    [Collection: PREMIERPurcVouchersColl]
    Source Collection : PREMIERPurcListSRC
    By : PremierPurc_VchNo : $Purc_VchNo
    Compute : PremierPurc_VchDate : $Purc_VchDate
    Compute : PremierPurc_Party : $Purc_Party

    AggrCompute : PremierPurc_VchTot : SUM : $Purc_ProductTotAmt

    [Collection: PREMIERPurcVouchersCollExtend]
    Source Collection : PREMIERRcptListSRC
    Compute : PremierPurc_VchNo : $Purc_VchNo
    Compute : PremierPurc_VchNo : $Purc_VchNo
    Compute : PremierPurc_Party : $Purc_Party
    Compute : PremierPurc_ProductName : $Purc_ProductName
    Compute : PremierPurc_ProductQty : $Purc_ProductQty
    Compute : PremierPurc_ProductRate : $Purc_ProductRate
    Compute : PremierPurc_ProductUnit : $Purc_ProductUnit
    Compute : PremierPurc_ProductTotAmt : $Purc_ProductTotAmt
    Filter : PremierPurc_VoucherNumFilter









    [System : Formulas]
    PremierPurc_VoucherNumFilter : $PremierPurc_VchNo = $$ReqObject:$PremierPurc_VchNo; AND $PremierVchName = $$ReqObject:$PremierVchName
     

    Attached Files:



Share This Page