Item Category wise discount.

Discussion in 'Tally Developer' started by Rupal Agarwal, May 15, 2023.

    
  1. Rupal Agarwal

    Rupal Agarwal Member


    Hello everyone,

    I have created a report to provide Stock Item Category wise discount for sales voucher. Everything is working fine, but the main issue is that the values are not updating according to the values provided in discount report.
    My code is given below
    The only possible condition the code is working for me is as :
    First I have to save the value, accept the voucher, then alter it again to feed the inventory.

    The working of the report is like first we provide the main discount value and then add discount percentage according to the category of stock item.

    Code:
    [#Part: EI BaseInfo]
        Option: RebSale : @@issales
    
    [!Part:Rebsale]
        Add:Line:Before:EI Consignee: PM Rebate
    
    [Line: PM Rebate]
        Field       : Simple Prompt, EI Rebate,
        Local       : Field : Simple Prompt: Info       : $$LocaleString:"Provide Discount:"
        Local         : Field : Simple Prompt: Width        : 14
    
    [Field: EI rebate]
        Use            : Logical Field
        Table        : Yes No Table
        Show Table    : Always
        Storage        : EiRebate
        Sub Form    : PMRebateReport : $$Value= "Yes"
    
    [System:UDF]
        EiRebate : Logical    : 101
    
    ;;============================================ Rebate Value Report ========================================
    
    [Report:PMRebateReport]
        Form:PMRebateReport
    
    [Form:PMRebateReport]
        Part                : PMR Top, PMR Category
        Width                : 65
        Height                : 40% screen
        Vertical Align        : Left
        Horizontal Align    : Top
        Button                : Rebate
       
    [Part:PMR Top]
        Line:PMR Titles, PMR Disc,
        Border    : Thin box
        Common Border    : Yes
    
    [Line: PMR titles]
        Use: PMR Reb
        Border        : Column Titles
        Space Top    : 0.1
        Space Bottom: 0.1
        Local:Field:default        :Delete:Storage
        Local:Field:default        :Skip: Yes
        Local:Field:default        :Style: normal bold
        Local:Field:default        :Align: Center
        Local:Field:PMR Sno        :Info:"S No"
        Local:Field:PMR RName    :Info:"Name"
        Local:Field:PMR RDisc    :Info:"Discount %"
        Local:Field:PMR Reb        :Info:"Rebate %"
        Local:Field:PMR RebPer    :Info:"Total %"
    
    [Line: PMR Disc]
        Field: PMR DB1, PMR DName , PMR DDisc, PMR DB2
        Space Top        : 0.2
        Space Bottom    : 0.2
        Border            : Thin Bottom
    
    [Field:PMR DB1]
        Use            : Name Field
        Set as        : "1.)"
        Skip        : Yes
        Width        : 5
    
    [Field: PMR DName]
        Use            : Name Field
        Set as        : "Discount"
        Width        : 30
        Skip        : Yes
    
    [Field: PMR DDisc]
        Use            : Number Field
        Set as        : if $$IsEmpty:$PmrDisc then $$Value Else $PmrDisc
        Set Always    : Yes
        Format        : "No Zero, Deciaml : 2, Percentage"
        Width        : 10
        Align        : Right
        Space Right    : 1
        Storage        : PmrMainDisc
    
    [System:UDF]
        PmrMainDisc : Number: 126
    
    [Field: PMR DB2]
        Use        : Name Field
        Width    : 20
        Skip    : Yes
    
    ;;--------------------------------------------------------------- Reb Cat Part
    
    [Part:PMR Category]
        Line        : PMR Reb
        Repeat        : PMR Reb : Pmr Aggr
        Break On    : $$IsEndOfList:#PmrRName
        Border        : Thin Box
        Scroll        : Vertical
        Common Border: Yes
    
    [Line: PMR Reb]
        Field: PMR Sno, PMR RName , PMR RDisc, PMR Reb, PMR RebPer
    
    [Field: PMR Sno]
        Use            : Number Field
        Set as        : $$Line
        Set Always    : Yes
        Skip        : Yes
        Width        : 5
        Border        : Thin Right
       
    [Field: PMR RName]
        Use            : Name Field
        Set as        : $$Value
        Table       : List Of ExtractStockCategories, Endoflist
        Show Table  : Always
        Key         : Create StockCategory
        Modifies    : SStockCategory
        Storage        : PmrName
        Width        : 30
        Border        : Thin Right
    
    [Field: PMR RDisc]
        Use            : Number Field
        Set as        : #PmrDDisc
        Set Always    : Yes
        Width        : 5
        Skip Forward: Yes
        Format        : "No Zero, Deciaml : 2, Percentage"
        Width        : 10
        Align        : Right
        Space Right    : 1
        Skip        : Yes
        Storage        : PmrDisc
        Border        : Thin Right
    
    [Field: PMR Reb]
        Use            : Number Field
        Set as        : $$VAlue
        Set Always    : Yes
        Format        : "No Zero, Deciaml : 2, Percentage"
        Width        : 10
        Align        : Right
        Space Right    : 1
        Storage        : PmrReb
        Skip        : $$IsEndOfList:#PMRRname
        Border        : Thin Right
    
    [Field: PMR RebPer]
        Use            : Number Field
        Set as        : #PmrRDisc + #PmrReb
        Set Always    : Yes
        Format        : "No Zero, Deciaml : 2, Percentage"
        Width        : 10
        Align        : Right
        Space Right    : 1
        Skip        : Yes
        Storage        : PMRTotal
    
    [System: UDF]
        Pmr Aggr     : Aggregate    : 110
        Pmr Name     : String    : 112
        Pmr Disc    : Number    : 113
        Pmr Reb     : Number    : 114
        Pmr Total    : Number    : 115
    
    [Collection: PMR Coll]
        Type    : PmrAggr : voucher
        Child Of: ##svVoucherType
        Fetch    : *.*, PmrName, PmrDisc, PmrReb , PmrTotal
    
    ;;========================================================= At voucher =======================================
    
    [#Line : EI Column One]
        Option: Reb Sale Title : @@issales
    
    [!Line: RebSaleTitle]
        Add   : Right Field: At Beginning: RebCat T, RebDisc T
    
    [Field: RebCat T]
        Use            : Name Field
        Set as        : "Category"
        Set Always    : Yes
        Skip        : Yes
        Align        : Left
        Width        : 10
        ; Invisible    : Yes
    
    [Field: RebDisc T]
        Use            : Name Field
        Set as        : "Disc"
        Set Always    : Yes
        Skip        : Yes
        Align        : Center
        Width        : 5
        ; Invisible    : Yes
    
    [#Line : EI Inv Info]
        Option: Reb Sale Title : @@issales
    
    [!Line: RebSaleTitle]
        Add: Right Field:At Beginning: RebCatVal, PmrRebDisc
    [Field: RebCatVal]
        Use            : Name Field
        Set as        : $CATEGORY:STOCKITEM:#VCHSTOCKITEM
        Width        : 10
        Align        : Left
        Set Always    : Yes
        Skip        : Yes
        ; Invisible    : Yes
    
    [Field:Pmrrebdisc]
        Use            : Number Field
        Set as        : $$CollectionFieldByKey:$PmrTotal:@rebname:NewDiscColl;;NewDiscColl;PmrDiscount
        rebname        : $$String:#RebCatVal
        Set Always    : Yes
        Format        : "Deciaml : 2, Percentage"
        Width        : 5
        ;Dynamic        : ""
        Storage        : PmrDiscPer
        ; Invisible    : Yes
        Skip        : $$IsEndOfList:#VchStockitem
    
    [System:UDF]
        pmrdiscper : Number: 125
    
    [Collection:Pmr Discount]
        Type        : PmrAggr : voucher
        Child Of    : ##svVoucherType
        Fetch        : *.*, PmrName, PmrDisc, PmrReb , PmrTotal
    
    [Collection:NewDiscColl]
        Source Collection:..           ; Default
        Walk        : PmrDiscount    ; inventoryentires
        Compute        : Name    : $PmrName
        Compute        : Disc    : $PmrDisc
        Compute        : Reb    : $PmrReb
        Compute        : Total    : $PmrTotal
        Fetch        : *.*, PmrName, PmrTotal, PmrDisc, PmrReb
        Search Key    : $PmrName
    
    [#Field: VCH Discount]
        Delete        : Set By Condition
        Add            : Set By Condition    : @@IsSales            : #Pmrrebdisc
        Set Always    : Yes
    discount.jpg

    Thank you in advance for helping.:D
     

    Attached Files:



Share This Page