Auto Discount Journal from Daybook

Discussion in 'Free Source Codes' started by NSA, Nov 8, 2021.

    
Tags:
  1. NSA

    NSA Member


    Dear Friends and Experts,

    This is one of the sample TDL I have developed by referring different TDL Codes from this Group. Hope it will be helpful to new friends, and of course expecting comments and positive criticism from the experts.

    Thanking all the Admins and people for this wonderful Group.

    [#Form:Day Book]
    Add:Button:Auto Discount Journal Entry Button
    [Button:Auto Discount Journal Entry Button]
    Key:Ctrl+3
    Title:"Pass discount?"
    Action:Call:Auto Discount Journal Entry Function
    Mode: Display
    Scope: Selected Lines
    Inactive: $$NumLinesInScope = 0
    [Function:Auto Discount Journal Entry Function]
    Variable:RCPCounter:Number
    Variable:RCPADJE Date:Date
    Variable:RCPADJE Discount Ledger:String
    Variable:RCPADJE Discount Amt:Amount
    Variable:RCPADJE Party Ledger:String:""
    Variable:RCPADJE Reference No:String:""
    Variable:RCPDBtempVchMSTID:String
    000:Walk Collection:RCPDBSelectedVocuhers
    010:Set: RCPDBtempVchMSTID:"ID:"+$$String:$MasterID
    015:If:$RCPDiscAutoJournYNoFldStore="No"
    ;;Modifying the User Defined Object/Field whcih prevent from duplication of discount. I have created a user defined field in Sales voucher.
    018:Modify Object:RCPDiscAutoJournYNoFldStore[].RCPDiscAutoJournYNoFldStore:($$string:"Yes")
    020:Set:RCPADJEDate:$Date
    ;;Choosing the right discount Ledger Based on Party Group, Here I am using different discount ledger for different groups
    030:Set:RCPADJEDiscountLedger:If ($Parent:Ledger:$PartyLedgerName)="Jabal Akthar Debtors" Then $$LocaleString:"Jabal Discount Allowed" Else $$LocaleString:"Cash Discount"
    ;;$RCPAgentVCHCommissionAmt is the User defined Discount Amount. I have defined the calculations in sales voucher.
    040:Set:RCPADJEDiscountAmt:$RCPAgentVCHCommissionAmt
    050:Set:RCPADJEPartyLedger:$PartyLedgerName
    060:Set:RCPADJEReferenceNo:$VoucherNumber
    action:070:New Object:Voucher
    action:080:Set Value:Date:##RCPADJEDate
    action:090:Set Value:VoucherTypeName:$$VchTypeJournal
    action:100:Set Value:Narration:$$LocaleString:"Hidden Commission"
    action:110:Insert Collection Object:AllLedgerEntries
    action:120:Set Value:LedgerName:##RCPADJEDiscountLedger
    action:130:Set Value:Is Deemed Positive : "Yes"
    action:140:Set Value:Amount:$$Negative:##RCPADJEDiscountAmt
    action:150:Insert Collection Object:AllLedgerEntries
    action:160:Set Value:LedgerName:##RCPADJEPartyLedger
    action:170:Set Value:Is Deemed Positive : "No"
    action:180:Set Value:Amount:##RCPADJEDiscountAmt
    action:190:INSERT COLLECTION OBJECT : BillAllocations
    action:200: SET VALUE : BillType : $$SysName:AgstRef
    action:210: SET VALUE : Name : ##RCPADJEReferenceNo
    action:220: SET VALUE : Amount : ##RCPADJEDiscountAmt
    action:230: SET TARGET : ...
    action:240: SET TARGET : ..
    action:250: SET VALUE : PersistedView : ##SVViewName
    action:260: CREATE TARGET
    0265:End If
    290:End Walk
     
    Last edited: Nov 9, 2021


  2. MANOJ BARDIA

    MANOJ BARDIA New Member


    showing error boss
    upload_2021-11-10_15-47-34.png
     


  3. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Make a collection of selected voucher(s).
     


  4. PANKAJ BHONDLE

    PANKAJ BHONDLE Active Member



  5. NSA

    NSA Member


    Dear friend,

    Its a sample code. Not a complete coding. Please use it for reference purpose only
     


Share This Page