def METHOD_NAME(sles):
	balance_qty = 0.0
	balance_stock_value = 0.0
	for idx, sle in enumerate(sles):
		queue = json.loads(sle.stock_queue)
		fifo_qty = 0.0
		fifo_value = 0.0
		for qty, rate in queue:
			fifo_qty += qty
			fifo_value += qty * rate
		if sle.actual_qty < 0:
			sle.consumption_rate = sle.stock_value_difference / sle.actual_qty
		balance_qty += sle.actual_qty
		balance_stock_value += sle.stock_value_difference
		if sle.voucher_type == "Stock Reconciliation" and not sle.batch_no:
			balance_qty = frappe.db.get_value("Stock Reconciliation Item", sle.voucher_detail_no, "qty")
			if balance_qty is None:
				balance_qty = sle.qty_after_transaction
		sle.fifo_queue_qty = fifo_qty
		sle.fifo_stock_value = fifo_value
		sle.fifo_valuation_rate = fifo_value / fifo_qty if fifo_qty else None
		sle.balance_value_by_qty = (
			sle.stock_value / sle.qty_after_transaction if sle.qty_after_transaction else None
		)
		sle.expected_qty_after_transaction = balance_qty
		sle.stock_value_from_diff = balance_stock_value
		# set difference fields
		sle.difference_in_qty = sle.qty_after_transaction - sle.expected_qty_after_transaction
		sle.fifo_qty_diff = sle.qty_after_transaction - fifo_qty
		sle.fifo_value_diff = sle.stock_value - fifo_value
		sle.fifo_valuation_diff = (
			sle.valuation_rate - sle.fifo_valuation_rate if sle.fifo_valuation_rate else None
		)
		sle.valuation_diff = (
			sle.valuation_rate - sle.balance_value_by_qty if sle.balance_value_by_qty else None
		)
		sle.diff_value_diff = sle.stock_value_from_diff - sle.stock_value
		if idx > 0:
			sle.fifo_stock_diff = sle.fifo_stock_value - sles[idx - 1].fifo_stock_value
			sle.fifo_difference_diff = sle.fifo_stock_diff - sle.stock_value_difference
		if sle.batch_no:
			sle.use_batchwise_valuation = frappe.db.get_value(
				"Batch", sle.batch_no, "use_batchwise_valuation", cache=True
			)
	return sles