Beispiel #1
0
def get_cash_flow_data(fiscal_year, companies, filters):
    cash_flow_accounts = get_cash_flow_accounts()

    income, expense, net_profit_loss = get_income_expense_data(
        companies, fiscal_year, filters)

    data = []
    summary_data = {}
    company_currency = get_company_currency(filters)

    for cash_flow_account in cash_flow_accounts:
        section_data = []
        data.append({
            "account_name": cash_flow_account['section_header'],
            "parent_account": None,
            "indent": 0.0,
            "account": cash_flow_account['section_header']
        })

        if len(data) == 1:
            # add first net income in operations section
            if net_profit_loss:
                net_profit_loss.update({
                    "indent":
                    1,
                    "parent_account":
                    cash_flow_accounts[0]['section_header']
                })
                data.append(net_profit_loss)
                section_data.append(net_profit_loss)

        for account in cash_flow_account['account_types']:
            account_data = get_account_type_based_data(account['account_type'],
                                                       companies, fiscal_year,
                                                       filters)
            account_data.update({
                "account_name":
                account['label'],
                "account":
                account['label'],
                "indent":
                1,
                "parent_account":
                cash_flow_account['section_header'],
                "currency":
                company_currency
            })
            data.append(account_data)
            section_data.append(account_data)

        add_total_row_account(data, section_data,
                              cash_flow_account['section_footer'], companies,
                              company_currency, summary_data, True)

    add_total_row_account(data, data, _("Net Change in Cash"), companies,
                          company_currency, summary_data, True)

    report_summary = get_cash_flow_summary(summary_data, company_currency)

    return data, report_summary
def get_cash_flow_data(fiscal_year, companies, filters):
	cash_flow_accounts = get_cash_flow_accounts()

	income, expense, net_profit_loss = get_income_expense_data(companies, fiscal_year, filters)

	data = []
	company_currency = get_company_currency(filters)

	for cash_flow_account in cash_flow_accounts:
		section_data = []
		data.append({
			"account_name": cash_flow_account['section_header'],
			"parent_account": None,
			"indent": 0.0,
			"account": cash_flow_account['section_header']
		})

		if len(data) == 1:
			# add first net income in operations section
			if net_profit_loss:
				net_profit_loss.update({
					"indent": 1, 
					"parent_account": cash_flow_accounts[0]['section_header']
				})
				data.append(net_profit_loss)
				section_data.append(net_profit_loss)

		for account in cash_flow_account['account_types']:
			account_data = get_account_type_based_data(account['account_type'], companies, fiscal_year)
			account_data.update({
				"account_name": account['label'],
				"account": account['label'],
				"indent": 1,
				"parent_account": cash_flow_account['section_header'],
				"currency": company_currency
			})
			data.append(account_data)
			section_data.append(account_data)

		add_total_row_account(data, section_data, cash_flow_account['section_footer'],
			companies, company_currency, True)

	add_total_row_account(data, data, _("Net Change in Cash"), companies, company_currency, True)

	return data