Merge pull request #16094 from rohitwaghchaure/validate_due_date_for_purchase_invoice
[Fix] Due Date cannot be before Posting Date should consider supplier invoice date for purchase invoice
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index f19aaf8..8c7f3d8 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -335,7 +335,7 @@
def validate_due_date(posting_date, due_date, party_type, party, company=None, bill_date=None, template_name=None):
if getdate(due_date) < getdate(posting_date):
- frappe.throw(_("Due Date cannot be before Posting Date"))
+ frappe.throw(_("Due Date cannot be before Posting / Supplier Invoice Date"))
else:
if not template_name: return
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 51747f6..18a769d 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -179,7 +179,7 @@
validate_due_date(self.posting_date, self.due_date,
"Customer", self.customer, self.company, self.payment_terms_template)
elif self.doctype == "Purchase Invoice":
- validate_due_date(self.posting_date, self.due_date,
+ validate_due_date(self.bill_date or self.posting_date, self.due_date,
"Supplier", self.supplier, self.company, self.bill_date, self.payment_terms_template)
def set_price_list_currency(self, buying_or_selling):