mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-17 16:38:41 +00:00
fix: address review comments
- restore mutated SLE after test via addCleanup
- explicit return False in has_difference
- comment the fifo_stock_diff guard for non-queue predecessors
(cherry picked from commit ef5f47fafd)
This commit is contained in:
@@ -128,6 +128,7 @@ def add_fifo_fields(sle, prev_sle):
|
|||||||
sle.fifo_valuation_diff = (
|
sle.fifo_valuation_diff = (
|
||||||
sle.valuation_rate - sle.fifo_valuation_rate if sle.fifo_valuation_rate else None
|
sle.valuation_rate - sle.fifo_valuation_rate if sle.fifo_valuation_rate else None
|
||||||
)
|
)
|
||||||
|
# prev row may not maintain a queue; H and H - F stay blank across the gap
|
||||||
if prev_sle and prev_sle.fifo_stock_value is not None:
|
if prev_sle and prev_sle.fifo_stock_value is not None:
|
||||||
sle.fifo_stock_diff = sle.fifo_stock_value - prev_sle.fifo_stock_value
|
sle.fifo_stock_diff = sle.fifo_stock_value - prev_sle.fifo_stock_value
|
||||||
sle.fifo_difference_diff = sle.fifo_stock_diff - sle.stock_value_difference
|
sle.fifo_difference_diff = sle.fifo_stock_diff - sle.stock_value_difference
|
||||||
|
|||||||
@@ -51,6 +51,13 @@ class TestStockLedgerInvariantCheck(ERPNextTestSuite):
|
|||||||
sle = frappe.get_last_doc(
|
sle = frappe.get_last_doc(
|
||||||
"Stock Ledger Entry", {"item_code": item, "warehouse": WAREHOUSE, "is_cancelled": 0}
|
"Stock Ledger Entry", {"item_code": item, "warehouse": WAREHOUSE, "is_cancelled": 0}
|
||||||
)
|
)
|
||||||
|
self.addCleanup(
|
||||||
|
frappe.db.set_value,
|
||||||
|
"Stock Ledger Entry",
|
||||||
|
sle.name,
|
||||||
|
"qty_after_transaction",
|
||||||
|
sle.qty_after_transaction,
|
||||||
|
)
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
"Stock Ledger Entry", sle.name, "qty_after_transaction", sle.qty_after_transaction + 5
|
"Stock Ledger Entry", sle.name, "qty_after_transaction", sle.qty_after_transaction + 5
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -297,3 +297,5 @@ def has_difference(row, float_precision, currency_precision, difference_in, valu
|
|||||||
return True
|
return True
|
||||||
elif difference_in not in ["Qty", "Value", "Valuation"] and (qty_diff or value_diff or valuation_diff):
|
elif difference_in not in ["Qty", "Value", "Valuation"] and (qty_diff or value_diff or valuation_diff):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user