def get_data(filters): accounts = frappe.db.sql("""select name, parent_account, account_name, root_type, report_type, lft, rgt from `tabAccount` where company=%s order by lft""", filters.company, as_dict=True) if not accounts: return None accounts, accounts_by_name, parent_children_map = filter_accounts(accounts) min_lft, max_rgt = frappe.db.sql("""select min(lft), max(rgt) from `tabAccount` where company=%s""", (filters.company,))[0] gl_entries_by_account = {} set_gl_entries_by_account(filters.company, filters.from_date, filters.to_date, min_lft, max_rgt, filters, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry)) opening_balances = get_opening_balances(filters) total_row = calculate_values(accounts, gl_entries_by_account, opening_balances, filters) accumulate_values_into_parents(accounts, accounts_by_name) data = prepare_data(accounts, filters, total_row, parent_children_map) data = filter_out_zero_value_rows(data, parent_children_map, show_zero_values=filters.get("show_zero_values")) return data
def get_data(filters): accounts = frappe.db.sql("""select name, parent_account, account_name, root_type, report_type, lft, rgt from `tabAccount` where company=%s order by lft""", filters.company, as_dict=True) company_currency = erpnext.get_company_currency(filters.company) if not accounts: return None accounts, accounts_by_name, parent_children_map = filter_accounts(accounts) min_lft, max_rgt = frappe.db.sql("""select min(lft), max(rgt) from `tabAccount` where company=%s""", (filters.company,))[0] gl_entries_by_account = {} set_gl_entries_by_account(filters.company, filters.from_date, filters.to_date, min_lft, max_rgt, filters, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry)) opening_balances = get_opening_balances(filters) total_row = calculate_values(accounts, gl_entries_by_account, opening_balances, filters, company_currency) accumulate_values_into_parents(accounts, accounts_by_name) data = prepare_data(accounts, filters, total_row, parent_children_map, company_currency) data = filter_out_zero_value_rows(data, parent_children_map, show_zero_values=filters.get("show_zero_values")) return data
def get_data(accounts, filters, based_on): if not accounts: return [] accounts, accounts_by_name, parent_children_map = filter_accounts(accounts) gl_entries_by_account = {} set_gl_entries_by_account( filters.get("company"), filters.get("from_date"), filters.get("to_date"), based_on, gl_entries_by_account, ignore_closing_entries=not flt( filters.get("with_period_closing_entry")), ) total_row = calculate_values(accounts, gl_entries_by_account, filters) accumulate_values_into_parents(accounts, accounts_by_name) data = prepare_data(accounts, filters, total_row, parent_children_map, based_on) data = filter_out_zero_value_rows( data, parent_children_map, show_zero_values=filters.get("show_zero_values")) return data
def get_data(company, root_type, balance_must_be, period_list, grouper, filters=None, accumulated_values=1, only_current_fiscal_year=True, ignore_closing_entries=False, ignore_accumulated_values_for_fy=False, total=True): accounts = get_accounts(company, root_type) if not accounts: return None accounts, accounts_by_name, parent_children_map = filter_accounts(accounts) company_currency = get_appropriate_currency(company, filters) gl_entries_by_account = {} for root in frappe.db.sql("""select lft, rgt from tabAccount where root_type=%s and ifnull(parent_account, '') = ''""", root_type, as_dict=1): set_gl_entries_by_account( company, period_list[0]["year_start_date"] if only_current_fiscal_year else None, period_list[-1]["to_date"], root.lft, root.rgt, filters, gl_entries_by_account, ignore_closing_entries=ignore_closing_entries) calculate_values(accounts_by_name, gl_entries_by_account, period_list, accumulated_values, ignore_accumulated_values_for_fy) grouper.update(accounts_by_name) accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values) out = prepare_data(accounts, balance_must_be, period_list, company_currency) out = filter_out_zero_value_rows(out, parent_children_map) if out and total: add_total_row(out, root_type, balance_must_be, period_list, company_currency) return out
def get_data(filters): accounts = frappe.db.sql( """select name, account_number, parent_account, account_name, root_type, report_type, lft, rgt from `tabAccount` where company=%s order by lft""", filters.company, as_dict=True, ) company_currency = filters.presentation_currency or erpnext.get_company_currency( filters.company) if not accounts: return None accounts, accounts_by_name, parent_children_map = filter_accounts(accounts) min_lft, max_rgt = frappe.db.sql( """select min(lft), max(rgt) from `tabAccount` where company=%s""", (filters.company, ), )[0] gl_entries_by_account = {} opening_balances = get_opening_balances(filters) # add filter inside list so that the query in financial_statements.py doesn't break if filters.project: filters.project = [filters.project] set_gl_entries_by_account( filters.company, filters.from_date, filters.to_date, min_lft, max_rgt, filters, gl_entries_by_account, ignore_closing_entries=not flt(filters.with_period_closing_entry), ) total_row = calculate_values(accounts, gl_entries_by_account, opening_balances, filters, company_currency) accumulate_values_into_parents(accounts, accounts_by_name) data = prepare_data(accounts, filters, total_row, parent_children_map, company_currency) data = filter_out_zero_value_rows( data, parent_children_map, show_zero_values=filters.get("show_zero_values")) return data
def get_data(filters, dimension_list): company_currency = erpnext.get_company_currency(filters.company) acc = frappe.db.sql( """ select name, account_number, parent_account, lft, rgt, root_type, report_type, account_name, include_in_gross, account_type, is_group from `tabAccount` where company=%s order by lft""", (filters.company), as_dict=True, ) if not acc: return None accounts, accounts_by_name, parent_children_map = filter_accounts(acc) min_lft, max_rgt = frappe.db.sql( """select min(lft), max(rgt) from `tabAccount` where company=%s""", (filters.company), )[0] account = frappe.db.sql_list( """select name from `tabAccount` where lft >= %s and rgt <= %s and company = %s""", (min_lft, max_rgt, filters.company), ) gl_entries_by_account = {} set_gl_entries_by_account(dimension_list, filters, account, gl_entries_by_account) format_gl_entries(gl_entries_by_account, accounts_by_name, dimension_list, frappe.scrub(filters.get("dimension"))) accumulate_values_into_parents(accounts, accounts_by_name, dimension_list) out = prepare_data(accounts, filters, company_currency, dimension_list) out = filter_out_zero_value_rows(out, parent_children_map) return out
def get_data(accounts, filters, based_on): if not accounts: return [] accounts, accounts_by_name, parent_children_map = filter_accounts(accounts) gl_entries_by_account = {} set_gl_entries_by_account(filters.get("company"), filters.get("from_date"), filters.get("to_date"), based_on, gl_entries_by_account, ignore_closing_entries=not flt(filters.get("with_period_closing_entry"))) total_row = calculate_values(accounts, gl_entries_by_account, filters) accumulate_values_into_parents(accounts, accounts_by_name) data = prepare_data(accounts, filters, total_row, parent_children_map, based_on) data = filter_out_zero_value_rows(data, parent_children_map, show_zero_values=filters.get("show_zero_values")) return data