mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-20 02:34:41 +00:00
fix: valuation issue for batch (#41425)
(cherry picked from commit 065163146c)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -1149,7 +1149,18 @@ def make_batch_nos(item_code, batch_nos):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
batch_nos_details.append(
|
batch_nos_details.append(
|
||||||
(batch_no, batch_no, now(), now(), user, user, item.item_code, item.item_name, item.description)
|
(
|
||||||
|
batch_no,
|
||||||
|
batch_no,
|
||||||
|
now(),
|
||||||
|
now(),
|
||||||
|
user,
|
||||||
|
user,
|
||||||
|
item.item_code,
|
||||||
|
item.item_name,
|
||||||
|
item.description,
|
||||||
|
1,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
@@ -1162,6 +1173,7 @@ def make_batch_nos(item_code, batch_nos):
|
|||||||
"item",
|
"item",
|
||||||
"item_name",
|
"item_name",
|
||||||
"description",
|
"description",
|
||||||
|
"use_batchwise_valuation",
|
||||||
]
|
]
|
||||||
|
|
||||||
frappe.db.bulk_insert("Batch", fields=fields, values=set(batch_nos_details))
|
frappe.db.bulk_insert("Batch", fields=fields, values=set(batch_nos_details))
|
||||||
|
|||||||
@@ -498,6 +498,8 @@ class TestSerialandBatchBundle(FrappeTestCase):
|
|||||||
|
|
||||||
make_batch_nos(item_code, batch_nos)
|
make_batch_nos(item_code, batch_nos)
|
||||||
self.assertTrue(frappe.db.exists("Batch", batch_id))
|
self.assertTrue(frappe.db.exists("Batch", batch_id))
|
||||||
|
use_batchwise_valuation = frappe.db.get_value("Batch", batch_id, "use_batchwise_valuation")
|
||||||
|
self.assertEqual(use_batchwise_valuation, 1)
|
||||||
|
|
||||||
batch_id = "TEST-BATTCCH-VAL-00001"
|
batch_id = "TEST-BATTCCH-VAL-00001"
|
||||||
batch_nos = [{"batch_no": batch_id, "qty": 1}]
|
batch_nos = [{"batch_no": batch_id, "qty": 1}]
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ class BatchNoValuation(DeprecatedBatchNoValuation):
|
|||||||
self.set_stock_value_difference()
|
self.set_stock_value_difference()
|
||||||
|
|
||||||
def get_batch_no_ledgers(self) -> list[dict]:
|
def get_batch_no_ledgers(self) -> list[dict]:
|
||||||
if not self.batchwise_valuation_batches:
|
if not self.batches:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
parent = frappe.qb.DocType("Serial and Batch Bundle")
|
parent = frappe.qb.DocType("Serial and Batch Bundle")
|
||||||
@@ -575,7 +575,7 @@ class BatchNoValuation(DeprecatedBatchNoValuation):
|
|||||||
Sum(child.qty).as_("qty"),
|
Sum(child.qty).as_("qty"),
|
||||||
)
|
)
|
||||||
.where(
|
.where(
|
||||||
(child.batch_no.isin(self.batchwise_valuation_batches))
|
(child.batch_no.isin(self.batches))
|
||||||
& (parent.warehouse == self.sle.warehouse)
|
& (parent.warehouse == self.sle.warehouse)
|
||||||
& (parent.item_code == self.sle.item_code)
|
& (parent.item_code == self.sle.item_code)
|
||||||
& (parent.docstatus == 1)
|
& (parent.docstatus == 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user