ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Inconsistency in Stock Ledger

I have noticed some Inconsistency in Stock Ledger. This inconsistency is leading to wrong Balance Qty in ERPNext.

Please refer to the below screenshot

The cell highlighted should have a Balance Qty of 13, since this item has only been decreased by 1 Qty since last transaction when the Balance was 14. For some reason, the Balance Qty is 0.
These transactions are not back-dated therefore it is unlikely that this issue is arising out of Repost Item Valuation.

I checked the corresponding Stock Ledger Entry, here is the snapshot

Has anyone faced a similar issue? Not sure how to reproduce this issue either.

Note: The item is a serialised Item

By any chance was Negative stock enabled?

Nope, Negative Stock was never enabled

My findings so far

The Actual Qty after Transaction field in Stock Ledger entry for Previous Stock Ledger Entry (for Item and Warehouse combination) is not calculated correctly for some reason, which is leading to wrong Actual Qty after Transaction in current SLE (Current qty_after_transaction = Previous qty_after_transaction + actual_quantity. Not able to find the cause of this issue but looks like this is the problem

I was able to fix the issue (symptomatically) by setting the correct Actual Qty after Transaction at DB level, but still need to find the root cause

Not sure if this report will help in any way

It will be helpful, if someone from Frappe can explain what was the purpose of building this report and if they have faced a similar issue before

Thanks,
Manan