mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-15 15:45:01 +00:00
fix: filter batches that going to be zero
This commit is contained in:
@@ -2112,6 +2112,9 @@ def get_auto_batch_nos(kwargs):
|
||||
picked_batches,
|
||||
)
|
||||
|
||||
if available_batches and kwargs.get("posting_date"):
|
||||
filter_zero_near_batches(available_batches, kwargs)
|
||||
|
||||
if not kwargs.consider_negative_batches:
|
||||
available_batches = list(filter(lambda x: x.qty > 0, available_batches))
|
||||
|
||||
@@ -2121,6 +2124,26 @@ def get_auto_batch_nos(kwargs):
|
||||
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):
|
||||
batches = []
|
||||
for batch in available_batches:
|
||||
|
||||
Reference in New Issue
Block a user