How to fetch last purchase unit cost in Inventory tran rep

mkpjsrmkpjsr Member Posts: 587
Hi experts,

Can anybody tell me how to fetch last purchase unit cost of items on "Inventory - Transaction Detail" Report (704).

Comments

  • mkpjsrmkpjsr Member Posts: 587
    Hi all,
    i Have written the following code to get the last purchase unit cost but its not working:

    ItemLedgerEntry->Record->Item Ledger Entry
    LastDate->Date
    UnitCost->Decimal
    TotalValue->Decimal


    ItemLedgerEntry.RESET;
    ItemLedgerEntry.SETRANGE("Document Type","Document Type"::"Purchase Receipt");
    IF ItemLedgerEntry.FIND('-') THEN
    REPEAT
    IF (LastDate < MyRec."Posting Date") OR (LastDate = 0D) THEN
    LastDate := ItemLedgerEntry."Posting Date";
    IF ItemLedgerEntry.Quantity<>0 THEN
    BEGIN
    UnitCost:="Cost Amount (Actual)"/Quantity;
    TotalValue:=UnitCost*Quantity;
    END;

    UNTIL ItemLedgerEntry.NEXT=0;
  • FDickschatFDickschat Member Posts: 380
    You need to do a CALCFIELDS on the field "Cost Amount (Actual)".
    Some remarks:
    - What happens if you have received the goods but they were not invoiced?
    - What if not a receipt was posted but directly an invoice? Do you have the appropriate field ticked in Purch Setup?
    - Why not just use Last Direct Cost from the Item Card / SKU?
    Frank Dickschat
    FD Consulting
  • bbrownbbrown Member Posts: 3,268
    Why are you reading thru all those entries? Don't you just need the last posted entry ("Entry Type" = Purchase)?
    There are no bugs - only undocumented features.
  • mkpjsrmkpjsr Member Posts: 587
    bbrown wrote:
    Why are you reading thru all those entries? Don't you just need the last posted entry ("Entry Type" = Purchase)?

    i tried this but still my problem is not resolved, actually i want to show the last purchase unit cost of the items on the report on "Item Ledger Entry" footer section
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Step one is to define what you (and the client) define as Last Purchase Cost. It sounds simple but you would be surprised just how many options there are or that.
    David Singleton
  • mkpjsrmkpjsr Member Posts: 587
    Step one is to define what you (and the client) define as Last Purchase Cost. It sounds simple but you would be surprised just how many options there are or that.

    In my case "Last Purchase Cost" is the unit cost of the item with last purchase rate.

    For ex suppose i purchase an item x twice:

    Item Date of Purchase Unit Cost
    x 10/01/2010 34.00
    x 12/01/2010 33.50

    so the last purchase cost is 33.50

    that is what i want on the report

    For this i found that if i am able to find the last purchase transaction from item ledger entry then based on that i can find the last purchase unit cost.

    but my logic it not working
  • David_SingletonDavid_Singleton Member Posts: 5,479
    mkpjsr wrote:
    Step one is to define what you (and the client) define as Last Purchase Cost. It sounds simple but you would be surprised just how many options there are or that.

    In my case "Last Purchase Cost" is the unit cost of the item with last purchase rate.
    ...

    As I said the first thing to do is to deffine what you think "Last Purchase Rate" is. If you can't define it then it probably means you don't really know what it is.

    Sit with the client, review all the tables in Navision and determine what they want and then write up a definition.
    David Singleton
Sign In or Register to comment.