chore: add running stock value difference in invariant report (#29012)
[skip ci]
diff --git a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js
index c484516..31f389f 100644
--- a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js
+++ b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.js
@@ -8,7 +8,8 @@
"fifo_value_diff",
"fifo_valuation_diff",
"valuation_diff",
- "fifo_difference_diff"
+ "fifo_difference_diff",
+ "diff_value_diff"
];
frappe.query_reports["Stock Ledger Invariant Check"] = {
diff --git a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py
index ca47a1e..48753b0 100644
--- a/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py
+++ b/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py
@@ -50,6 +50,7 @@
def add_invariant_check_fields(sles):
balance_qty = 0.0
+ balance_stock_value = 0.0
for idx, sle in enumerate(sles):
queue = json.loads(sle.stock_queue)
@@ -60,6 +61,7 @@
fifo_value += qty * rate
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 = sle.qty_after_transaction
@@ -70,6 +72,7 @@
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
@@ -81,6 +84,7 @@
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
@@ -191,13 +195,22 @@
"fieldtype": "Float",
"label": "D - E",
},
-
{
"fieldname": "stock_value_difference",
"fieldtype": "Float",
"label": "(F) Stock Value Difference",
},
{
+ "fieldname": "stock_value_from_diff",
+ "fieldtype": "Float",
+ "label": "Balance Stock Value using (F)",
+ },
+ {
+ "fieldname": "diff_value_diff",
+ "fieldtype": "Float",
+ "label": "K - D",
+ },
+ {
"fieldname": "fifo_stock_diff",
"fieldtype": "Float",
"label": "(G) Stock Value difference (FIFO queue)",