Merge pull request #3779 from nabinhait/fifo_stack

[fix] Get fifo rate only qty exists in batch
This commit is contained in:
Anand Doshi 2015-08-04 12:26:42 +05:30
commit 4a0edd04c4
3 changed files with 30 additions and 28 deletions

View File

@ -187,3 +187,4 @@ execute:frappe.db.sql("update `tabLeave Type` set include_holiday=0")
erpnext.patches.v5_4.set_root_and_report_type
erpnext.patches.v5_4.notify_system_managers_regarding_wrong_tax_calculation
erpnext.patches.v5_4.fix_invoice_outstanding
execute:frappe.db.sql("update `tabStock Ledger Entry` set stock_queue = '[]' where voucher_type = 'Stock Reconciliation' and ifnull(qty_after_transaction, 0) = 0")

View File

@ -300,7 +300,7 @@ class update_entries_after(object):
# select first batch or the batch with same rate
batch = self.stock_queue[index]
if batch[0]:
if qty_to_pop >= batch[0]:
# consume current batch
qty_to_pop = qty_to_pop - batch[0]

View File

@ -133,6 +133,7 @@ def get_fifo_rate(previous_stock_queue, qty):
qty_to_pop = abs(qty)
while qty_to_pop and previous_stock_queue:
batch = previous_stock_queue[0]
if batch[0]:
if 0 < batch[0] <= qty_to_pop:
# if batch qty > 0
# not enough or exactly same qty in current batch, clear batch