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"])
|
||||
|
||||
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""", {
|
||||
"company_lft": company_lft,
|
||||
"company_rgt": company_rgt,
|
||||
})
|
||||
}, as_dict=1)
|
||||
|
||||
for company in companies:
|
||||
currency_info = frappe._dict({
|
||||
'report_date': to_date,
|
||||
'presentation_currency': filters.get('presentation_currency')
|
||||
})
|
||||
|
||||
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.fiscal_year, gl.debit_in_account_currency, gl.credit_in_account_currency, gl.account_currency,
|
||||
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,
|
||||
"lft": root_lft,
|
||||
"rgt": root_rgt,
|
||||
"company": company
|
||||
"company": d.name
|
||||
},
|
||||
as_dict=True)
|
||||
|
||||
if filters and filters.get('presentation_currency'):
|
||||
filters['company'] = company
|
||||
convert_to_presentation_currency(gl_entries, get_currency(filters))
|
||||
if filters and filters.get('presentation_currency') != d.default_currency:
|
||||
currency_info['company'] = d.name
|
||||
currency_info['company_currency'] = d.default_currency
|
||||
convert_to_presentation_currency(gl_entries, currency_info)
|
||||
|
||||
for entry in gl_entries:
|
||||
key = entry.account_number or entry.account_name
|
||||
|
Loading…
x
Reference in New Issue
Block a user