mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-18 06:15:10 +00:00
fix: filter batches that going to be zero
(cherry picked from commit aba512c1c6)
This commit is contained in:
committed by
Mergify
parent
02ff406b7c
commit
ac97489a32
@@ -2094,6 +2094,9 @@ def get_auto_batch_nos(kwargs):
|
|||||||
picked_batches,
|
picked_batches,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if available_batches and kwargs.get("posting_date"):
|
||||||
|
filter_zero_near_batches(available_batches, kwargs)
|
||||||
|
|
||||||
if not kwargs.consider_negative_batches:
|
if not kwargs.consider_negative_batches:
|
||||||
available_batches = list(filter(lambda x: x.qty > 0, available_batches))
|
available_batches = list(filter(lambda x: x.qty > 0, available_batches))
|
||||||
|
|
||||||
@@ -2103,6 +2106,26 @@ def get_auto_batch_nos(kwargs):
|
|||||||
return get_qty_based_available_batches(available_batches, qty)
|
return get_qty_based_available_batches(available_batches, qty)
|
||||||
|
|
||||||
|
|
||||||
|
def filter_zero_near_batches(available_batches, kwargs):
|
||||||
|
kwargs.batch_no = [d.batch_no for d in available_batches]
|
||||||
|
|
||||||
|
del kwargs["posting_date"]
|
||||||
|
del kwargs["posting_time"]
|
||||||
|
|
||||||
|
available_batches_in_future = get_available_batches(kwargs)
|
||||||
|
for batch in available_batches:
|
||||||
|
if batch.qty <= 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for future_batch in available_batches_in_future:
|
||||||
|
if (
|
||||||
|
batch.batch_no == future_batch.batch_no
|
||||||
|
and batch.warehouse == future_batch.warehouse
|
||||||
|
and future_batch.qty <= 0
|
||||||
|
):
|
||||||
|
batch.qty = 0
|
||||||
|
|
||||||
|
|
||||||
def get_qty_based_available_batches(available_batches, qty):
|
def get_qty_based_available_batches(available_batches, qty):
|
||||||
batches = []
|
batches = []
|
||||||
for batch in available_batches:
|
for batch in available_batches:
|
||||||
|
|||||||
Reference in New Issue
Block a user