Code optimization for consolidated financial statement report
This commit is contained in:
parent
02a7f8f0b2
commit
704796b1cb
@ -331,13 +331,18 @@ def set_gl_entries_by_account(from_date, to_date, root_lft, root_rgt, filters, g
|
|||||||
filters.get('company'), ["lft", "rgt"])
|
filters.get('company'), ["lft", "rgt"])
|
||||||
|
|
||||||
additional_conditions = get_additional_conditions(from_date, ignore_closing_entries, filters)
|
additional_conditions = get_additional_conditions(from_date, ignore_closing_entries, filters)
|
||||||
companies = frappe.db.sql_list(""" select name from `tabCompany`
|
companies = frappe.db.sql(""" select name, default_currency from `tabCompany`
|
||||||
where lft >= %(company_lft)s and rgt <= %(company_rgt)s""", {
|
where lft >= %(company_lft)s and rgt <= %(company_rgt)s""", {
|
||||||
"company_lft": company_lft,
|
"company_lft": company_lft,
|
||||||
"company_rgt": company_rgt,
|
"company_rgt": company_rgt,
|
||||||
|
}, as_dict=1)
|
||||||
|
|
||||||
|
currency_info = frappe._dict({
|
||||||
|
'report_date': to_date,
|
||||||
|
'presentation_currency': filters.get('presentation_currency')
|
||||||
})
|
})
|
||||||
|
|
||||||
for company in companies:
|
for d in companies:
|
||||||
gl_entries = frappe.db.sql("""select gl.posting_date, gl.account, gl.debit, gl.credit, gl.is_opening, gl.company,
|
gl_entries = frappe.db.sql("""select gl.posting_date, gl.account, gl.debit, gl.credit, gl.is_opening, gl.company,
|
||||||
gl.fiscal_year, gl.debit_in_account_currency, gl.credit_in_account_currency, gl.account_currency,
|
gl.fiscal_year, gl.debit_in_account_currency, gl.credit_in_account_currency, gl.account_currency,
|
||||||
acc.account_name, acc.account_number
|
acc.account_name, acc.account_number
|
||||||
@ -349,13 +354,14 @@ def set_gl_entries_by_account(from_date, to_date, root_lft, root_rgt, filters, g
|
|||||||
"to_date": to_date,
|
"to_date": to_date,
|
||||||
"lft": root_lft,
|
"lft": root_lft,
|
||||||
"rgt": root_rgt,
|
"rgt": root_rgt,
|
||||||
"company": company
|
"company": d.name
|
||||||
},
|
},
|
||||||
as_dict=True)
|
as_dict=True)
|
||||||
|
|
||||||
if filters and filters.get('presentation_currency'):
|
if filters and filters.get('presentation_currency') != d.default_currency:
|
||||||
filters['company'] = company
|
currency_info['company'] = d.name
|
||||||
convert_to_presentation_currency(gl_entries, get_currency(filters))
|
currency_info['company_currency'] = d.default_currency
|
||||||
|
convert_to_presentation_currency(gl_entries, currency_info)
|
||||||
|
|
||||||
for entry in gl_entries:
|
for entry in gl_entries:
|
||||||
key = entry.account_number or entry.account_name
|
key = entry.account_number or entry.account_name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user