Skip to content

Commit

Permalink
fix: clear payment schedule in purchase invoice for is_paid
Browse files Browse the repository at this point in the history
(cherry picked from commit e1fc239)
  • Loading branch information
Sanket322 authored and mergify[bot] committed Dec 27, 2024
1 parent 488d808 commit 6cc7060
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,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"));
Expand Down
14 changes: 6 additions & 8 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,14 @@ def validate_deferred_start_and_end_date(self):
)

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()
Expand Down Expand Up @@ -2342,9 +2346,6 @@ def validate_payment_schedule_dates(self):
dates = []
li = []

if self.doctype == "Sales Invoice" and self.is_pos:
return

for d in self.get("payment_schedule"):
if self.doctype == "Sales Order" and getdate(d.due_date) < getdate(self.transaction_date):
frappe.throw(
Expand All @@ -2361,9 +2362,6 @@ def validate_payment_schedule_dates(self):
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()
Expand Down

0 comments on commit 6cc7060

Please sign in to comment.