Compare commits

...

2 Commits

Author SHA1 Message Date
Nabin Hait
286ac77a05 test: reuse BootStrapTestData master data to reduce runtime
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 13:27:35 +05:30
Nabin Hait
ddb07bcc0a test: add coverage for Negative Batch Report report
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 10:19:52 +05:30

View File

@@ -0,0 +1,54 @@
# Copyright (c) 2026, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
import frappe
from erpnext.tests.utils import ERPNextTestSuite
class TestNegativeBatchReport(ERPNextTestSuite):
def run_report(self, item_code):
from erpnext.stock.report.negative_batch_report.negative_batch_report import execute
return execute(
frappe._dict(
{
"company": "_Test Company",
"warehouse": "Stores - _TC",
"item_code": item_code,
}
)
)[1]
def test_healthy_batch_not_negative(self):
from erpnext.stock.doctype.item.test_item import make_item
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
item = make_item(
properties={
"is_stock_item": 1,
"has_batch_no": 1,
"create_new_batch": 1,
"batch_number_series": "NBR-.#####",
}
).name
make_stock_entry(
item_code=item,
to_warehouse="Stores - _TC",
qty=10,
rate=100,
posting_date="2026-06-01",
)
make_stock_entry(
item_code=item,
from_warehouse="Stores - _TC",
qty=4,
posting_date="2026-06-02",
)
data = self.run_report(item)
# The batch was only received (10) before being issued (4), so its running
# balance never goes negative; the report must not list this item's batch.
self.assertFalse([row for row in data if row.get("item_code") == item])