From 98362d9183af56f4aa2182ff0e68da57733975b5 Mon Sep 17 00:00:00 2001 From: NIYAZ RAZAK <76736615+niyazrazak@users.noreply.github.com> Date: Sat, 24 Aug 2024 12:56:33 +0300 Subject: [PATCH 01/13] fix: incorrect amount in bank clearance (cherry picked from commit 9a11df59fc3b415d4b15a71d10df4656a0b339d8) --- erpnext/accounts/doctype/bank_clearance/bank_clearance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py index b361a1ebb82..153c9990665 100644 --- a/erpnext/accounts/doctype/bank_clearance/bank_clearance.py +++ b/erpnext/accounts/doctype/bank_clearance/bank_clearance.py @@ -55,7 +55,7 @@ class BankClearance(Document): "Payment Entry" as payment_document, name as payment_entry, reference_no as cheque_number, reference_date as cheque_date, if(paid_from=%(account)s, paid_amount + total_taxes_and_charges, 0) as credit, - if(paid_from=%(account)s, 0, received_amount) as debit, + if(paid_from=%(account)s, 0, received_amount + total_taxes_and_charges) as debit, posting_date, ifnull(party,if(paid_from=%(account)s,paid_to,paid_from)) as against_account, clearance_date, if(paid_to=%(account)s, paid_to_account_currency, paid_from_account_currency) as account_currency from `tabPayment Entry` From 083382399faf7eb3b95c4db29d884a92c65f1eed Mon Sep 17 00:00:00 2001 From: ljain112 Date: Fri, 18 Oct 2024 18:02:25 +0530 Subject: [PATCH 02/13] fix: "show_remarks" checkbox in Process statement of accounts (cherry picked from commit f4600df1f718440698aa98d460178f3e1f9ab430) # Conflicts: # erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py --- .../process_statement_of_accounts.json | 9 ++- .../process_statement_of_accounts.py | 59 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json index 8584cbb31cb..27f7853410b 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json @@ -25,6 +25,7 @@ "payment_terms_template", "sales_partner", "sales_person", + "show_remarks", "based_on_payment_terms", "section_break_3", "customer_collection", @@ -388,10 +389,16 @@ "fieldname": "ignore_cr_dr_notes", "fieldtype": "Check", "label": "Ignore System Generated Credit / Debit Notes" + }, + { + "default": "0", + "fieldname": "show_remarks", + "fieldtype": "Check", + "label": "Show Remarks" } ], "links": [], - "modified": "2024-08-13 10:41:18.381165", + "modified": "2024-10-18 17:51:39.108481", "modified_by": "Administrator", "module": "Accounts", "name": "Process Statement Of Accounts", diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py index 078ac034eeb..e5aa204ea1a 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py @@ -22,6 +22,64 @@ from erpnext.accounts.report.general_ledger.general_ledger import execute as get class ProcessStatementOfAccounts(Document): +<<<<<<< HEAD +======= + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + from erpnext.accounts.doctype.process_statement_of_accounts_customer.process_statement_of_accounts_customer import ( + ProcessStatementOfAccountsCustomer, + ) + from erpnext.accounts.doctype.psoa_cost_center.psoa_cost_center import PSOACostCenter + from erpnext.accounts.doctype.psoa_project.psoa_project import PSOAProject + + account: DF.Link | None + ageing_based_on: DF.Literal["Due Date", "Posting Date"] + based_on_payment_terms: DF.Check + body: DF.TextEditor | None + cc_to: DF.Link | None + collection_name: DF.DynamicLink | None + company: DF.Link + cost_center: DF.TableMultiSelect[PSOACostCenter] + currency: DF.Link | None + customer_collection: DF.Literal["", "Customer Group", "Territory", "Sales Partner", "Sales Person"] + customers: DF.Table[ProcessStatementOfAccountsCustomer] + enable_auto_email: DF.Check + filter_duration: DF.Int + finance_book: DF.Link | None + frequency: DF.Literal["Weekly", "Monthly", "Quarterly"] + from_date: DF.Date | None + group_by: DF.Literal["", "Group by Voucher", "Group by Voucher (Consolidated)"] + ignore_cr_dr_notes: DF.Check + ignore_exchange_rate_revaluation_journals: DF.Check + include_ageing: DF.Check + include_break: DF.Check + letter_head: DF.Link | None + orientation: DF.Literal["Landscape", "Portrait"] + payment_terms_template: DF.Link | None + pdf_name: DF.Data | None + posting_date: DF.Date | None + primary_mandatory: DF.Check + project: DF.TableMultiSelect[PSOAProject] + report: DF.Literal["General Ledger", "Accounts Receivable"] + sales_partner: DF.Link | None + sales_person: DF.Link | None + sender: DF.Link | None + show_net_values_in_party_account: DF.Check + show_remarks: DF.Check + start_date: DF.Date | None + subject: DF.Data | None + terms_and_conditions: DF.Link | None + territory: DF.Link | None + to_date: DF.Date | None + # end: auto-generated types + +>>>>>>> f4600df1f7 (fix: "show_remarks" checkbox in Process statement of accounts) def validate(self): if not self.subject: self.subject = "Statement Of Accounts for {{ customer.customer_name }}" @@ -132,6 +190,7 @@ def get_common_filters(doc): "finance_book": doc.finance_book if doc.finance_book else None, "account": [doc.account] if doc.account else None, "cost_center": [cc.cost_center_name for cc in doc.cost_center], + "show_remarks": doc.show_remarks, } ) From 35c257a7aeb5e8080ad7e734a93571215bd4b223 Mon Sep 17 00:00:00 2001 From: venkat102 Date: Fri, 18 Oct 2024 18:00:40 +0530 Subject: [PATCH 03/13] fix: get period estimate till service end date (cherry picked from commit a7ba7e9c28e3946ba771516c8ef3ce397d6b0e2e) --- .../deferred_revenue_and_expense.py | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py b/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py index 8999ef710f0..a9756c4f87e 100644 --- a/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py +++ b/erpnext/accounts/report/deferred_revenue_and_expense/deferred_revenue_and_expense.py @@ -122,21 +122,24 @@ class Deferred_Item: """ simulate future posting by creating dummy gl entries. starts from the last posting date. """ - if self.service_start_date != self.service_end_date: - if add_days(self.last_entry_date, 1) < self.period_list[-1].to_date: - self.estimate_for_period_list = get_period_list( - self.filters.from_fiscal_year, - self.filters.to_fiscal_year, - add_days(self.last_entry_date, 1), - self.period_list[-1].to_date, - "Date Range", - "Monthly", - company=self.filters.company, - ) - for period in self.estimate_for_period_list: - amount = self.calculate_amount(period.from_date, period.to_date) - gle = self.make_dummy_gle(period.key, period.to_date, amount) - self.gle_entries.append(gle) + if ( + self.service_start_date != self.service_end_date + and add_days(self.last_entry_date, 1) < self.service_end_date + ): + self.estimate_for_period_list = get_period_list( + self.filters.from_fiscal_year, + self.filters.to_fiscal_year, + add_days(self.last_entry_date, 1), + self.service_end_date, + "Date Range", + "Monthly", + company=self.filters.company, + ) + + for period in self.estimate_for_period_list: + amount = self.calculate_amount(period.from_date, period.to_date) + gle = self.make_dummy_gle(period.key, period.to_date, amount) + self.gle_entries.append(gle) def calculate_item_revenue_expense_for_period(self): """ From beb53184465067f20acc0719f1478b670f4bca61 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 21 Oct 2024 12:21:51 +0530 Subject: [PATCH 04/13] chore: resolve conflict --- .../process_statement_of_accounts.py | 58 ------------------- 1 file changed, 58 deletions(-) diff --git a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py index e5aa204ea1a..06c037dba84 100644 --- a/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py +++ b/erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.py @@ -22,64 +22,6 @@ from erpnext.accounts.report.general_ledger.general_ledger import execute as get class ProcessStatementOfAccounts(Document): -<<<<<<< HEAD -======= - # begin: auto-generated types - # This code is auto-generated. Do not modify anything in this block. - - from typing import TYPE_CHECKING - - if TYPE_CHECKING: - from frappe.types import DF - - from erpnext.accounts.doctype.process_statement_of_accounts_customer.process_statement_of_accounts_customer import ( - ProcessStatementOfAccountsCustomer, - ) - from erpnext.accounts.doctype.psoa_cost_center.psoa_cost_center import PSOACostCenter - from erpnext.accounts.doctype.psoa_project.psoa_project import PSOAProject - - account: DF.Link | None - ageing_based_on: DF.Literal["Due Date", "Posting Date"] - based_on_payment_terms: DF.Check - body: DF.TextEditor | None - cc_to: DF.Link | None - collection_name: DF.DynamicLink | None - company: DF.Link - cost_center: DF.TableMultiSelect[PSOACostCenter] - currency: DF.Link | None - customer_collection: DF.Literal["", "Customer Group", "Territory", "Sales Partner", "Sales Person"] - customers: DF.Table[ProcessStatementOfAccountsCustomer] - enable_auto_email: DF.Check - filter_duration: DF.Int - finance_book: DF.Link | None - frequency: DF.Literal["Weekly", "Monthly", "Quarterly"] - from_date: DF.Date | None - group_by: DF.Literal["", "Group by Voucher", "Group by Voucher (Consolidated)"] - ignore_cr_dr_notes: DF.Check - ignore_exchange_rate_revaluation_journals: DF.Check - include_ageing: DF.Check - include_break: DF.Check - letter_head: DF.Link | None - orientation: DF.Literal["Landscape", "Portrait"] - payment_terms_template: DF.Link | None - pdf_name: DF.Data | None - posting_date: DF.Date | None - primary_mandatory: DF.Check - project: DF.TableMultiSelect[PSOAProject] - report: DF.Literal["General Ledger", "Accounts Receivable"] - sales_partner: DF.Link | None - sales_person: DF.Link | None - sender: DF.Link | None - show_net_values_in_party_account: DF.Check - show_remarks: DF.Check - start_date: DF.Date | None - subject: DF.Data | None - terms_and_conditions: DF.Link | None - territory: DF.Link | None - to_date: DF.Date | None - # end: auto-generated types - ->>>>>>> f4600df1f7 (fix: "show_remarks" checkbox in Process statement of accounts) def validate(self): if not self.subject: self.subject = "Statement Of Accounts for {{ customer.customer_name }}" From 5333f33c21c8147136422475a49cbc4bde44194b Mon Sep 17 00:00:00 2001 From: ljain112 Date: Fri, 18 Oct 2024 13:28:46 +0530 Subject: [PATCH 05/13] fix: party_balance based on company in payment entry (cherry picked from commit 97c9adf06b04df4a76e71e7cdc6b0331e6c84847) --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index c8f53b25a55..d2abbf8e55c 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -2270,7 +2270,9 @@ def get_party_details(company, party_type, party, date, cost_center=None): account_balance = get_balance_on(party_account, date, cost_center=cost_center) _party_name = "title" if party_type == "Shareholder" else party_type.lower() + "_name" party_name = frappe.db.get_value(party_type, party, _party_name) - party_balance = get_balance_on(party_type=party_type, party=party, cost_center=cost_center) + party_balance = get_balance_on( + party_type=party_type, party=party, company=company, cost_center=cost_center + ) if party_type in ["Customer", "Supplier"]: bank_account = get_party_bank_account(party_type, party) From 725b6beff3a6c34e979a53b9527c82aa84d65cb5 Mon Sep 17 00:00:00 2001 From: HarryPaulo Date: Wed, 24 Jul 2024 08:57:27 -0300 Subject: [PATCH 06/13] fix: Freeze Screen on load invoices on POS Closing Entry (cherry picked from commit 486d396174216c83c00f0218dda94aff803b8693) --- erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js index 715800a7c16..e6088b0529e 100644 --- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js +++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js @@ -80,8 +80,10 @@ frappe.ui.form.on("POS Closing Entry", { ) { reset_values(frm); frappe.run_serially([ + () => frappe.dom.freeze(__("Loading Invoices! Please Wait...")), () => frm.trigger("set_opening_amounts"), () => frm.trigger("get_pos_invoices"), + () => frappe.dom.unfreeze(), ]); } }, From c18beaea6b9cbb79ac24bfd6182999337bc7e441 Mon Sep 17 00:00:00 2001 From: "bhaveshkumar.j" Date: Mon, 21 Oct 2024 18:22:30 +0000 Subject: [PATCH 07/13] fix: coupon code validation logic (cherry picked from commit d04257a32dd705868cc662399dcc893003a5b59c) # Conflicts: # erpnext/accounts/doctype/pricing_rule/utils.py --- erpnext/accounts/doctype/pricing_rule/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 0032e539e44..0b0a3235b3a 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -715,6 +715,7 @@ def get_pricing_rule_items(pr_doc, other_items=False) -> list: def validate_coupon_code(coupon_name): coupon = frappe.get_doc("Coupon Code", coupon_name) +<<<<<<< HEAD if coupon.valid_from: if coupon.valid_from > getdate(today()): @@ -723,9 +724,17 @@ def validate_coupon_code(coupon_name): if coupon.valid_upto < getdate(today()): frappe.throw(_("Sorry, this coupon code's validity has expired")) elif coupon.used >= coupon.maximum_use: +======= + if coupon.valid_from and coupon.valid_from > getdate(today()): + frappe.throw(_("Sorry, this coupon code's validity has not started")) + elif coupon.valid_upto and coupon.valid_upto < getdate(today()): + frappe.throw(_("Sorry, this coupon code's validity has expired")) + elif coupon.maximum_use and coupon.used >= coupon.maximum_use: +>>>>>>> d04257a32d (fix: coupon code validation logic) frappe.throw(_("Sorry, this coupon code is no longer valid")) + def update_coupon_code_count(coupon_name, transaction_type): coupon = frappe.get_doc("Coupon Code", coupon_name) if coupon: From 719565c8973f18783fb44503536317a0d8e25a9f Mon Sep 17 00:00:00 2001 From: "bhaveshkumar.j" Date: Mon, 21 Oct 2024 18:23:39 +0000 Subject: [PATCH 08/13] fix: remove extra space (cherry picked from commit 1561a9e1bf6b179dddae2861160d224b6983ced1) --- erpnext/accounts/doctype/pricing_rule/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 0b0a3235b3a..48f81629244 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -734,7 +734,6 @@ def validate_coupon_code(coupon_name): frappe.throw(_("Sorry, this coupon code is no longer valid")) - def update_coupon_code_count(coupon_name, transaction_type): coupon = frappe.get_doc("Coupon Code", coupon_name) if coupon: From 2af36383cc33455041c82040a2deb58e5455ecbe Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 22 Oct 2024 10:16:57 +0530 Subject: [PATCH 09/13] chore: resolve conflict --- erpnext/accounts/doctype/pricing_rule/utils.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py index 48f81629244..0b3117365c0 100644 --- a/erpnext/accounts/doctype/pricing_rule/utils.py +++ b/erpnext/accounts/doctype/pricing_rule/utils.py @@ -715,22 +715,11 @@ def get_pricing_rule_items(pr_doc, other_items=False) -> list: def validate_coupon_code(coupon_name): coupon = frappe.get_doc("Coupon Code", coupon_name) -<<<<<<< HEAD - - if coupon.valid_from: - if coupon.valid_from > getdate(today()): - frappe.throw(_("Sorry, this coupon code's validity has not started")) - elif coupon.valid_upto: - if coupon.valid_upto < getdate(today()): - frappe.throw(_("Sorry, this coupon code's validity has expired")) - elif coupon.used >= coupon.maximum_use: -======= if coupon.valid_from and coupon.valid_from > getdate(today()): frappe.throw(_("Sorry, this coupon code's validity has not started")) elif coupon.valid_upto and coupon.valid_upto < getdate(today()): frappe.throw(_("Sorry, this coupon code's validity has expired")) elif coupon.maximum_use and coupon.used >= coupon.maximum_use: ->>>>>>> d04257a32d (fix: coupon code validation logic) frappe.throw(_("Sorry, this coupon code is no longer valid")) From 0dcb5a4fbbe14958b868f13ba984f1e2701aabda Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 22 Oct 2024 11:59:57 +0530 Subject: [PATCH 10/13] refactor: allow unreconcile on bank and cash entry type journals (cherry picked from commit 2c4f37f488031d98c9b8297758295422520a9eea) --- erpnext/public/js/utils/unreconcile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/utils/unreconcile.js b/erpnext/public/js/utils/unreconcile.js index c6ee8a330c7..de20f468ccb 100644 --- a/erpnext/public/js/utils/unreconcile.js +++ b/erpnext/public/js/utils/unreconcile.js @@ -4,7 +4,8 @@ erpnext.accounts.unreconcile_payment = { add_unreconcile_btn(frm) { if (frm.doc.docstatus == 1) { if ( - (frm.doc.doctype == "Journal Entry" && frm.doc.voucher_type != "Journal Entry") || + (frm.doc.doctype == "Journal Entry" && + !["Journal Entry", "Bank Entry", "Cash Entry"].includes(frm.doc.voucher_type)) || !["Purchase Invoice", "Sales Invoice", "Journal Entry", "Payment Entry"].includes( frm.doc.doctype ) From 3d082c93bc0bc96a800d32f50b3a2f0311ceee92 Mon Sep 17 00:00:00 2001 From: Corentin Forler Date: Wed, 9 Oct 2024 09:56:17 +0200 Subject: [PATCH 11/13] fix(deferred_revenue): Escape account in query (cherry picked from commit c7b3ae41d4a0b1506ef50d470a9eed3f76f85a22) --- erpnext/accounts/deferred_revenue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py index a48ce9b4c63..cd34bf7f850 100644 --- a/erpnext/accounts/deferred_revenue.py +++ b/erpnext/accounts/deferred_revenue.py @@ -58,7 +58,7 @@ def build_conditions(process_type, account, company): ) if account: - conditions += f"AND {deferred_account}='{account}'" + conditions += f"AND {deferred_account}='{frappe.db.escape(account)}'" elif company: conditions += f"AND p.company = {frappe.db.escape(company)}" From 411f7c3a2cacf949fd291f816e70df4e4fd82651 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Tue, 22 Oct 2024 13:44:28 +0200 Subject: [PATCH 12/13] refactor: validate_return_against_account (#43778) (cherry picked from commit c4faa0e101f5c9e3c885eedc08c7ae318b555717) --- erpnext/controllers/accounts_controller.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index da222d5f58e..153b6f5320a 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -357,12 +357,17 @@ class AccountsController(TransactionBase): def validate_return_against_account(self): if self.doctype in ["Sales Invoice", "Purchase Invoice"] and self.is_return and self.return_against: cr_dr_account_field = "debit_to" if self.doctype == "Sales Invoice" else "credit_to" - cr_dr_account_label = "Debit To" if self.doctype == "Sales Invoice" else "Credit To" + cr_dr_account_label = self.meta.get_label(cr_dr_account_field) cr_dr_account = self.get(cr_dr_account_field) - if frappe.get_value(self.doctype, self.return_against, cr_dr_account_field) != cr_dr_account: + original_account = frappe.get_value(self.doctype, self.return_against, cr_dr_account_field) + if original_account != cr_dr_account: frappe.throw( - _("'{0}' account: '{1}' should match the Return Against Invoice").format( - frappe.bold(cr_dr_account_label), frappe.bold(cr_dr_account) + _( + "Please set {0} to {1}, the same account that was used in the original invoice {2}." + ).format( + frappe.bold(_(cr_dr_account_label, context=self.doctype)), + frappe.bold(cr_dr_account), + frappe.bold(self.return_against), ) ) From 5b0a8fd2cedeacde822aff82d7aa25ac7b8bb324 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 19:43:13 +0200 Subject: [PATCH 13/13] fix: use correct variable in error message (backport #43790) (#43791) Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> fix: use correct variable in error message (#43790) --- erpnext/controllers/accounts_controller.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 153b6f5320a..bcdc788df47 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -357,16 +357,14 @@ class AccountsController(TransactionBase): def validate_return_against_account(self): if self.doctype in ["Sales Invoice", "Purchase Invoice"] and self.is_return and self.return_against: cr_dr_account_field = "debit_to" if self.doctype == "Sales Invoice" else "credit_to" - cr_dr_account_label = self.meta.get_label(cr_dr_account_field) - cr_dr_account = self.get(cr_dr_account_field) original_account = frappe.get_value(self.doctype, self.return_against, cr_dr_account_field) - if original_account != cr_dr_account: + if original_account != self.get(cr_dr_account_field): frappe.throw( _( "Please set {0} to {1}, the same account that was used in the original invoice {2}." ).format( - frappe.bold(_(cr_dr_account_label, context=self.doctype)), - frappe.bold(cr_dr_account), + frappe.bold(_(self.meta.get_label(cr_dr_account_field), context=self.doctype)), + frappe.bold(original_account), frappe.bold(self.return_against), ) )