From b6d9134014aaa35def4322b73dad749360b5e7d7 Mon Sep 17 00:00:00 2001 From: Abdeali Chharchhoda Date: Mon, 5 May 2025 18:25:56 +0530 Subject: [PATCH] fix: show party type in due date exceeding message --- erpnext/accounts/party.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 57c56c9b2c4..b8b8f301de5 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -670,10 +670,10 @@ def validate_due_date(posting_date, due_date, bill_date=None, template_name=None frappe.throw(_("Due Date cannot be before {0}").format(doctype_date)) else: - validate_due_date_with_template(posting_date, due_date, bill_date, template_name) + validate_due_date_with_template(posting_date, due_date, bill_date, template_name, doctype) -def validate_due_date_with_template(posting_date, due_date, bill_date, template_name): +def validate_due_date_with_template(posting_date, due_date, bill_date, template_name, doctype=None): if not template_name: return @@ -683,13 +683,12 @@ def validate_due_date_with_template(posting_date, due_date, bill_date, template_ return if default_due_date != posting_date and getdate(due_date) > getdate(default_due_date): - is_credit_controller = ( - frappe.db.get_single_value("Accounts Settings", "credit_controller") in frappe.get_roles() - ) - if is_credit_controller: + if frappe.db.get_single_value("Accounts Settings", "credit_controller") in frappe.get_roles(): + party_type = "supplier" if doctype == "Purchase Invoice" else "customer" + msgprint( - _("Note: Due Date exceeds allowed customer credit days by {0} day(s)").format( - date_diff(due_date, default_due_date) + _("Note: Due Date exceeds allowed {0} credit days by {1} day(s)").format( + party_type, date_diff(due_date, default_due_date) ) ) else: