From 9a5604c5bb4f2c8d99fa59bdfb9bc16565aa6ffa Mon Sep 17 00:00:00 2001 From: ljain112 Date: Tue, 15 Oct 2024 18:38:42 +0530 Subject: [PATCH 1/4] fix: do not check for payment terms details for return invoices. (cherry picked from commit 6703b7d1aea159d02c4eae6f45e486b27138e29c) --- .../accounts/report/accounts_receivable/accounts_receivable.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 8d4a8579ae3..984d77dbad2 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -522,7 +522,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, From a826a894f4d9ef2be1c59c4e97f0ceb475b569b4 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Fri, 25 Oct 2024 18:09:01 +0530 Subject: [PATCH 2/4] fix: do not set payment terms for return invoices (cherry picked from commit 8b700eadc746698c02573f5af209a962d32be5d6) --- .../accounts/doctype/purchase_invoice/purchase_invoice.js | 4 +++- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 3 +++ erpnext/controllers/accounts_controller.py | 7 ++++++- erpnext/public/js/controllers/transaction.js | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 2bb02f2e041..be429689b5a 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -342,7 +342,9 @@ 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), + 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/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 87b71cd793f..5e248c8b235 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -339,6 +339,9 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends ( account: this.frm.doc.debit_to, price_list: this.frm.doc.selling_price_list, 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/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 188cbf0587c..e6fb5d0d153 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -451,6 +451,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() @@ -465,7 +470,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 92e9e559ada..f9b78a3b8bc 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -2438,7 +2438,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", From 29aa5d64683d8af8864996c4f09214c17b58905d Mon Sep 17 00:00:00 2001 From: ljain112 Date: Fri, 25 Oct 2024 18:14:07 +0530 Subject: [PATCH 3/4] fix: hide payment terms for return and paid purchase invoices (cherry picked from commit 912e1e3f3d3a3e3d8b15fee9dfa1dda7c1922e37) # Conflicts: # erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json --- .../accounts/doctype/purchase_invoice/purchase_invoice.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index c2ee4166ed1..b6205af0fdf 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -1134,12 +1134,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", @@ -1631,7 +1633,11 @@ "idx": 204, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2024-09-11 12:59:19.130593", +======= + "modified": "2024-10-25 18:13:01.944477", +>>>>>>> 912e1e3f3d (fix: hide payment terms for return and paid purchase invoices) "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", From 303ae8321b271aef96f5de61d7bc0ff8b3ee6d80 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 28 Oct 2024 13:33:24 +0530 Subject: [PATCH 4/4] chore: resolve conflict --- .../accounts/doctype/purchase_invoice/purchase_invoice.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index b6205af0fdf..6b21ec5b678 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -1633,11 +1633,7 @@ "idx": 204, "is_submittable": 1, "links": [], -<<<<<<< HEAD - "modified": "2024-09-11 12:59:19.130593", -======= "modified": "2024-10-25 18:13:01.944477", ->>>>>>> 912e1e3f3d (fix: hide payment terms for return and paid purchase invoices) "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice",