Compare commits

...

2 Commits

Author SHA1 Message Date
Nabin Hait
7da4bc46bf test: reuse BootStrapTestData master data to reduce runtime
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 13:26:54 +05:30
Nabin Hait
06592a49c8 test: add coverage for Incorrect Serial No Valuation report
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:19:45 +05:30

View File

@@ -0,0 +1,55 @@
# Copyright (c) 2026, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
import frappe
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from erpnext.stock.report.incorrect_serial_no_valuation.incorrect_serial_no_valuation import execute
from erpnext.tests.utils import ERPNextTestSuite
SERIAL_ITEM = "_Test Serialized Item With Series"
WAREHOUSE = "Stores - _TC"
class TestIncorrectSerialNoValuation(ERPNextTestSuite):
def run_report(self, **extra):
filters = frappe._dict({"company": "_Test Company"})
filters.update(extra)
return execute(filters)[1]
def test_healthy_serial_item_not_flagged(self):
make_stock_entry(
item_code=SERIAL_ITEM,
to_warehouse=WAREHOUSE,
qty=3,
rate=100,
posting_date="2026-06-01",
)
make_stock_entry(
item_code=SERIAL_ITEM,
from_warehouse=WAREHOUSE,
qty=1,
posting_date="2026-06-02",
)
data = self.run_report(item_code=SERIAL_ITEM)
flagged_items = {row.get("item_code") for row in data if isinstance(row, dict)}
self.assertNotIn(SERIAL_ITEM, flagged_items)
def test_only_balance_row_when_filtered_to_healthy_item(self):
make_stock_entry(
item_code=SERIAL_ITEM,
to_warehouse=WAREHOUSE,
qty=3,
rate=100,
posting_date="2026-06-01",
)
data = self.run_report(item_code=SERIAL_ITEM)
# The report always appends a single "Balance" summary row. A healthy
# serial item contributes no detail rows, so only that summary remains.
self.assertEqual(len(data), 1)
self.assertEqual(data[-1].get("qty"), 0)
self.assertEqual(data[-1].get("valuation_rate"), 0)