fix: Remove batch
diff --git a/erpnext/stock/report/stock_ageing/stock_ageing.py b/erpnext/stock/report/stock_ageing/stock_ageing.py
index 7529ae6..790cd8f 100644
--- a/erpnext/stock/report/stock_ageing/stock_ageing.py
+++ b/erpnext/stock/report/stock_ageing/stock_ageing.py
@@ -6,6 +6,7 @@
from frappe import _
from frappe.utils import date_diff, flt
from six import iteritems
+from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
def execute(filters=None):
@@ -18,7 +19,6 @@
details = item_dict["details"]
if not fifo_queue or (not item_dict.get("total_qty")): continue
- print(fifo_queue)
average_age = get_average_age(fifo_queue, to_date)
earliest_age = date_diff(to_date, fifo_queue[0][1])
latest_age = date_diff(to_date, fifo_queue[-1][1])
@@ -151,39 +151,27 @@
if d.actual_qty > 0:
if transfered_item_details.get((d.voucher_no, d.name)):
qty_to_add = d.actual_qty
- while qty_to_add:
- batch = transfered_item_details[(d.voucher_no, d.name)][0]
- if 0 < batch[0] <= qty_to_add:
- qty_to_add -= batch[0]
- fifo_queue.append(batch)
- transfered_item_details[((d.voucher_no, d.name))].pop(0)
- else:
- batch[0] -= qty_to_add
- fifo_queue.append([qty_to_add, batch[1]])
+ batch = transfered_item_details[(d.voucher_no, d.name)][0]
+ fifo_queue.append(batch)
+ transfered_item_details[((d.voucher_no, d.name))].pop(0)
else:
- if d.serial_no or d.batch_no:
+ if d.serial_no:
if d.serial_no:
- for no in d.serial_no.split("\n"):
+ for no in get_serial_nos(d.serial_no):
if serial_no_batch_purchase_details.get(no):
fifo_queue.append([no, serial_no_batch_purchase_details.get(no)])
else:
serial_no_batch_purchase_details.setdefault(no, d.posting_date)
fifo_queue.append([no, d.posting_date])
- else:
- if serial_no_batch_purchase_details.get(d.batch_no):
- fifo_queue.append([d.batch_no, serial_no_batch_purchase_details.get(d.batch_no)])
- else:
- serial_no_batch_purchase_details.setdefault(d.batch_no, d.posting_date)
- fifo_queue.append([d.batch_no, d.posting_date])
-
else:
fifo_queue.append([d.actual_qty, d.posting_date])
else:
if d.serial_no or d.batch_no:
- serial_no_list = d.serial_no.split("\n")
- for serial_no in fifo_queue:
- if serial_no[0] in serial_no_list:
- fifo_queue.remove(serial_no)
+ if d.serial_no:
+ serial_no_list = d.serial_no.split("\n")
+ for serial_no in fifo_queue:
+ if serial_no[0] in serial_no_list:
+ fifo_queue.remove(serial_no)
else:
qty_to_pop = abs(d.actual_qty)
while qty_to_pop: