frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
17.28k stars 6.6k forks source link

Issue when working with Batch (Stock Ledger not calculating Opening Balance) #41507

Closed ablashek closed 2 weeks ago

ablashek commented 2 weeks ago

Information about bug

I have an issue when using ERPNext with

I am trying to make a Delivery Note for an item that when looking at the inventory level is there for the warehouse and batch number in question. image

But if I make the same Stock Ledger report taking into account this year, I get: Negative amounts. It's like report didn't know that there was a stock entry before.

image

Then when I try to make a delivery note, it shows an error that I have negative -28250 units in stock. WhatsApp Image 2024-05-16 at 18 10 09_d79798f1

Basically the issue arrises in Stock Ledger that the Opening Balance isn't taken into account for the discount calculations. Secondly and not sure if this is related, but all throughout the system it shows me I ahve stock on hand under this warehouse/batch code/item combination. But when I actually try to submit it says I have negative value same as when the Stock Ledger report when I limit the dates.

This is causing an issue where I have the goods on hand but I cannot submit any documents. Nor can I transfer, or do a recon.

Module

stock

Version

Frappe Framework v15.27.0 ERPNext v15.23.2

Installation method

FrappeCloud

Relevant log output / Stack trace / Full Error Message.

No response

Nihantra-Patel commented 2 weeks ago

You have to see all the transactions in that batch because somewhere in the transaction entries in that batch you have made a wrong entry. So comes this issue. If the opening data is entered, check if it is proper or not, otherwise, check the batch-wise balance history report. You have to view all transactions in the stock ledger, for that batch. The problem is not with the amount but with the quantity, which is showing as negative.

ablashek commented 2 weeks ago

You have to see all the transactions in that batch because somewhere in the transaction entries in that batch you have made a wrong entry. So comes this issue. If the opening data is entered, check if it is proper or not, otherwise, check the batch-wise balance history report. You have to view all transactions in the stock ledger, for that batch. The problem is not with the amount but with the quantity, which is showing as negative.

You should check the screenshots attached. Many of the comments you pass has already been checked. When I said amount, I mean amount of units ... should have used the word quantity to be more inline with ERPNext lingo.

If you see the image The item has an opening balance of 172,800 units for that time period. The very next row is a deduction (out quantity) of 28,250 units. This should obviously lead to the a balance of (172,800 - 28,250 =) 144,550 units ... but the stock ledger is bringing up -28,250. It's like the balance is not taking into account the opening balance for that period.

This is a BUG, plain and simple.

And if you see my third screenshot image You will see that I cannot transact the quantity of 144,250 units because i have a negative stock of -28,250. Basically the system understands that for that BATCH, that WAREHOUSE, and that ITEM we should have a stock of 144,250 but when calculating within the year the opening balance which shows up isn't being taken into account.

And finally this forum should avoid closing bugs without first understanding what the problem is. My intention of posting is to help other users now and in the future. I've worked out this problem and it doesn't seem like a configuration issue ... plain and simple looks like to be a bug that wasn't there before.