mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-16 07:58:38 +00:00
test: flag an SLE whose balance is out of sync with the FIFO queue
This commit is contained in:
@@ -28,6 +28,29 @@ class TestFifoQueueVsQtyAfterTransactionComparison(ERPNextTestSuite):
|
||||
item_codes = [row.get("item_code") for row in data if row]
|
||||
self.assertNotIn(item, item_codes)
|
||||
|
||||
def test_queue_out_of_sync_is_flagged(self):
|
||||
item = "_Test Item 2"
|
||||
warehouse = "Stores - _TC"
|
||||
frappe.db.set_value("Item", item, "valuation_method", "FIFO")
|
||||
|
||||
entry = make_stock_entry(
|
||||
item_code=item, to_warehouse=warehouse, qty=10, rate=100, posting_date="2026-06-01"
|
||||
)
|
||||
sle = frappe.db.get_value(
|
||||
"Stock Ledger Entry",
|
||||
{"voucher_no": entry.name, "item_code": item, "warehouse": warehouse},
|
||||
"name",
|
||||
)
|
||||
|
||||
# corrupt the running balance so it no longer matches the FIFO queue (the queue holds 10,
|
||||
# but the stored qty_after_transaction now claims 7)
|
||||
frappe.db.set_value("Stock Ledger Entry", sle, "qty_after_transaction", 7, update_modified=False)
|
||||
|
||||
data = self.run_report({"company": "_Test Company", "item_code": item, "warehouse": warehouse})
|
||||
|
||||
flagged = {row.get("name") for row in data if row}
|
||||
self.assertIn(sle, flagged)
|
||||
|
||||
def test_requires_a_filter(self):
|
||||
with self.assertRaises(frappe.ValidationError):
|
||||
self.run_report({"company": "_Test Company"})
|
||||
|
||||
Reference in New Issue
Block a user