diff --git a/erpnext/accounts/report/billed_items_to_be_received/billed_items_to_be_received.py b/erpnext/accounts/report/billed_items_to_be_received/billed_items_to_be_received.py index dc6192e7544..0ec4652146e 100644 --- a/erpnext/accounts/report/billed_items_to_be_received/billed_items_to_be_received.py +++ b/erpnext/accounts/report/billed_items_to_be_received/billed_items_to_be_received.py @@ -31,7 +31,7 @@ def get_report_filters(report_filters): ] if report_filters.get("purchase_invoice"): - filters.append(["Purchase Invoice", "per_received", "in", [report_filters.get("purchase_invoice")]]) + filters.append(["Purchase Invoice", "name", "=", report_filters.get("purchase_invoice")]) return filters diff --git a/erpnext/accounts/report/billed_items_to_be_received/test_billed_items_to_be_received.py b/erpnext/accounts/report/billed_items_to_be_received/test_billed_items_to_be_received.py index 1112a9f7403..aed83005a1a 100644 --- a/erpnext/accounts/report/billed_items_to_be_received/test_billed_items_to_be_received.py +++ b/erpnext/accounts/report/billed_items_to_be_received/test_billed_items_to_be_received.py @@ -87,3 +87,16 @@ class TestBilledItemsToBeReceived(ERPNextTestSuite): rows = self.get_rows_for(self.run_report(posting_date="2000-01-01"), pi.name) self.assertEqual(len(rows), 0) + + def test_purchase_invoice_filter_scopes_to_that_invoice(self): + """The optional purchase_invoice filter must narrow to that invoice only.""" + pi = make_purchase_invoice( + supplier="_Test Supplier", item_code="_Test Item", qty=5, rate=200, update_stock=0 + ) + other = make_purchase_invoice( + supplier="_Test Supplier", item_code="_Test Item", qty=3, rate=200, update_stock=0 + ) + + names = {row.get("name") for row in self.run_report(purchase_invoice=pi.name)} + self.assertEqual(names, {pi.name}) + self.assertNotIn(other.name, names)