mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
fix: incorrect balance qty in stock ledger if batch filter set (#19480)
This commit is contained in:
committed by
Nabin Hait
parent
b2be301988
commit
7fdef64152
@@ -19,10 +19,26 @@ def execute(filters=None):
|
|||||||
if opening_row:
|
if opening_row:
|
||||||
data.append(opening_row)
|
data.append(opening_row)
|
||||||
|
|
||||||
|
actual_qty = stock_value = 0
|
||||||
|
|
||||||
for sle in sl_entries:
|
for sle in sl_entries:
|
||||||
item_detail = item_details[sle.item_code]
|
item_detail = item_details[sle.item_code]
|
||||||
|
|
||||||
sle.update(item_detail)
|
sle.update(item_detail)
|
||||||
|
|
||||||
|
if filters.get("batch_no"):
|
||||||
|
actual_qty += sle.actual_qty
|
||||||
|
stock_value += sle.stock_value_difference
|
||||||
|
|
||||||
|
if sle.voucher_type == 'Stock Reconciliation':
|
||||||
|
actual_qty = sle.qty_after_transaction
|
||||||
|
stock_value = sle.stock_value
|
||||||
|
|
||||||
|
sle.update({
|
||||||
|
"qty_after_transaction": actual_qty,
|
||||||
|
"stock_value": stock_value
|
||||||
|
})
|
||||||
|
|
||||||
data.append(sle)
|
data.append(sle)
|
||||||
|
|
||||||
if include_uom:
|
if include_uom:
|
||||||
@@ -67,7 +83,7 @@ def get_stock_ledger_entries(filters, items):
|
|||||||
|
|
||||||
return frappe.db.sql("""select concat_ws(" ", posting_date, posting_time) as date,
|
return frappe.db.sql("""select concat_ws(" ", posting_date, posting_time) as date,
|
||||||
item_code, warehouse, actual_qty, qty_after_transaction, incoming_rate, valuation_rate,
|
item_code, warehouse, actual_qty, qty_after_transaction, incoming_rate, valuation_rate,
|
||||||
stock_value, voucher_type, voucher_no, batch_no, serial_no, company, project
|
stock_value, voucher_type, voucher_no, batch_no, serial_no, company, project, stock_value_difference
|
||||||
from `tabStock Ledger Entry` sle
|
from `tabStock Ledger Entry` sle
|
||||||
where company = %(company)s and
|
where company = %(company)s and
|
||||||
posting_date between %(from_date)s and %(to_date)s
|
posting_date between %(from_date)s and %(to_date)s
|
||||||
|
|||||||
Reference in New Issue
Block a user