From 8b2328c6d31b2985f40a5516a2a6377a1bc53218 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 2 Jan 2023 12:21:45 +0530 Subject: [PATCH 1/3] refactor: show balance checkbox in Accounts Settings (cherry picked from commit 1b78fae6fc5e61a02781abe298a6436364a6695d) # Conflicts: # erpnext/accounts/doctype/accounts_settings/accounts_settings.json --- .../accounts_settings/accounts_settings.json | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 467c68f1021..bfd1eb37f47 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -64,9 +64,14 @@ "column_break_25", "frozen_accounts_modifier", "report_settings_sb", +<<<<<<< HEAD "banking_tab", "enable_party_matching", "enable_fuzzy_matching" +======= + "tab_break_dpet", + "show_balance_in_coa" +>>>>>>> 1b78fae6fc (refactor: show balance checkbox in Accounts Settings) ], "fields": [ { @@ -355,6 +360,7 @@ "label": "Allow multi-currency invoices against single party account " }, { +<<<<<<< HEAD "default": "0", "description": "Split Early Payment Discount Loss into Income and Tax Loss", "fieldname": "book_tax_discount_loss", @@ -416,6 +422,17 @@ "fieldname": "ignore_account_closing_balance", "fieldtype": "Check", "label": "Ignore Account Closing Balance" +======= + "fieldname": "tab_break_dpet", + "fieldtype": "Tab Break", + "label": "Chart Of Accounts" + }, + { + "default": "1", + "fieldname": "show_balance_in_coa", + "fieldtype": "Check", + "label": "Show Balances in Chart Of Accounts" +>>>>>>> 1b78fae6fc (refactor: show balance checkbox in Accounts Settings) } ], "icon": "icon-cog", @@ -423,7 +440,11 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], +<<<<<<< HEAD "modified": "2023-07-27 15:05:34.000264", +======= + "modified": "2023-01-02 12:07:42.434214", +>>>>>>> 1b78fae6fc (refactor: show balance checkbox in Accounts Settings) "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", From 18702841af6fc13ae89e1a2bc56ea703143e076b Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 2 Jan 2023 12:22:33 +0530 Subject: [PATCH 2/3] refactor: Show Balance in COA based on Accounts Settings (cherry picked from commit 23fbe86d51193c7242119bec81d4d63c8191d49d) --- .../accounts/doctype/account/account_tree.js | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/erpnext/accounts/doctype/account/account_tree.js b/erpnext/accounts/doctype/account/account_tree.js index 8ae90ceb383..d537adfcbfd 100644 --- a/erpnext/accounts/doctype/account/account_tree.js +++ b/erpnext/accounts/doctype/account/account_tree.js @@ -56,36 +56,41 @@ frappe.treeview_settings["Account"] = { accounts = nodes; } - const get_balances = frappe.call({ - method: 'erpnext.accounts.utils.get_account_balances', - args: { - accounts: accounts, - company: cur_tree.args.company - }, - }); + frappe.db.get_single_value("Accounts Settings", "show_balance_in_coa").then((value) => { + if(value) { - get_balances.then(r => { - if (!r.message || r.message.length == 0) return; + const get_balances = frappe.call({ + method: 'erpnext.accounts.utils.get_account_balances', + args: { + accounts: accounts, + company: cur_tree.args.company + }, + }); - for (let account of r.message) { + get_balances.then(r => { + if (!r.message || r.message.length == 0) return; - const node = cur_tree.nodes && cur_tree.nodes[account.value]; - if (!node || node.is_root) continue; + for (let account of r.message) { - // show Dr if positive since balance is calculated as debit - credit else show Cr - const balance = account.balance_in_account_currency || account.balance; - const dr_or_cr = balance > 0 ? "Dr": "Cr"; - const format = (value, currency) => format_currency(Math.abs(value), currency); + const node = cur_tree.nodes && cur_tree.nodes[account.value]; + if (!node || node.is_root) continue; - if (account.balance!==undefined) { - node.parent && node.parent.find('.balance-area').remove(); - $('' - + (account.balance_in_account_currency ? - (format(account.balance_in_account_currency, account.account_currency) + " / ") : "") - + format(account.balance, account.company_currency) - + " " + dr_or_cr - + '').insertBefore(node.$ul); - } + // show Dr if positive since balance is calculated as debit - credit else show Cr + const balance = account.balance_in_account_currency || account.balance; + const dr_or_cr = balance > 0 ? "Dr": "Cr"; + const format = (value, currency) => format_currency(Math.abs(value), currency); + + if (account.balance!==undefined) { + node.parent && node.parent.find('.balance-area').remove(); + $('' + + (account.balance_in_account_currency ? + (format(account.balance_in_account_currency, account.account_currency) + " / ") : "") + + format(account.balance, account.company_currency) + + " " + dr_or_cr + + '').insertBefore(node.$ul); + } + } + }); } }); }, From 79321f56caf12af2d2d5abfd3260104cc1279936 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 18 Sep 2023 10:29:29 +0530 Subject: [PATCH 3/3] chore: resolve conflicts --- .../accounts_settings/accounts_settings.json | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index bfd1eb37f47..3ab9d2b60d5 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -64,14 +64,11 @@ "column_break_25", "frozen_accounts_modifier", "report_settings_sb", -<<<<<<< HEAD "banking_tab", "enable_party_matching", - "enable_fuzzy_matching" -======= + "enable_fuzzy_matching", "tab_break_dpet", "show_balance_in_coa" ->>>>>>> 1b78fae6fc (refactor: show balance checkbox in Accounts Settings) ], "fields": [ { @@ -360,7 +357,6 @@ "label": "Allow multi-currency invoices against single party account " }, { -<<<<<<< HEAD "default": "0", "description": "Split Early Payment Discount Loss into Income and Tax Loss", "fieldname": "book_tax_discount_loss", @@ -422,7 +418,8 @@ "fieldname": "ignore_account_closing_balance", "fieldtype": "Check", "label": "Ignore Account Closing Balance" -======= + }, + { "fieldname": "tab_break_dpet", "fieldtype": "Tab Break", "label": "Chart Of Accounts" @@ -432,7 +429,6 @@ "fieldname": "show_balance_in_coa", "fieldtype": "Check", "label": "Show Balances in Chart Of Accounts" ->>>>>>> 1b78fae6fc (refactor: show balance checkbox in Accounts Settings) } ], "icon": "icon-cog", @@ -440,11 +436,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], -<<<<<<< HEAD "modified": "2023-07-27 15:05:34.000264", -======= - "modified": "2023-01-02 12:07:42.434214", ->>>>>>> 1b78fae6fc (refactor: show balance checkbox in Accounts Settings) "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings",