mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-28 00:55:19 +00:00
* fix: incorrect current qty in stock reco (#51152) (cherry picked from commitdec474ef3a) * chore: fix conflicts --------- Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com> (cherry picked from commit89d6a8f02e)
This commit is contained in:
@@ -166,7 +166,9 @@ class Batch(Document):
|
|||||||
for row in batches:
|
for row in batches:
|
||||||
batch_qty += row.get("qty")
|
batch_qty += row.get("qty")
|
||||||
|
|
||||||
self.db_set("batch_qty", batch_qty)
|
if self.batch_qty != batch_qty:
|
||||||
|
self.db_set("batch_qty", batch_qty)
|
||||||
|
|
||||||
frappe.msgprint(_("Batch Qty updated to {0}").format(batch_qty), alert=True)
|
frappe.msgprint(_("Batch Qty updated to {0}").format(batch_qty), alert=True)
|
||||||
|
|
||||||
def set_batchwise_valuation(self):
|
def set_batchwise_valuation(self):
|
||||||
|
|||||||
@@ -1227,32 +1227,23 @@ class StockReconciliation(StockController):
|
|||||||
def get_batch_qty_for_stock_reco(
|
def get_batch_qty_for_stock_reco(
|
||||||
item_code, warehouse, batch_no, posting_date, posting_time, voucher_no, sle_creation
|
item_code, warehouse, batch_no, posting_date, posting_time, voucher_no, sle_creation
|
||||||
):
|
):
|
||||||
ledger = frappe.qb.DocType("Stock Ledger Entry")
|
qty = (
|
||||||
posting_datetime = get_combine_datetime(posting_date, posting_time)
|
get_batch_qty(
|
||||||
|
batch_no,
|
||||||
query = (
|
warehouse,
|
||||||
frappe.qb.from_(ledger)
|
item_code,
|
||||||
.select(
|
creation=sle_creation,
|
||||||
Sum(ledger.actual_qty).as_("batch_qty"),
|
posting_date=posting_date,
|
||||||
|
posting_time=posting_time,
|
||||||
|
ignore_voucher_nos=[voucher_no],
|
||||||
|
for_stock_levels=True,
|
||||||
|
consider_negative_batches=True,
|
||||||
|
do_not_check_future_batches=True,
|
||||||
)
|
)
|
||||||
.where(
|
or 0
|
||||||
(ledger.item_code == item_code)
|
|
||||||
& (ledger.warehouse == warehouse)
|
|
||||||
& (ledger.docstatus == 1)
|
|
||||||
& (ledger.is_cancelled == 0)
|
|
||||||
& (ledger.batch_no == batch_no)
|
|
||||||
& (ledger.voucher_no != voucher_no)
|
|
||||||
& (
|
|
||||||
(ledger.posting_datetime < posting_datetime)
|
|
||||||
| ((ledger.posting_datetime == posting_datetime) & (ledger.creation < sle_creation))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.groupby(ledger.batch_no)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
sle = query.run(as_dict=True)
|
return flt(qty)
|
||||||
|
|
||||||
return flt(sle[0].batch_qty) if sle else 0
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
|||||||
Reference in New Issue
Block a user