Post additional value entry to cancel an incorrect cost entry

The question is detail should be: How can I post a correction value entry that affects both costs entries (Value Entry and GL Entry) of a specific Item Ledger Entry move without quantity to a move with a different posting date?


A few months ago we had a developer that creates a Codeunit/Xmlport to use it in a Web Service App to handle Item transfers. The idea was to import into Item Journal lines transferences of items between different Locations/Bins, then will call the “Item Jnl.-Post” Codeunit with the Journal lines table. The Web Service works great, but he didn’t catch error exceptions in the XML Imports execution and sometimes the users were trying to reallocate items that don’t have existence in the current location. The Web Service receives a warning but inserts the transfer line anyway and when the Codeunit executes the error arises.

The error:

Before detecting the error the user tried one or more times to transfer the product before noticing that the existence wasn’t enough. And now I have like 100 transfers in my Item Ledger Entry that shows with the entry type of transfer but only one line instead of two and quantity of 0. This movements have increase the cost of items without quantity and I can’t revaluate the item without quantity.


Modify the Xmlport to load into a Temporary table to validate every field. =)

I forgot to add that I’m using Average cost as cost method