From cbafa16fbc7b1331ef1424664d03de25ebc03006 Mon Sep 17 00:00:00 2001 From: diptanilsaha Date: Thu, 6 Aug 2026 11:56:58 +0530 Subject: [PATCH] fix(journal_entry): validate blocked purchase invoices --- .../journal_entry/services/reference_validator.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/erpnext/accounts/doctype/journal_entry/services/reference_validator.py b/erpnext/accounts/doctype/journal_entry/services/reference_validator.py index 1d75b171d08..802ce4d8b2f 100644 --- a/erpnext/accounts/doctype/journal_entry/services/reference_validator.py +++ b/erpnext/accounts/doctype/journal_entry/services/reference_validator.py @@ -184,6 +184,7 @@ class JournalEntryReferenceValidator: continue invoice = frappe.get_doc(reference_type, reference_name) self._validate_invoice_outstanding(invoice, total, reference_type, reference_name) + self._validate_block_invoice(invoice) def _validate_invoice_outstanding(self, invoice, total, reference_type, reference_name) -> None: """Payment booked against an invoice cannot exceed its outstanding amount.""" @@ -197,3 +198,15 @@ class JournalEntryReferenceValidator: reference_type, reference_name, invoice.outstanding_amount ) ) + + def _validate_block_invoice(self, invoice): + """Payment cannnot be booked against blocked Purchase Invoices""" + if invoice.doctype != "Purchase Invoice": + return + + if invoice.invoice_is_blocked(): + frappe.throw( + _("{0} {1} is blocked and on hold until {2}.").format( + invoice.doctype, invoice.name, invoice.release_date + ) + )