mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 10:11:20 +00:00
Merge pull request #37125 from frappe/mergify/bp/version-14-hotfix/pr-33502
feat: Toggle display of Account Balance in Chart of Accounts (backport #33502)
This commit is contained in:
@@ -56,36 +56,41 @@ frappe.treeview_settings["Account"] = {
|
|||||||
accounts = nodes;
|
accounts = nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const get_balances = frappe.call({
|
frappe.db.get_single_value("Accounts Settings", "show_balance_in_coa").then((value) => {
|
||||||
method: 'erpnext.accounts.utils.get_account_balances',
|
if(value) {
|
||||||
args: {
|
|
||||||
accounts: accounts,
|
|
||||||
company: cur_tree.args.company
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
get_balances.then(r => {
|
const get_balances = frappe.call({
|
||||||
if (!r.message || r.message.length == 0) return;
|
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];
|
for (let account of r.message) {
|
||||||
if (!node || node.is_root) continue;
|
|
||||||
|
|
||||||
// show Dr if positive since balance is calculated as debit - credit else show Cr
|
const node = cur_tree.nodes && cur_tree.nodes[account.value];
|
||||||
const balance = account.balance_in_account_currency || account.balance;
|
if (!node || node.is_root) continue;
|
||||||
const dr_or_cr = balance > 0 ? "Dr": "Cr";
|
|
||||||
const format = (value, currency) => format_currency(Math.abs(value), currency);
|
|
||||||
|
|
||||||
if (account.balance!==undefined) {
|
// show Dr if positive since balance is calculated as debit - credit else show Cr
|
||||||
node.parent && node.parent.find('.balance-area').remove();
|
const balance = account.balance_in_account_currency || account.balance;
|
||||||
$('<span class="balance-area pull-right">'
|
const dr_or_cr = balance > 0 ? "Dr": "Cr";
|
||||||
+ (account.balance_in_account_currency ?
|
const format = (value, currency) => format_currency(Math.abs(value), currency);
|
||||||
(format(account.balance_in_account_currency, account.account_currency) + " / ") : "")
|
|
||||||
+ format(account.balance, account.company_currency)
|
if (account.balance!==undefined) {
|
||||||
+ " " + dr_or_cr
|
node.parent && node.parent.find('.balance-area').remove();
|
||||||
+ '</span>').insertBefore(node.$ul);
|
$('<span class="balance-area pull-right">'
|
||||||
}
|
+ (account.balance_in_account_currency ?
|
||||||
|
(format(account.balance_in_account_currency, account.account_currency) + " / ") : "")
|
||||||
|
+ format(account.balance, account.company_currency)
|
||||||
|
+ " " + dr_or_cr
|
||||||
|
+ '</span>').insertBefore(node.$ul);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -66,7 +66,9 @@
|
|||||||
"report_settings_sb",
|
"report_settings_sb",
|
||||||
"banking_tab",
|
"banking_tab",
|
||||||
"enable_party_matching",
|
"enable_party_matching",
|
||||||
"enable_fuzzy_matching"
|
"enable_fuzzy_matching",
|
||||||
|
"tab_break_dpet",
|
||||||
|
"show_balance_in_coa"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -416,6 +418,17 @@
|
|||||||
"fieldname": "ignore_account_closing_balance",
|
"fieldname": "ignore_account_closing_balance",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Ignore Account Closing Balance"
|
"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"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-cog",
|
"icon": "icon-cog",
|
||||||
|
|||||||
Reference in New Issue
Block a user