From 6c443bd85aba5cc8e911219da4924ab63223d2ed Mon Sep 17 00:00:00 2001 From: ljain112 Date: Tue, 18 Mar 2025 14:16:35 +0530 Subject: [PATCH] fix: customer credit limit check based on `bypass_credit_limit_check` in Journal Entry (cherry picked from commit 8a84faebedaaddc4ff6b1210a15420ede0c2c51b) --- .../doctype/journal_entry/journal_entry.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 9e1eaf25442..e8ac493d659 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -576,8 +576,22 @@ class JournalEntry(AccountsController): if customers: from erpnext.selling.doctype.customer.customer import check_credit_limit + customer_details = frappe._dict( + frappe.db.get_all( + "Customer Credit Limit", + filters={ + "parent": ["in", customers], + "parenttype": ["=", "Customer"], + "company": ["=", self.company], + }, + fields=["parent", "bypass_credit_limit_check"], + as_list=True, + ) + ) + for customer in customers: - check_credit_limit(customer, self.company) + ignore_outstanding_sales_order = bool(customer_details.get(customer)) + check_credit_limit(customer, self.company, ignore_outstanding_sales_order) def validate_cheque_info(self): if self.voucher_type in ["Bank Entry"]: