From b7d76d8fad5e92a60a5e5f3f819f8d5ef314f63e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 Oct 2025 11:27:55 +0530 Subject: [PATCH] fix: Set paid amount automatically only if return entry validated and has negative grand total (#49829) (cherry picked from commit dcbcc596f2004643acde442128137e0ac778a4fe) # Conflicts: # erpnext/public/js/controllers/taxes_and_totals.js --- erpnext/controllers/accounts_controller.py | 10 +++++----- erpnext/public/js/controllers/taxes_and_totals.js | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 21567a60abe..756fa5f6d09 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -213,6 +213,11 @@ class AccountsController(TransactionBase): self.validate_date_with_fiscal_year() self.validate_party_accounts() + if self.doctype in ["Sales Invoice", "Purchase Invoice"]: + if self.is_return: + self.validate_qty() + else: + self.validate_deferred_start_and_end_date() self.validate_inter_company_reference() @@ -258,11 +263,6 @@ class AccountsController(TransactionBase): self.set_advance_gain_or_loss() - if self.is_return: - self.validate_qty() - else: - self.validate_deferred_start_and_end_date() - self.validate_deferred_income_expense_account() self.set_inter_company_account() diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index dca9f353457..8e39046c923 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -76,9 +76,16 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { // Update paid amount on return/debit note creation if ( +<<<<<<< HEAD this.frm.doc.doctype === "Purchase Invoice" && this.frm.doc.is_return && (this.frm.doc.grand_total > this.frm.doc.paid_amount) +======= + this.frm.doc.doctype === "Purchase Invoice" && + this.frm.doc.is_return && + this.frm.doc.grand_total < 0 && + this.frm.doc.grand_total > this.frm.doc.paid_amount +>>>>>>> dcbcc596f2 (fix: Set paid amount automatically only if return entry validated and has negative grand total (#49829)) ) { this.frm.doc.paid_amount = flt(this.frm.doc.grand_total, precision("grand_total")); }