test(stock): add ledger preview unit tests (#58700)

This commit is contained in:
Afsal Syed
2026-09-08 18:51:06 +05:30
committed by Sudharsanan11
parent 2932793af0
commit 5edb7e2abc

View File

@@ -0,0 +1,23 @@
# Copyright (c) 2026, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from unittest.mock import patch
import frappe
from frappe.tests import UnitTestCase
from erpnext.controllers.stock_controller import get_sl_entries_for_preview
class TestLedgerPreview(UnitTestCase):
def test_in_out_rate_is_only_set_for_outgoing_entries(self):
stock_ledger_entries = [
frappe._dict(actual_qty=5, stock_value_difference=10),
frappe._dict(actual_qty=-5, stock_value_difference=-15),
]
with patch("frappe.get_all", return_value=stock_ledger_entries):
entries = get_sl_entries_for_preview("Delivery Note", "DN-0001", [])
self.assertIsNone(entries[0].get("in_out_rate"))
self.assertEqual(entries[1].in_out_rate, 3)