test: debit note account mismatch
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 992fbe6..5da6f8b 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -1995,6 +1995,21 @@
self.assertEqual(pi.items[0].cost_center, "_Test Cost Center Buying - _TC")
+ def test_debit_note_with_account_mismatch(self):
+ new_creditors = create_account(
+ parent_account="Accounts Payable - _TC",
+ account_name="Creditors 2",
+ company="_Test Company",
+ account_type="Payable",
+ )
+ pi = make_purchase_invoice(qty=1, rate=1000)
+ dr_note = make_purchase_invoice(
+ qty=-1, rate=1000, is_return=1, return_against=pi.name, do_not_save=True
+ )
+ dr_note.credit_to = new_creditors
+
+ self.assertRaises(frappe.ValidationError, dr_note.save)
+
def test_debit_note_without_item(self):
pi = make_purchase_invoice(item_name="_Test Item", qty=10, do_not_submit=True)
pi.items[0].item_code = ""