auto post selected purchases to sales (error)

Discussion in 'Free Source Codes' started by love, Sep 20, 2021.

    
  1. love

    love Member


    dear experts i have used two source codes from this site and knowledge blessed upon by experts to create this code

    problem lies in function as credit and debit totals do not match , in fact total amount of credit is (double of total inventories -amount of 1st inventory) plz help
    special request @@himanshu and @@devendra ji sir , plz help


    [#Menu: Gateway of Tally]
    Add : Item : my purchases : Display : mypurchase

    [Report: mypurchase]
    Add: Form: mypurchase

    Variables : SV CurrentCompany, SV FromDate, SV ToDate
    Set : SV Sort Method : @@Default
    Set : SVFromDate : $$MonthStart:##SVCurrentDate-30
    Set : SVToDate : $$MonthEnd:##SVCurrentDate




    [Form: mypurchase]
    Part: mypurchase
    Height: 100 % screen
    Width: 100 % Screen
    Bottom Part:BOTTOM INFO PUR


    Add: ButtonS: ChangePeriod, REMOVE SELECTED






    [Part: mypurchase] ;Main part contains data
    Add: Lines: mypurchase Column Titles, mypurchase
    Repeat: mypurchase : PQRorderbyVouchersColl
    Scroll : Vertical
    Common Border: YES
    Total:MyVCHValue,Myvchqty

    Bottom Lines:mypurchase TOT



    [Line:mypurchase Column Titles] ;Titles lines
    Use: mypurchase
    Local : Field : Default : Type : String
    Local : Field : Default : Style : Tiny Bold
    Local : Field : Default : Align : Centre
    Local: Field: MySNo : Info: "S No"
    Local: Field: Mydate : Info: "Date"
    Local: Field: MYVCHNo. : Info: "VCH No."
    Local: Field: MYPARTY : Info: "Party Name"
    Local: Field: MyVCHValue : Info: "Amount"
    Local: Field: Default : Color: blue
    Local: Field: Default : Style: Book Antiqua Italic

    Border: Column Titles

    [Line: my purchase] ;Main line

    Field:MySno, Mydate,MYVCHNo., MYPARTY,
    Right Field: MyVCHValue
    ;Space Top: 0.50
    ; Height: 1.5
    ;Explode: MyExplode part : ($$KeyExplode or ##Explodeflag)
    Border: Double Sub Column Titles

    ;Option:ALTER ON ENTER


    [Line:mypurchase TOT] ;Titles lines
    Use: mypurchase
    Local : Field : Default : Type : String
    Local : Field : Default : Style : Tiny Bold
    Local : Field : Default : Align : Centre
    Local: Field: MySNo : Info: ""
    Local: Field: Mydate : Info: ""
    Local: Field: MYVCHNo. : Info: ""
    Local: Field: MYPARTY : Info: "Total"
    Local: Field: MyVCHValue : Set as: $$Total:MyVCHValue
    Local: Field: Default : Color: blue
    Local: Field: Default : Style: Book Antiqua Italic

    Border: Column Titles



    [PART:BOTTOM INFO PUR]
    Line:BOTTOM INFO PUR
    Background:Lily Yellow
    [Line:BOTTOM INFO PUR]
    FIELD: MEDIUM PROMPT,BOTTOM INFO PUR
    Local:Field:MEDIUM PROMPT: Info:"INFO"

    Local: Field: MEDIUM PROMPT : Color: RED
    Local: Field: MEDIUM PROMPT : Style: Book Antiqua Italic

    [Field:BOTTOM INFO PUR]
    Use: NAME FIELD
    Info:"Press Alt+ENTER to edit voucher/Select Purchases to post AND press Alt+3"
    Color: RED
    Width:80% SCREEN



    [Field:MYSno]
    Set as : $$Line
    Width : 3% Page
    Align : Center
    Border : Thin Left Right
    Skip: Yes
    Width:3% PAGE


    [Field: Mydate]
    Use: Short Date Field
    Set as: $Date
    Width:8% Page
    Alter: Voucher

    [Field: MYVCHNo.]
    Use: Name field
    Set as: $Reference
    Width:15% Page
    Align: Center
    Border : Thin Left

    [Field: MYPARTY]
    Use: Name Field
    Set as: $partyLedgername
    Border : Thin Left
    Width:30% Page


    [Field: MyVCHValue]
    Use:Amount Field
    Set as: $Amount
    Border: Thin Left












    [Button : REMOVE SELECTED]
    Title : "SHOW SELECTED"
    Key :F3
    Action :Alter:SELQREPORT
    ; Action :Call: selected12 Voucher Object
    ;Mode : Display
    ;Scope : Selected Lines
    Inactive : $$NumLinesInScope = 0









    ;================================================================================================
    ;===================================== Collections =================================================

    [Collection: PQRorderbyVouchersColl]
    Type : Voucher
    Fetch : Date, VoucherNumber, VoucherTypeName,LedgerName,PartyLedgerName,VCHorderbyName,GrossProfit,GROSSREVENUE, LedgerEntries.*,inventoryentries
    Filter : MYpartyPURVouchers




    [System: Formula]

    MYpartyPURVouchers: $$IsPurchase:$VoucherTypeName






    [Collection:Selected Master]

    Data Source : Parent Report : Selected lines
    Fetch: partyledgername



    ;;=================================================
    ;;======================================
    ;;=================================================



    ;
    ;second report to show items belongig to selected vouchers and being posted on auto selection
    ;
    ;




    [Report: SELQReport]
    ;Use : DSP Template
    Form : SELQReport
    Title : "Outward Sale Report"
    Set : SVFromDate : $$MonthStart:##SVCurrentDate-30
    Set : SVToDate : $$MonthEnd:##SVCurrentDate
    ;Variables:SHOWLEDPARENT, LEDGERNAME
    variable:temp
    Variable:abtotal
    Variable:abdate:Date





    [Form: SELQReport]
    ;Use : DSP Template
    Parts :SELVCHPRT, SELQReport,selqtot
    Height : 100% screen
    Width : 100% screen
    Delete : Buttons: ExplodeFlag

    Add: ButtonS: PRINT BUTTON,REMOVE SELECTED
    add:page Break:pbSELQTitile
    on :form accept:yes:call:advancebooking:##temp:##abdate:#abname:#ABvchno:#ABTOTAL






    [Part:SELVCHPRT]

    line : SELVCHPRT
    Background:DIM GREY
    [line:SELVCHPRT]
    Fields : ABTIT1, ABvchno,ABTIT2, ABDATE,ABTIT3, ABname
    Space Bottom:1
    Space Bottom:1

    [field : ABvchno]
    Use: NUMBER FIELD
    Width:10% SCREEN
    Background:Light Orange
    Align:Center
    Modifies:ABVCHNO: YES
    Skip: Yes

    [Field:ABTIT1]
    Set as : $$LocaleString:"Vouher No."
    Skip: Yes
    Background:Lily White
    Width: 15% SCREEN
    [Field:ABTIT2]
    Set as : $$LocaleString:"Date"
    Skip: Yes
    Background:Lily White
    Width:15% SCREEN
    [Field:ABTIT3]
    Set as : $$LocaleString:"Party name:"
    Skip: Yes
    Background:Lily White
    Width: 15% SCREEN
    [field : ABDATE]
    use:uni date field
    modifies:abdate:yes
    Width:20% SCREEN
    Background:Light Orange
    Align: Center

    [field : ABName]
    use:name field
    table:collxn ledger
    Show Table : Always
    Key: Create Ledge1
    Set Always:Yes
    Width:45% SCREEN
    Background:Light Orange
    Align: Center


    [COLLECTION: COLLXN LEDGER]
    TYPE:LEDGER
    USE:ALIAS COLLECTION
    FETCH:NAME
    Format : $LedgerName,CLOSING BALANCE 25
    CHILDOF:SUNDRYDEBTORS

    [Key: Create Ledge1]
    Key : Alt+C
    Action : Create :Ledger





    [Line: SELQTitile]

    Field:SELQSno1,SELQItemName1,SELQQty1,SELQUnit1,SELQRate1,SELQAmount1
    Border :Thin Bottom

    Local : Field : Default : Type : String
    Local : Field : Default : Style : Tiny Bold
    Local : Field : Default : Align : Centre
    Local : Field : SELQSno1 : set as: $$LocaleString:"SRNo"
    Local : Field : SELQItemName1 : Set as: $$LocaleString:"ITEM NAME"
    Local : Field : SELQQty1 : Set as: $$LocaleString:"QTY"
    Local : Field : SELQUnit1 : Set as: $$LocaleString:"Unit"
    Local : Field : SELQRate1 : Set as: $$LocaleString:"RATE"
    Local : Field : SELQAmount1 : Set as: $$LocaleString:"AMOUNT"
    Border : Flush Totals




    [ Field : SELQSno1]
    set as: :""
    Width : 4% Screen
    Align : Center
    Border : Thin Left Right
    Background:GREY

    [Field : SELQItemName1]
    Set as: ""
    Width : 20% Screen
    Background:GREY

    [ Field : SELQQty1]
    Set as: ""
    Width : 5% Screen
    Background:GREY

    [Field : SELQUnit1]
    Set as: ""
    width: 3% Screen
    Background:GREY

    [ Field : SELQRate1]
    Set as: ""
    Width : 4% Screen
    Background:GREY







    [Line:SELQBody]

    Field:SELQSno,SELQItemName,SELQQty,SELQUnit,SELQRate,SELQAmount
    Border :Thin Bottom

    [Field:SELQSno]
    Use: NUMBER FIELD
    Set as : $$Line
    Width : 4% Screen
    Align : Center
    Border : Thin Left Right
    Skip: Yes
    modifies:temp:yes


    [Field: SELQItemName]
    Use :Name Field
    Set as :$SELQItemName
    Border : Thin Left
    Width : 20% Screen
    Align : Left
    ;Style : Tiny
    modifies:listabitem[$$line]:yes
    Skip: Yes

    [Field:SELQNewdisc]
    Use:NUMBER Field
    ;Set as :$SELQNewdisc
    Border : Thin Left
    Width : 4% Screen
    Align : Right
    Set as : if NOT $$IsDr:$SELQNewdisC then $SELQNewdisc else 0
    modifies:listabgodown[$$line]:yes
    Skip: Yes

    [Field:SELQQty]
    use : Qty field
    width: 5% Screen
    Border:thin left
    align: right
    set as:$SELQQty
    Format: "No Symbol, Short Form, No Compact"
    modifies:listabqty[$$line]:yes
    Skip: Yes


    [Field:SELQUnit]
    use : Number Field
    width: 3% Screen
    Border:thin left
    align: right
    set as:$SELQUnit
    Type : Rate : Unit Symbol
    Style : Small Bold
    Format: "No Symbol, Short Form, No Compact"
    Skip: Yes

    [Field:SELQRate]
    Use:Number Field
    Set as :$SELQRate
    Border : Thin Left
    Width : 4% Screen
    Align : Right
    ;Format: "No Short Form, Compact"
    ;Style : Tiny
    ;Format : "no Symbol," + ##ShowForex
    modifies:listabrate[$$line]:yes
    Skip: Yes

    [Field: SELQAmount]
    Use : Amount Field
    Set as : $SELQAmount
    Border : Thin Left
    Width : 5% Screen
    Align : Right
    ;Style : Tiny
    ;Format : "No Zero,DrCr,Symbol," + ##ShowForex
    modifies:listabamount[$$line]:yes
    Skip: Yes


    [Field: SELQAmount1]
    Use : Amount Field
    Set as :$$TOTAL:SELQAmount
    Border : Thin Left
    Width : 5% Screen
    Align : Right
    Set Always: Yes
    Skip: Yes
    [FIELD:totalamount]

    USE:amount FIELD
    Width : @@AmountWidth
    SET ALWAYS:YES
    set as:#SELQAmount1
    skip:yes





    [Part: selqtot]
    Line: selqbody total

    [Line: SELQBody Total]



    Field:SELQSno1,totalAMOUNT,SELQItemName1,SELQQty1,SELQUnit1,SELQRate1,SELQAmount
    Border :Thin Bottom

    Local : Field : Default : Type : String
    Local : Field : Default : Style : Tiny Bold
    Local : Field : Default : Align : Centre
    Local : Field : SELQSno1 : Set as: ""
    Local : Field : SELQSno1 : Skip:Yes
    Local : Field : totalamount : set as:#SELQAmount
    Local : Field : totalamount : Color: RED
    Local : Field : totalamount : Skip: Yes
    local : field : SELQItemName1 :set as: "TOTAL"
    Local : Field : SELQItemName1 :COLOR: BLUE
    local : field : SELQItemName1 :Skip: Yes
    local : field : SELQQty1 :set as:$$Total:SELQQty
    local : field : SELQQty1 :Skip: Yes
    local : field : SELQUnit1 :set as:""
    local : field : SELQUnit1 :Skip: Yes
    Local : Field : SELQRate1 : Set as: ""
    Local : Field : SELQRate1 : Skip: Yes
    Local : Field : SELQAmount : Set as: $$Total:SELQAmount
    Local : Field : SELQAmount : Color: RED
    Local : Field : SELQAmount : Skip: Yes
    Border : Flush Totals






    ;================================================================================================
    ;===================================== Collections =================================================
    [Part: SELQReport]
    Lines:SELQTitile,SELQBody
    Repeat : SELQBody:Sales AllVoucher1
    CommonBorder: Yes
    Scroll : Vertical
    Total:SELQAmount,SELQIGAmount,SELQQty




    [Collection: SELQSalesManVouchersColl]
    Type:Vouchers:VoucherType
    Fetch:myvchorderbyname,myvchorderbyname1, PARTYLEDGERNAME
    Data Source:parent Report: SELECTED LINES



    [Collection:Sales AllVoucher1]
    Source Collection:SELQSalesManVouchersColl
    Walk:Inventory Entries

    Compute : SELQItemName :$StockItemName
    Compute : SELQQty :$BilledQuantity
    Compute : SELQUnit :$Rate
    Compute : SELQRate :$RATE ;$Rate
    Compute : SELQAmount :mad:@MYNEWAMOUNT




    [System: Formula]

    MYNEWAMOUNT:$BilledQuantity*$RATE





    [System:Variables]

    list variable:listabitem:STRING:100
    list variable:listabqty:Quantity:100
    list variable:listabrate:Number:100
    list variable:listabamount:amount:100
    list variable:listabgodown:Number:100

    [variable:temp]
    type:number
    [Variable:ABTOTAL]
    Type:Amount

    [function:ADVANCEBOOKING]
    Parameter:Temp:Number
    Parameter:abdate:Date
    Parameter:abname:String
    Parameter:ABvchno:Number
    Parameter:TOTALAMOUNT:Amount
    Variable:counter:Number
    Variable:todate:Date
    Returns:String
    Variable:a:Date

    110:Set:counter:1


    800 : Set : SVViewName :$$SysName:InvVchView
    900 : SET : SV VoucherType : "sales ";;$$VchTypeSalesOrder
    1000 : NEW OBJECT : Voucher

    1200 : SET VALUE : Date : $$Tgtobject:##ABDATE
    1201 : Log : ##ABDATE
    1300 : SET VALUE : VoucherTypeName : "Sales";;$$String:$$VchTypeSalesOrder
    ;1301:Set: TOTALAMOUNT: ##ABTOTAL
    1302 : Set Value : VOUCHERNUMBER : ##ABvchno
    1303 : Log : ##ABvchno
    1500 : Set Value : REFERENCE : $$Tgtobject:##ABDATE
    1600 : Set Value : PARTYLEDGERNAME : $$Tgtobject:##ABNAME
    1601 : Log : ##ABNAME
    1700 : INSERT COLLECTION OBJECT : LedgerEntries
    1800 : SET VALUE : LedgerName : $$Tgtobject:##ABNAME
    1801: Log: #TOTALAMOUNT
    1900 : SET VALUE : IsDeemedPositive: Yes
    2000 : SET VALUE : ISPARTYLEDGER : Yes
    2100 : Set Value : AMOUNT : $$Tgtobject:$$AsAmount:#TOTALAMOUNT*-1;;$$Negative:##totalamount
    2200 : SET TARGET : ..

    2300 : Set : counter :1
    2400 : While : ##counter<=##temp

    2500 : INSERT COLLECTION OBJECT : ALLINVENTORYENTRIES
    2700 : SET VALUE : Stock Item Name : $$Tgtobject:##listabitem[##counter]
    2800 : SET VALUE : IsDeemedPositive : No

    2900 : SET VALUE : rate : $$tgtobject:$$AsRate:##listabrate[##counter]
    3000 : SET VALUE : amount : $$Tgtobject:$$AsAmount:##listabamount[##counter]
    3100 : Set Value : actualqty : $$Tgtobject:$$AsQty:##listabqty[##counter]*-1
    3200 : Set Value : billedqty : $$Tgtobject:$$AsQty:##listabqty[##counter]*-1
    2701 : Log:##listabitem[##counter]
    3201 : Log:##listabqty[##counter]
    3201A : Log:##listabrate[##counter]
    3201B : Log:##listabamount[##counter]
    3201C : Log:##listabqty[##counter]*-1

    3500 : INSERT COLLECTION OBJECT : BATCHALLOCATIONS
    ; 3700 : SET VALUE : godownname : "primary"
    ;3700 : SET VALUE : DISCOUNT : $$Tgtobject:##listabgodown[##counter]
    3800 : SET VALUE : batchname : "Primary batch"
    ;3900 : SET VALUE : destinationgodownname : "primary" ;$$Tgtobject:##listabgodown[##counter]
    4000 : SET VALUE : amount : $$Tgtobject:$$AsAmount:##listabamount[##counter]
    4100 : Set Value : actualqty : $$Tgtobject:$$Asqty:##listabqty[##counter];;*-1
    4200 : Set Value : billedqty : $$Tgtobject:$$Asqty:##listabqty[##counter];;*-1
    4300 : Set Value : orderduedate : $$Tgtobject:$$DateRange:##abdate:##abdate:Yes+15
    ;;4400 : Set Target:..
    ;;4410 : Increment:counter
    ;;4420 : End While
    4500 : INSERT COLLECTION OBJECT : ACCOUNTINGALLOCATIONS
    ; 4600 : SET TARGET : accountingallocations
    4700 : SET VALUE : ledgername : "Sales Gst"
    4800 : SET VALUE : IsDeemedPositive : No
    4900 : SET VALUE : ispartyledger : No
    5000 : SET VALUE : amount : $$Tgtobject:$$AsAmount:##listabamount[##counter]
    ;5400:Set Target:..
    ;;5500:Set Target:..
    5510 : Increment:counter
    5520 : End While
    9996 : Set Value : PersistedView : ##SVViewName
    9997 : Create Target
    ; 9999 : RETURN
     


  2. Devendra_Rawat

    Devendra_Rawat Well-Known Member


    Hi.. best way to solve such issues is.
    Pass a similar entry in Tally. Export the voucher in XML format, then open the XML file in Web Browser..

    It will show you structure of the voucher in Tally. with Objects, Collections, method names and their values .. try to understand the XML .. you can notice , where the amount should be Negative and where the Quantity should be negative and make required changes in TDL
     
    gangstar and love like this.


Share This Page