From f73e99e9d21112d1cf36dc3ee4337696dd0c89ac Mon Sep 17 00:00:00 2001 From: Abdeali Chharchhoda Date: Mon, 5 May 2025 18:25:56 +0530 Subject: [PATCH 1/2] fix: show party type in due date exceeding message (cherry picked from commit b6d9134014aaa35def4322b73dad749360b5e7d7) # Conflicts: # erpnext/accounts/party.py --- erpnext/accounts/party.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index de13f51e216..126e6bdfcab 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -661,6 +661,7 @@ def validate_due_date(posting_date, due_date, bill_date=None, template_name=None if getdate(due_date) < getdate(posting_date): frappe.throw(_("Due Date cannot be before Posting / Supplier Invoice Date")) else: +<<<<<<< HEAD if not template_name: return @@ -674,6 +675,28 @@ def validate_due_date(posting_date, due_date, bill_date=None, template_name=None 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() +======= + 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, doctype=None): + if not template_name: + return + + default_due_date = format(get_due_date_from_template(template_name, posting_date, bill_date)) + + if not default_due_date: + return + + if default_due_date != posting_date and getdate(due_date) > getdate(default_due_date): + 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 {0} credit days by {1} day(s)").format( + party_type, date_diff(due_date, default_due_date) + ) +>>>>>>> b6d9134014 (fix: show party type in due date exceeding message) ) if is_credit_controller: msgprint( From 40faa7f7b9214a1f04733b0a10c249afa4f1824e Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 6 May 2025 14:08:22 +0530 Subject: [PATCH 2/2] chore: resolve conflicts and pass all parameters --- erpnext/accounts/party.py | 31 +++------------------- erpnext/controllers/accounts_controller.py | 11 ++------ 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 126e6bdfcab..419baaa3d47 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -657,25 +657,10 @@ def get_due_date_from_template(template_name, posting_date, bill_date): return due_date -def validate_due_date(posting_date, due_date, bill_date=None, template_name=None): +def validate_due_date(posting_date, due_date, bill_date=None, template_name=None, doctype=None): if getdate(due_date) < getdate(posting_date): frappe.throw(_("Due Date cannot be before Posting / Supplier Invoice Date")) else: -<<<<<<< HEAD - if not template_name: - return - - default_due_date = get_due_date_from_template(template_name, posting_date, bill_date).strftime( - "%Y-%m-%d" - ) - - if not default_due_date: - 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() -======= validate_due_date_with_template(posting_date, due_date, bill_date, template_name, doctype) @@ -696,18 +681,10 @@ def validate_due_date_with_template(posting_date, due_date, bill_date, template_ _("Note: Due Date exceeds allowed {0} credit days by {1} day(s)").format( party_type, date_diff(due_date, default_due_date) ) ->>>>>>> b6d9134014 (fix: show party type in due date exceeding message) ) - if is_credit_controller: - msgprint( - _("Note: Due / Reference Date exceeds allowed customer credit days by {0} day(s)").format( - date_diff(due_date, default_due_date) - ) - ) - else: - frappe.throw( - _("Due / Reference Date cannot be after {0}").format(formatdate(default_due_date)) - ) + + else: + frappe.throw(_("Due / Reference Date cannot be after {0}").format(formatdate(default_due_date))) @frappe.whitelist() diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index f576bc91541..247fd5d009b 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -779,17 +779,10 @@ class AccountsController(TransactionBase): if not self.due_date: frappe.throw(_("Due Date is mandatory")) - validate_due_date( - posting_date, - self.due_date, - self.payment_terms_template, - ) + validate_due_date(posting_date, self.due_date, None, self.payment_terms_template, self.doctype) elif self.doctype == "Purchase Invoice": validate_due_date( - posting_date, - self.due_date, - self.bill_date, - self.payment_terms_template, + posting_date, self.due_date, self.bill_date, self.payment_terms_template, self.doctype ) def set_price_list_currency(self, buying_or_selling):