Skip to content

Commit

Permalink
fix: auto-update due date for invoices via data import
Browse files Browse the repository at this point in the history
(cherry picked from commit c096133)
  • Loading branch information
GursheenK authored and mergify[bot] committed Mar 15, 2024
1 parent 3fe4540 commit 9cdde50
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,23 +603,32 @@ def disable_tax_included_prices_for_internal_transfer(self):
)

def validate_due_date(self):
if self.get("is_pos"):
if self.get("is_pos") or self.doctype not in ["Sales Invoice", "Purchase Invoice"]:
return

from erpnext.accounts.party import validate_due_date

if self.doctype == "Sales Invoice":
posting_date = (
self.posting_date if self.doctype == "Sales Invoice" else (self.bill_date or self.posting_date)
)
via_data_import = (
self.flags.updater_reference and self.flags.updater_reference.get("doctype") == "Data Import"
)
if via_data_import and getdate(self.due_date) < getdate(posting_date):
self.due_date = posting_date

elif self.doctype == "Sales Invoice":
if not self.due_date:
frappe.throw(_("Due Date is mandatory"))

validate_due_date(
self.posting_date,
posting_date,
self.due_date,
self.payment_terms_template,
)
elif self.doctype == "Purchase Invoice":
validate_due_date(
self.bill_date or self.posting_date,
posting_date,
self.due_date,
self.bill_date,
self.payment_terms_template,
Expand Down

0 comments on commit 9cdde50

Please sign in to comment.