Code: ;;Shree Ganeshi ;; Function to create a sales voucher when a purchase voucher is created. ;; Only item voice is supported. [#Form: Voucher] On : Form Accept : $$IsPurchase:##SVVoucherType : CALL : FNSalesVchCreate [Function: FNSalesVchCreate] ;; Variable to check first and second LedgerEntry Variable: LedEntCount : Number ;; Creates the purchase voucher before creating the new sales voucher 01 : Create Target 02 : Set : LedEntCount : 0 03 : New Object : Voucher 04 : Set Value : Date : $Date 05 : Set Value : VoucherNumber : $VoucherNumber 06 : Set Value : VoucherTypeName : "Sales" 07 : Set Value : PartyLedgerName : "Customer" 08 : Set Value : PartyName : "Customer" 09 : Set Value : BasicBasePartyName : "Customer" 10 : Set Value : FBTPaymentType : "Default" 11 : Set Value : BasicBuyerName : $BasicBuyerName 12 : Set Value : BasicDateTimeOfInvoice: $BasicDateTimeOfInvoice 13 : Set Value : EffectiveDate : $EffectiveDate 14 : Set Value : IsInvoice : $IsInvoice 15 : Set Value : Narration : $Narration + "Sales" 15a : Set Value : DiffActualQty : $DiffActualQty ;; Walk subobject ledgerentries 16 : Walk Collection : AllLedgerEntries 17 : Insert Collection Object : All Ledger Entries ;; If it is first ledgerenty then ledgername is set to customer else ;; If it is second ledgerentry then ledgername is set to sales else set to $ledger 18 : If : ##LedEntCount = 0 19 : Set Value : LedgerName : "Customer" 20 : Else 20a : IF : ##LedEntCount = 1 21 : Set Value : LedgerName : "Sales" 21a : Else 21b : Set Value : LedgerName : $LedgerName 21c : End If 22 : End If 23 : Set Value : IsDeemedPositive : NOT $IsDeemedPositive 24 : Set Value : IsPartyLedger : $IsPartyLedger 25 : Set Value : Amount : -$Amount 26 : Set : LedEntCount : ##LedEntCount+1 ;; Bill allocations should be created for only first ledger entry 27 : If : ##LedEntCount = 1 27a : Walk Collection : BillAllocations 28 : Insert Collection Object : Bill Allocations 29 : Set Value : Name : "Sales/"+ $Name 30 : Set Value : Bill Type : $BillType 31 : Set Value : Amount : -$Amount 31a : End Walk 32 : Set Target : ... 33 : End If 33a : Walk Collection : Tax Bill Allocations 33b : Insert Collection Object : Tax Bill Allocations 33c : Set Value : Name : "Sales/"+ $Name 33d : Set Value : BillType : $BillType 33e : Set Value : Amount : $Amount 33f : Set Value : IsInputAvail : $IsInputAvail 33g : Set Value : IsPureAgentBill : $IsPureAgentBill 33h : Set Value : TdsTaxRate : $TdsTaxRate 33i : Set Value : TdsSurcharge : $TdsSurcharge 33j : Set Value : STSecondaryCessRate : $STSecondaryCessRate 33k : Set Value : SurchargeAmount : $SurchargeAmount 33l : Set Value : AddlSurchargeAmount : $AddlSurchargeAmount 33m : Set Value : STSecondaryCessAmount : $STSecondaryCessAmount 33n : Set Value : AssessableAmount : $AssessableAmount 33p : End Walk ;; For Second ledger entry Inventory allocations should be created 35 : Walk Collection : Inventory Allocations 36 : Insert Collection Object : Inventory Allocations 37 : Set Value : StockItemName : $StockItemName 38 : Set Value : IsDeemedPositive : NOT $IsDeemedPositive 39 : Set Value : Rate : $Rate 40 : Set Value : Amount : -$Amount 41 : Set Value : ActualQty : -$ActualQty 42 : Set Value : BilledQty : -$BilledQty ;; For each inventory allocation there should be a batch allocation 43 : Walk Collection : BatchAllocations 44 : Insert Collection Object : Batch Allocations 44a : Set Value : Narration : $Narration 44b : Set Value : MfdOn : $MfdOn 44c : Set Value : ExpiryPeriod : $ExpiryPeriod 44d : Set Value : BatchName : $BatchName 44e : Set Value : GodownName : $GodownName 44f : Set Value : DestinationGodownName : $DestinationGodownName 44g : Set Value : ActualQty : -$ActualQty 44h : Set Value : BilledQty : -$BilledQty 44i : Set Value : Amount : -$Amount 44j : Set Value : AddlAmount : -$AddlAmount 44k : Set Value : TrackingNumber : $TrackingNumber 44l : Set Value : OrderNo : $OrderNo 44m : Set Value : OrderDueDate : $OrderDueDate 44n : Set Value : IndentNo : $IndentNo 44o : Set Value : IndentDueDate : $IndentDueDate 52 : End Walk ;; BatchAllocations ;; For each inventory allocation there should be a Additional Details 52a : Walk Collection : Additional Details 52b : Insert Collection Object : Additional Details 52c : Set Value : Name : $Name 52d : Set Value : Rate : $Rate 52e : Set Value : Amount : $Amount 52f : Set Value : AddlAllocType : $AddlAllocType 52g : Set Value : AddlLedPos : $AddlLedPos 52h : End Walk ;; Additional Details 53 : End Walk ;; Inventory Allocations 54 : Set Target : .... ;; Setting the context to Voucher Object 56 : End Walk ;; All Ledger Entries 57 : Create Target 58 : Return ;; End of File
Dear sir, This code is not working. Can u pls update. I changed it a bit, sales voucher is getting created by the amount goes in credit instead of debit.
This file is working when I am creating as Voucher mode. But from Invoice mode its showing No entries in voucher. Thank you