fix: Remove batch

This commit is contained in:
deepeshgarg007 2019-07-22 15:30:18 +05:30
parent e3a2ab184e
commit 1495c9599a

View File

@ -6,6 +6,7 @@ import frappe
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 @@ def execute(filters=None):
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 @@ def get_fifo_queue(filters):
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: