diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index adf49c42d41..f60ba5d1329 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -403,6 +403,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. hide_fields(this.frm.doc); if (cint(this.frm.doc.is_paid)) { this.frm.set_value("allocate_advances_automatically", 0); + this.frm.set_value("payment_terms_template", ""); + this.frm.set_value("payment_schedule", []); if (!this.frm.doc.company) { this.frm.set_value("is_paid", 0); frappe.msgprint(__("Please specify Company to proceed")); diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index db49882c8b3..d788f94a923 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -468,10 +468,14 @@ class AccountsController(TransactionBase): ) def validate_invoice_documents_schedule(self): - if self.is_return: + if ( + self.is_return + or (self.doctype == "Purchase Invoice" and self.is_paid) + or (self.doctype == "Sales Invoice" and self.is_pos) + or self.get("is_opening") == "Yes" + ): self.payment_terms_template = "" self.payment_schedule = [] - return self.validate_payment_schedule_dates() self.set_due_date() @@ -2370,9 +2374,6 @@ class AccountsController(TransactionBase): dates = [] li = [] - if self.doctype == "Sales Invoice" and self.is_pos: - return - for d in self.get("payment_schedule"): d.validate_from_to_dates("discount_date", "due_date") if self.doctype == "Sales Order" and getdate(d.due_date) < getdate(self.transaction_date): @@ -2390,9 +2391,6 @@ class AccountsController(TransactionBase): frappe.throw(_("Rows with duplicate due dates in other rows were found: {0}").format(duplicates)) def validate_payment_schedule_amount(self): - if (self.doctype == "Sales Invoice" and self.is_pos) or self.get("is_opening") == "Yes": - return - party_account_currency = self.get("party_account_currency") if not party_account_currency: party_type, party = self.get_party()