mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-17 00:18:39 +00:00
fix: resolve float precision before streaming stock ledger entries
get_single_value inside _revalue_reconciled_batch_slots runs while rows stream through the unbuffered cursor on MariaDB, killing the active iterator. Resolve it once in generate() with the other prefetches.
This commit is contained in:
@@ -306,6 +306,7 @@ class FIFOSlots:
|
|||||||
|
|
||||||
# prepare single sle voucher detail lookup
|
# prepare single sle voucher detail lookup
|
||||||
self.prepare_stock_reco_voucher_wise_count()
|
self.prepare_stock_reco_voucher_wise_count()
|
||||||
|
self.float_precision = get_float_precision()
|
||||||
|
|
||||||
if stock_ledger_entries is None:
|
if stock_ledger_entries is None:
|
||||||
# streaming path: nested queries invalidate the streaming cursor below,
|
# streaming path: nested queries invalidate the streaming cursor below,
|
||||||
@@ -408,7 +409,6 @@ class FIFOSlots:
|
|||||||
slot[FIFO_VALUE_INDEX] = flt(slot[FIFO_QTY_INDEX] * flt(row.valuation_rate))
|
slot[FIFO_VALUE_INDEX] = flt(slot[FIFO_QTY_INDEX] * flt(row.valuation_rate))
|
||||||
|
|
||||||
def _revalue_reconciled_batch_slots(self, fifo_queue: list, batch_nos: list) -> None:
|
def _revalue_reconciled_batch_slots(self, fifo_queue: list, batch_nos: list) -> None:
|
||||||
precision = get_float_precision()
|
|
||||||
for batch_no, _use_batchwise_valuation, qty, stock_value_difference in batch_nos:
|
for batch_no, _use_batchwise_valuation, qty, stock_value_difference in batch_nos:
|
||||||
if not flt(qty):
|
if not flt(qty):
|
||||||
continue
|
continue
|
||||||
@@ -418,7 +418,7 @@ class FIFOSlots:
|
|||||||
for slot in fifo_queue
|
for slot in fifo_queue
|
||||||
if is_batch_slot(slot) and slot[BATCH_SLOT_BATCH_INDEX] == batch_no
|
if is_batch_slot(slot) and slot[BATCH_SLOT_BATCH_INDEX] == batch_no
|
||||||
]
|
]
|
||||||
if flt(sum(flt(slot[BATCH_SLOT_QTY_INDEX]) for slot in slots) - flt(qty), precision):
|
if flt(sum(flt(slot[BATCH_SLOT_QTY_INDEX]) for slot in slots) - flt(qty), self.float_precision):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
rate = flt(stock_value_difference) / flt(qty)
|
rate = flt(stock_value_difference) / flt(qty)
|
||||||
|
|||||||
Reference in New Issue
Block a user