NAV 5.0 SP1
This post will be probably interesting for those who uses method "FIFO",
"LIFO" or Average and there are lots with enough remaining quantity
in this case there is no sense to use "Adjust Cost - Item Entries" report
You'll need to insert into codeunit 22 (function "InsertValueEntry")
a following section of code:
IF ("Entry Type" = "Entry Type"::Sale) OR ("Entry Type" = "Entry Type"::"Negative Adjmt.") THEN BEGIN
QtyLE := 0;
CostLE := 0;
ApplItemLERec.RESET;
ApplItemLERec.SETCURRENTKEY("Item Ledger Entry No.","Output Completely Invd. Date");
ApplItemLERec.SETRANGE("Item Ledger Entry No.", ItemLedgEntry."Entry No.");
IF ApplItemLERec.FIND('-') THEN
REPEAT
ItemLERec.GET(ApplItemLERec."Inbound Item Entry No.");
ItemLERec.CALCFIELDS("Cost Amount (Actual)");
QtyLE += ApplItemLERec.Quantity;
IF ItemLERec.Quantity <> 0 THEN
CostLE += ApplItemLERec.Quantity * ItemLERec."Cost Amount (Actual)" / ItemLERec.Quantity;
UNTIL ApplItemLERec.NEXT = 0;
IF QtyLE <> 0 THEN BEGIN
ValueEntry."Cost per Unit" := CostLE / QtyLE;
ValueEntry."Cost Amount (Actual)" := ValueEntry."Invoiced Quantity" * ValueEntry."Cost per Unit";
END;
END;
before:
IF InvtSetup."Automatic Cost Posting" AND ValueEntry.Inventoriable THEN
IF PostEntry(ValueEntry,ItemJnlLine) THEN
PostInventoryToGL(ValueEntry);
where:
ApplItemLERec Record Item Application Entry
ItemLERec Record Item Ledger Entry
VERec Record Value Entry
CostLE Decimal
QtyLE Decimal
Thus you are getting a real Cost right away after posting.
It's strictly recommended to make a preliminary testing
of amended code