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;
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?
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
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.
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.
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.
Comments
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;
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?
FD Consulting
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
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
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.