示例#1
0
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 = 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 = get_gl_entries(
        filters.company,
        filters.from_date,
        filters.to_date,
        min_lft,
        max_rgt,
        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)

    return data
示例#2
0
def get_data(filters):
    accounts = frappe.db.sql(
        """select * from `tabAccount` where company=%s order by lft""",
        filters.company,
        as_dict=True)

    if not accounts:
        return None

    accounts, accounts_by_name = 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 = get_gl_entries(
        filters.company,
        None,
        filters.to_date,
        min_lft,
        max_rgt,
        ignore_closing_entries=not flt(filters.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)

    return data