Item Cost Calculation

akeyakey Member Posts: 5
edited 2010-12-16 in NAV Tips & Tricks
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

Comments

  • akeyakey Member Posts: 5
    I would like to bring up the subject if Alain Krikilion is not against
    it's the Adjust Cost - Item Entries batch job (report ID 795)

    By the way, I would like to know - whether there are remarks,
    suggestions on previous post on Item Cost Calculation
    Any posts are welcome.

    So, let's get down to business
    If you are not using the Adjust Cost - Item Entries batch job (report ID 795)
    not regularly or with a large interval be carefull, as there can be such situation:

    Imagine: A book-keeping closed a period and handed over declarations in a tax and etc
    You start then the Adjust Cost - Item Entries batch job (report ID 795)
    processing brings in the operations of correction in the closed period,
    that can cause the change of amount of turns and balances exactly in this closed period.

    And so what ya gonna do when they come for you. (c) Not mine

    I am not quite sure, but if I do not wrong, the same situation is
    possible with the Adjust Exchange Rates batch job (report ID 595), if you use a few currencies.
    I didn't check this as currently we use only LCY.
    At least in NAV 3.10 I rewrote the Adjust Exchange Rates batch job

    Hope this post will be useful to somebody
Sign In or Register to comment.