[fix] Account Currency and Balance fixed in chart of accounts #4019
This commit is contained in:
parent
8247ad4028
commit
77ca80217c
@ -166,7 +166,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
var dr_or_cr = node.data.balance < 0 ? "Cr" : "Dr";
|
var dr_or_cr = node.data.balance < 0 ? "Cr" : "Dr";
|
||||||
if (me.ctype == 'Account' && node.data && node.data.balance!==undefined) {
|
if (me.ctype == 'Account' && node.data && node.data.balance!==undefined) {
|
||||||
$('<span class="balance-area pull-right text-muted small">'
|
$('<span class="balance-area pull-right text-muted small">'
|
||||||
+ format_currency(Math.abs(node.data.balance), node.data.currency)
|
+ format_currency(Math.abs(node.data.balance), node.data.account_currency)
|
||||||
+ " " + dr_or_cr
|
+ " " + dr_or_cr
|
||||||
+ '</span>').insertBefore(node.$ul);
|
+ '</span>').insertBefore(node.$ul);
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,7 @@ def get_children():
|
|||||||
|
|
||||||
# root
|
# root
|
||||||
if args['parent'] in ("Accounts", "Cost Centers"):
|
if args['parent'] in ("Accounts", "Cost Centers"):
|
||||||
select_cond = ", root_type, report_type" if args["parent"]=="Accounts" else ""
|
select_cond = ", root_type, report_type, account_currency" if ctype=="Account" else ""
|
||||||
|
|
||||||
acc = frappe.db.sql(""" select
|
acc = frappe.db.sql(""" select
|
||||||
name as value, is_group as expandable %s
|
name as value, is_group as expandable %s
|
||||||
from `tab%s`
|
from `tab%s`
|
||||||
@ -35,19 +34,17 @@ def get_children():
|
|||||||
sort_root_accounts(acc)
|
sort_root_accounts(acc)
|
||||||
else:
|
else:
|
||||||
# other
|
# other
|
||||||
|
select_cond = ", account_currency" if ctype=="Account" else ""
|
||||||
acc = frappe.db.sql("""select
|
acc = frappe.db.sql("""select
|
||||||
name as value, is_group as expandable
|
name as value, is_group as expandable %s
|
||||||
from `tab%s`
|
from `tab%s`
|
||||||
where ifnull(parent_%s,'') = %s
|
where ifnull(parent_%s,'') = %s
|
||||||
and docstatus<2
|
and docstatus<2
|
||||||
order by name""" % (ctype, ctype.lower().replace(' ','_'), '%s'),
|
order by name""" % (select_cond, ctype, ctype.lower().replace(' ','_'), '%s'),
|
||||||
args['parent'], as_dict=1)
|
args['parent'], as_dict=1)
|
||||||
|
|
||||||
if ctype == 'Account':
|
if ctype == 'Account':
|
||||||
currency = frappe.db.sql("select default_currency from `tabCompany` where name = %s", company)[0][0]
|
|
||||||
for each in acc:
|
for each in acc:
|
||||||
bal = get_balance_on(each.get("value"))
|
each["balance"] = flt(get_balance_on(each.get("value")))
|
||||||
each["currency"] = currency
|
|
||||||
each["balance"] = flt(bal)
|
|
||||||
|
|
||||||
return acc
|
return acc
|
||||||
|
@ -94,6 +94,11 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, in_acco
|
|||||||
select name from `tabAccount` ac where ac.name = gle.account
|
select name from `tabAccount` ac where ac.name = gle.account
|
||||||
and ac.lft >= %s and ac.rgt <= %s
|
and ac.lft >= %s and ac.rgt <= %s
|
||||||
)""" % (acc.lft, acc.rgt))
|
)""" % (acc.lft, acc.rgt))
|
||||||
|
|
||||||
|
# If group and currency same as company,
|
||||||
|
# always return balance based on debit and credit in company currency
|
||||||
|
if acc.account_currency == frappe.db.get_value("Company", acc.company, "default_currency"):
|
||||||
|
in_account_currency = False
|
||||||
else:
|
else:
|
||||||
cond.append("""gle.account = "%s" """ % (account.replace('"', '\\"'), ))
|
cond.append("""gle.account = "%s" """ % (account.replace('"', '\\"'), ))
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user