mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-29 22:58:25 +00:00
test: add coverage for Incorrect Balance Qty After Transaction report
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
# Copyright (c) 2026, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
from erpnext.stock.doctype.item.test_item import make_item
|
||||||
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
|
from erpnext.stock.report.incorrect_balance_qty_after_transaction.incorrect_balance_qty_after_transaction import (
|
||||||
|
execute,
|
||||||
|
)
|
||||||
|
from erpnext.tests.utils import ERPNextTestSuite
|
||||||
|
|
||||||
|
WAREHOUSE = "_Test Warehouse - _TC"
|
||||||
|
COMPANY = "_Test Company"
|
||||||
|
|
||||||
|
|
||||||
|
class TestIncorrectBalanceQtyAfterTransaction(ERPNextTestSuite):
|
||||||
|
def run_report(self, **extra):
|
||||||
|
filters = frappe._dict({"company": COMPANY, "warehouse": WAREHOUSE})
|
||||||
|
filters.update(extra)
|
||||||
|
return execute(filters)[1]
|
||||||
|
|
||||||
|
def test_healthy_stock_not_flagged(self):
|
||||||
|
item = make_item(properties={"is_stock_item": 1}).name
|
||||||
|
make_stock_entry(item_code=item, to_warehouse=WAREHOUSE, qty=10, rate=100, posting_date="2026-06-01")
|
||||||
|
make_stock_entry(item_code=item, from_warehouse=WAREHOUSE, qty=4, rate=100, posting_date="2026-06-02")
|
||||||
|
|
||||||
|
data = self.run_report(item_code=item)
|
||||||
|
flagged = [row for row in data if row.get("item_code") == item]
|
||||||
|
self.assertEqual(flagged, [])
|
||||||
|
|
||||||
|
def test_sequence_of_movements_not_flagged(self):
|
||||||
|
item = make_item(properties={"is_stock_item": 1}).name
|
||||||
|
make_stock_entry(item_code=item, to_warehouse=WAREHOUSE, qty=20, rate=50, posting_date="2026-06-01")
|
||||||
|
make_stock_entry(item_code=item, from_warehouse=WAREHOUSE, qty=5, rate=50, posting_date="2026-06-02")
|
||||||
|
make_stock_entry(item_code=item, to_warehouse=WAREHOUSE, qty=8, rate=50, posting_date="2026-06-03")
|
||||||
|
make_stock_entry(item_code=item, from_warehouse=WAREHOUSE, qty=3, rate=50, posting_date="2026-06-04")
|
||||||
|
|
||||||
|
data = self.run_report(item_code=item)
|
||||||
|
flagged = [row for row in data if row.get("item_code") == item]
|
||||||
|
self.assertEqual(flagged, [])
|
||||||
Reference in New Issue
Block a user