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;
IF InvtSetup."Automatic Cost Posting" AND ValueEntry.Inventoriable THEN IF PostEntry(ValueEntry,ItemJnlLine) THEN PostInventoryToGL(ValueEntry);
ApplItemLERec Record Item Application Entry ItemLERec Record Item Ledger Entry VERec Record Value Entry CostLE Decimal QtyLE Decimal
Comments
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