diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 503eb751c41..dc879cfc1b4 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -310,8 +310,11 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. party_type: "Supplier", account: this.frm.doc.credit_to, price_list: this.frm.doc.buying_price_list, - fetch_payment_terms_template: cint(!this.frm.doc.ignore_default_payment_terms_template) - }, function() { + fetch_payment_terms_template: cint( + (this.frm.doc.is_return == 0) & !this.frm.doc.ignore_default_payment_terms_template + ), + }, + function () { me.apply_pricing_rule(); me.frm.doc.apply_tds = me.frm.supplier_tds ? 1 : 0; me.frm.doc.tax_withholding_category = me.frm.supplier_tds; diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index 3af2617da75..82c4a224eb4 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -1128,12 +1128,14 @@ "label": "Payment Terms" }, { + "depends_on": "eval:(!doc.is_paid && !doc.is_return)", "fieldname": "payment_terms_template", "fieldtype": "Link", "label": "Payment Terms Template", "options": "Payment Terms Template" }, { + "depends_on": "eval:(!doc.is_paid && !doc.is_return)", "fieldname": "payment_schedule", "fieldtype": "Table", "label": "Payment Schedule", @@ -1611,7 +1613,7 @@ "idx": 204, "is_submittable": 1, "links": [], - "modified": "2024-09-11 12:59:19.130593", + "modified": "2024-10-25 18:13:01.944477", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index bc458ffa272..dffd5d98c4f 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -280,8 +280,12 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e party_type: "Customer", account: this.frm.doc.debit_to, price_list: this.frm.doc.selling_price_list, - pos_profile: pos_profile - }, function() { + pos_profile: pos_profile, + fetch_payment_terms_template: cint( + (this.frm.doc.is_return == 0) & !this.frm.doc.ignore_default_payment_terms_template + ), + }, + function () { me.apply_pricing_rule(); }); diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 5ef39755ca5..b2a24338cbf 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -500,7 +500,8 @@ class ReceivablePayableReport: from `tab{row.voucher_type}` si, `tabPayment Schedule` ps where si.name = ps.parent and - si.name = %s + si.name = %s and + si.is_return = 0 order by ps.paid_amount desc, due_date """, row.voucher_no, diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index ebd6594a2a8..e7d8bc9ddd4 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -415,6 +415,11 @@ class AccountsController(TransactionBase): ) def validate_invoice_documents_schedule(self): + if self.is_return: + self.payment_terms_template = "" + self.payment_schedule = [] + return + self.validate_payment_schedule_dates() self.set_due_date() self.set_payment_schedule() @@ -429,7 +434,7 @@ class AccountsController(TransactionBase): self.validate_payment_schedule_amount() def validate_all_documents_schedule(self): - if self.doctype in ("Sales Invoice", "Purchase Invoice") and not self.is_return: + if self.doctype in ("Sales Invoice", "Purchase Invoice"): self.validate_invoice_documents_schedule() elif self.doctype in ("Quotation", "Purchase Order", "Sales Order"): self.validate_non_invoice_documents_schedule() diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index f774528ee86..79e14b9eb5b 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2213,7 +2213,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe payment_terms_template() { var me = this; const doc = this.frm.doc; - if(doc.payment_terms_template && doc.doctype !== 'Delivery Note') { + if(doc.payment_terms_template && doc.doctype !== 'Delivery Note' && doc.is_return == 0) { var posting_date = doc.posting_date || doc.transaction_date; frappe.call({ method: "erpnext.controllers.accounts_controller.get_payment_terms",