frappe / erpnext

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

Stock Reconciliation for non-batch item doesn't set the actual_qty in Stock Ledger Entry #29948

Closed guilmori closed 2 years ago

guilmori commented 2 years ago

Information about bug

Here I created a Stock Reconciliation for a non-batch item: image

You can see the generated Stock ledger Entry doesn't have a value for actual_qty: image

And while I'm typing this I notice the stock_queue being assigned in the SLE, while the item is using Moving Average valuation method, why is that? image

Module

stock

Version

13.16.0

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

No response

ankush commented 2 years ago

this is intentional. Is there any problem?

Duplicate of: https://github.com/frappe/erpnext/issues/29472 (add more info here if required)

Stock queue addressed here: https://github.com/frappe/erpnext/pull/29302

guilmori commented 2 years ago

Thanks for the quick reply. I have some custom report which SUM(actual_qty), that doesn't work anymore once Stock Recon is made. So is this intentional or will it be fixed as per #29472 ?

ankush commented 2 years ago

This is intentional for sure but just like the problem you faced we also end up adding complexity for this edge case :)

Id like to fix it but no timelines for this.

guilmori commented 2 years ago

This is intentional for sure but just like the problem you faced we also end up adding complexity for this edge case :)

Id like to fix it but no timelines for this.

I would really appreciate if you can give me some reference code where this additional complexity is handled. No worry if you don't have time, I can search for it too :-)

ankush commented 2 years ago

Check stock balance report code.

Also bin doctype might be better for building simple integration / reports on stock qty.

guilmori commented 2 years ago

Check stock balance report code.

Also bin doctype might be better for building simple integration / reports on stock qty.

I can't use bin doctype as I need batch-wise qty and prices.

I'm building this simple Stock List: image

Building my own because I didn't find any built-in report showing batch-wise actual qty and price. This was my query, but now the Stock Recon breaks the sum(actual_qty)... so I'll have to query non-batch items another way.

select sle.item_code, item.item_group, sle.warehouse, IFNULL(sle.batch_no,'') as batch_no, item.stock_uom, 
sum(sle.actual_qty) as qty, 
sum(sle.stock_value_difference) AS total_value,
sum(sle.stock_value_difference) / sum(sle.actual_qty) AS unit_value
from `tabStock Ledger Entry` sle
inner join `tabItem` item ON item.name = sle.item_code
left join `tabBatch` batch ON batch.name = sle.batch_no
where sle.is_cancelled = 0 and sle.docstatus < 2
group by sle.warehouse, IFNULL(sle.batch_no,''), sle.item_code
having sum(sle.actual_qty) != 0
order by item.item_group, sle.item_code, sle.warehouse