Skip to content

Commit 6cc7060

Browse files
Sanket322mergify[bot]
Sanket322
authored andcommitted
fix: clear payment schedule in purchase invoice for is_paid
(cherry picked from commit e1fc239)
1 parent 488d808 commit 6cc7060

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js

+2
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
399399
hide_fields(this.frm.doc);
400400
if (cint(this.frm.doc.is_paid)) {
401401
this.frm.set_value("allocate_advances_automatically", 0);
402+
this.frm.set_value("payment_terms_template", "");
403+
this.frm.set_value("payment_schedule", []);
402404
if (!this.frm.doc.company) {
403405
this.frm.set_value("is_paid", 0);
404406
frappe.msgprint(__("Please specify Company to proceed"));

erpnext/controllers/accounts_controller.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,14 @@ def validate_deferred_start_and_end_date(self):
464464
)
465465

466466
def validate_invoice_documents_schedule(self):
467-
if self.is_return:
467+
if (
468+
self.is_return
469+
or (self.doctype == "Purchase Invoice" and self.is_paid)
470+
or (self.doctype == "Sales Invoice" and self.is_pos)
471+
or self.get("is_opening") == "Yes"
472+
):
468473
self.payment_terms_template = ""
469474
self.payment_schedule = []
470-
return
471475

472476
self.validate_payment_schedule_dates()
473477
self.set_due_date()
@@ -2342,9 +2346,6 @@ def validate_payment_schedule_dates(self):
23422346
dates = []
23432347
li = []
23442348

2345-
if self.doctype == "Sales Invoice" and self.is_pos:
2346-
return
2347-
23482349
for d in self.get("payment_schedule"):
23492350
if self.doctype == "Sales Order" and getdate(d.due_date) < getdate(self.transaction_date):
23502351
frappe.throw(
@@ -2361,9 +2362,6 @@ def validate_payment_schedule_dates(self):
23612362
frappe.throw(_("Rows with duplicate due dates in other rows were found: {0}").format(duplicates))
23622363

23632364
def validate_payment_schedule_amount(self):
2364-
if (self.doctype == "Sales Invoice" and self.is_pos) or self.get("is_opening") == "Yes":
2365-
return
2366-
23672365
party_account_currency = self.get("party_account_currency")
23682366
if not party_account_currency:
23692367
party_type, party = self.get_party()

0 commit comments

Comments
 (0)