Frappe Cloud Support Partners Foundation Frappe School

Incorrect Valuation Rate in Stock Ledger and Repost Item Valuation not working for back dated cancelation [Release v13.0.0]

When any back dated stock transaction is cancelled then repost item valuation get stuck in Queued and stock ledger is not getting updated. I have tested this on latest [Release v13.0.0].

Later if we post any new transaction for the same item in current date then the item valuation gets updated only for the new transaction and stock balance value get corrected however, all the previous transactions which were recorded prior to current transaction still show wrong calculation in stock ledger.

Moreover the valuation rate is not calculating correctly. Please see in below picture

As visible in above ledger the incoming rate is always 2800 however after some back dated cancelations the repost functionality has calculated wrong valuation rate.

Wondering if anyone got the same problem

Looking for possible solutions

It seems also the balance value suddenly jumps after purchase of 5 kg.

We faced similar issue - but in our case - the item quantities went completely off after the initial attempts. We are on FIFO. We followed these steps to resolve - unsure if/why needed - and not clear why they worked.

Check if there are subsequent stock reconciliations - cancel them. Cancel/delete any pending repost item valuations and attempt them again. Start with the earliest first where you notice an error and then move forward in time with each step. Depending on size of ledger repost item valuation can take time.

Sorry cannot help you more - but would be interesting for the community to learn how you resolve this issue…

We managed to correct the stock ledger and valuation rate once- not sure how but after so many trials and errors. However later on there was one back dated purchase receipt posted and again the stock ledger went crazy!!!

Very confused with this calculation!!!

This reposting idea is knid of bullshit right now. Locks many things up and why it is needed at that stage of maturity is unknown. Messed up all the accounting.

1 Like

@rmehta This seems like a major issue. Our ERP is showing incorrect stock and valuation. And I think the reason is stock ledger entry getting messed up. Is there a way to manually trigger recalculation/reposting of everything?

Dears, @rmehta,
this kind of valuation was not a problem before. Even before diving into the coding itself, we’ve been using perpetual inventory from the start. Now, we receive correction entry requests during stock transaction which were not an issue before. The rate is up to 10% of the inventory value.
Someone should delve into this problem to check what is going on and if it makes any business sense.
Financials is the key to corporate accounts and just this question will decrease the value of the product.
I just don’t understand why a system is posting valuation difference entries now that we are using Erpnext for over 5 years.

1 Like

We are using this function to correct the stock ledger and valuation rate, originally it was a patch in V13

We have a setting in the custom app to enqueue this function and also we setting their reposting start date

The process may take an hour or a day depends on the existing data and the server’s power

I hope it will help


Thanks a lot @youssef… i will test this and update the results.

Just one clarification, if the repost entries are already stuck in queue, Will this code restart them over again or they will be stuck there and new repost will run?

you have to wait for it to be finished before you start a new one.

How was it working before? Why are GL Entries updated? How can we keep a consistent ledger if it keeps being updated in every transaction? Say, we submitted the GL on 30-06-2021 and did a stock entry in 01-07-2021, will that change the GL entry in 30-06-2021? Just does not hold up! Just because it can be codded does not mean it is correct business wise!

If you do Stock Entry on 1st July 2021 but posting date is 30th June 2021, it will repost GL entries then. Otherwise, it will continue normally.