.
The Daybook e-letter news, tips and features to help you get the best from your system

  • more info
  • back to newsletter
  • Purchase ledger macro

    This lengthy, but very useful macro is a good example of the sort of functionality that can be added into your system. It will help you reconcile incoming purchase invoices to purchase orders and make sure that the information carried in the originating sales order matches up with the final sum paid - thereby ensuring that your profit calculations are always accurate. It is not the sort of things that you could write yourself, even with a good knowledge of 4D programming, because it relies on a detailed knowledge of the many thousands of 'methods' that are under the elegant Enterprise 6 hood.

    Just copy the text to a macro, assign it to a function key, or call it from the macros palette next time you have a purchase invoice open.

    ---------------------------------

    `This macro helps you match purchase invoices to purchase orders
    `We suggest that you assign it to a function key for eveyone who enters Purchase Orders
    `(c) Daybook Limited

    If([PURCHASES]Purch Inv No>"")
    mSearch:=Request("Purch Ord No or Order Code to find:")
    If(OK=1)
    QUERY([ORDER ITEMS];[ORDER ITEMS]Purch Ord No=mSearch)
    If(Records in selection([ORDER ITEMS])=0)
    QUERY([ORDER ITEMS];[ORDER ITEMS]Order Code=mSearch)
    End if
    vNo:=records in selection([ORDER ITEMS])
    If(vNo>0)
    COPY NAMED SELECTION([ORDER ITEMS];"mOISel")
    QUERY SELECTION([ORDER ITEMS];[ORDER ITEMS]Supp Inv No="")
    mNo:=records in selection([ORDER ITEMS])-vNo
    If(mNo#0)
    Confirm("NB: "+String(Abs(mNo))+" of those Items already has a Supplier Inv No. Show only those without?";"Yes";"All")
    If(OK=1)
    CLEAR NAMED SELECTION("mOISel")
    Else
    USE NAMED SELECTION("mOISel")
    CLEAR NAMED SELECTION("mOISel")
    End if
    Else
    CLEAR NAMED SELECTION("mOISel")
    End if
    vNo:=records in selection([ORDER ITEMS])
    If(vNo>0)
    READ WRITE([ORDER ITEMS])
    OrderI File
    OUTPUT FORM([ORDER ITEMS];"Items OutPrint")
    Open Pro Window("Select Items to include in Purch Inv")
    MODIFY SELECTION([ORDER ITEMS];*)
    Close ProWin
    Userset
    vNo:=records in selection([ORDER ITEMS])
    Confirm("Add "+String(vNo)+" Items to the Purchase Invoice?")
    If(OK=1)
    FIRST RECORD([ORDER ITEMS])
    While(not(end selection([ORDER ITEMS])))
    CREATE SUBRECORD([PURCHASES]ITEMS)
    Purchases SbLPB
    [PURCHASES]ITEMS'Product Code:=[ORDER ITEMS]Product Code
    PurItems InLPX(->[PURCHASES]ITEMS'Product Code)
    [PURCHASES]ITEMS'Description:=[ORDER ITEMS]Product Name
    [PURCHASES]ITEMS'Quantity:=[ORDER ITEMS]Quantity
    [PURCHASES]ITEMS'Price Per:=[ORDER ITEMS]Price Per
    [PURCHASES]ITEMS'Cost Price:=[ORDER ITEMS]Cost Price
    Purch ItemCalAm
    Purch ItemCalc
    vTot:=1
    [PURCHASES]ITEMS'Our Order No:=[ORDER ITEMS]Purch Ord No
    [PURCHASES]ITEMS'Item Number:=[ORDER ITEMS]Item Number

    [ORDER ITEMS]Supp Inv No:=[PURCHASES]Purch Inv No
    If([ORDER ITEMS]Received Date=!00/00/00!)
    [ORDER ITEMS]Received Date:=◊CDate
    End if
    mResult:=FurthFld Set("Order Items";"Supplier Invoice Date";String(◊CDate)) `or could be Purch Inv Date
    SAVE RECORD([ORDER ITEMS])
    NEXT RECORD([ORDER ITEMS])
    End while
    ALL SUBRECORDS([PURCHASES]ITEMS)
    Purch InLP§("S1")
    Purch InLP
    End if
    End if
    Else
    Alert("No Items found")
    End if
    End if
    Else
    Alert("Please first define the Purchase Invoice No")
    End if

     

    Back to main newsletter »

     
    e-mail:info@daybook.co.uk voice: 020 7582 4000 web: http://www.daybook.co.uk