def execute(filters=None):
    columns, data, message, chart = [], [], [], []

    if not filters.get('company'):
        return columns, data, message, chart

    fiscal_year = get_fiscal_year_data(filters.get('from_fiscal_year'),
                                       filters.get('to_fiscal_year'))
    companies_column, companies = get_companies(filters)
    columns = get_columns(companies_column)

    if filters.get('report') == "Balance Sheet":
        data, message, chart = get_balance_sheet_data(fiscal_year, companies,
                                                      columns, filters)
    elif filters.get('report') == "Profit and Loss Statement":
        data, message, chart = get_profit_loss_data(fiscal_year, companies,
                                                    columns, filters)
    else:
        if cint(
                frappe.db.get_single_value('Accounts Settings',
                                           'use_custom_cash_flow')):
            from erpnext.accounts.report.cash_flow.custom_cash_flow import execute as execute_custom
            return execute_custom(filters=filters)

        data = get_cash_flow_data(fiscal_year, companies, filters)

    return columns, data, message, chart
Esempio n. 2
0
def execute(filters=None):
	if cint(frappe.db.get_single_value('Accounts Settings', 'use_custom_cash_flow')):
		from erpnext.accounts.report.cash_flow.custom_cash_flow import execute as execute_custom
		return execute_custom(filters=filters)
		
	period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, 
		filters.periodicity, filters.accumulated_values, filters.company)

	cash_flow_accounts = get_cash_flow_accounts()

	# compute net profit / loss
	income = get_data(filters.company, "Income", "Credit", period_list, filters=filters,
		accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True)
	expense = get_data(filters.company, "Expense", "Debit", period_list, filters=filters,
		accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True)
		
	net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company)

	data = []
	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency")
	
	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(filters.company, 
				account['account_type'], period_list, filters.accumulated_values)
			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'], 
			period_list, company_currency)

	add_total_row_account(data, data, _("Net Change in Cash"), period_list, company_currency)
	columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, filters.company)

	return columns, data
Esempio n. 3
0
def execute(filters=None):
    columns, data, message, chart = [], [], [], []

    if not filters.get('company'):
        return columns, data, message, chart

    if filters.get('compare_with_company') and not (filters.from_company
                                                    or filters.to_company):
        frappe.msgprint(_("Please select From Company  and To Company"))

    period_list = get_period_list(filters.from_date, filters.to_date,
                                  filters.periodicity,
                                  filters.accumulated_in_group_company)

    companies_column, companies = get_companies(filters)
    columns = get_columns(companies_column, filters.periodicity, period_list,
                          filters, filters.accumulated_in_group_company)

    if filters.get('report') == "Balance Sheet":
        data, message, chart = get_balance_sheet_data(period_list, companies,
                                                      columns, filters)
    elif filters.get('report') == "Profit and Loss Statement":
        data, message, chart = get_profit_loss_data(period_list, companies,
                                                    columns, filters)
    else:
        if cint(
                frappe.db.get_single_value('Accounts Settings',
                                           'use_custom_cash_flow')):
            from erpnext.accounts.report.cash_flow.custom_cash_flow import execute as execute_custom
            return execute_custom(filters=filters)

        data = get_cash_flow_data(period_list, companies, filters)

    return columns, data, message, chart
def execute(filters=None):
	columns, data, message, chart = [], [], [], []

	if not filters.get('company'):
		return columns, data, message, chart

	fiscal_year = get_fiscal_year_data(filters.get('from_fiscal_year'), filters.get('to_fiscal_year'))
	companies_column, companies = get_companies(filters)
	columns = get_columns(companies_column)

	if filters.get('report') == "Balance Sheet":
		data, message, chart = get_balance_sheet_data(fiscal_year, companies, columns, filters)
	elif filters.get('report') == "Profit and Loss Statement":
		data, message, chart = get_profit_loss_data(fiscal_year, companies, columns, filters)
	else:
		if cint(frappe.db.get_single_value('Accounts Settings', 'use_custom_cash_flow')):
			from erpnext.accounts.report.cash_flow.custom_cash_flow import execute as execute_custom
			return execute_custom(filters=filters)

		data = get_cash_flow_data(fiscal_year, companies, filters)

	return columns, data, message, chart
Esempio n. 5
0
def execute(filters=None):
    if cint(
            frappe.db.get_single_value('Accounts Settings',
                                       'use_custom_cash_flow')):
        from erpnext.accounts.report.cash_flow.custom_cash_flow import execute as execute_custom
        return execute_custom(filters=filters)

    period_list = get_period_list(filters.from_fiscal_year,
                                  filters.to_fiscal_year, filters.periodicity,
                                  filters.accumulated_values, filters.company)

    operation_accounts = {
        "section_name":
        "Operations",
        "section_footer":
        _("Net Cash from Operations"),
        "section_header":
        _("Cash Flow from Operations"),
        "account_types": [{
            "account_type": "Depreciation",
            "label": _("Depreciation")
        }, {
            "account_type": "Receivable",
            "label": _("Net Change in Accounts Receivable")
        }, {
            "account_type": "Payable",
            "label": _("Net Change in Accounts Payable")
        }, {
            "account_type": "Stock",
            "label": _("Net Change in Inventory")
        }]
    }

    investing_accounts = {
        "section_name":
        "Investing",
        "section_footer":
        _("Net Cash from Investing"),
        "section_header":
        _("Cash Flow from Investing"),
        "account_types": [{
            "account_type": "Fixed Asset",
            "label": _("Net Change in Fixed Asset")
        }]
    }

    financing_accounts = {
        "section_name":
        "Financing",
        "section_footer":
        _("Net Cash from Financing"),
        "section_header":
        _("Cash Flow from Financing"),
        "account_types": [{
            "account_type": "Equity",
            "label": _("Net Change in Equity")
        }]
    }

    # combine all cash flow accounts for iteration
    cash_flow_accounts = [
        operation_accounts, investing_accounts, financing_accounts
    ]

    # compute net profit / loss
    income = get_data(filters.company,
                      "Income",
                      "Credit",
                      period_list,
                      accumulated_values=filters.accumulated_values,
                      ignore_closing_entries=True,
                      ignore_accumulated_values_for_fy=True)
    expense = get_data(filters.company,
                       "Expense",
                       "Debit",
                       period_list,
                       accumulated_values=filters.accumulated_values,
                       ignore_closing_entries=True,
                       ignore_accumulated_values_for_fy=True)

    net_profit_loss = get_net_profit_loss(income, expense, period_list,
                                          filters.company)

    data = []
    company_currency = frappe.db.get_value("Company", filters.company,
                                           "default_currency")

    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":
                    operation_accounts['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(
                filters.company, account['account_type'], period_list,
                filters.accumulated_values)
            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'], period_list,
                              company_currency)

    add_total_row_account(data, data, _("Net Change in Cash"), period_list,
                          company_currency)
    columns = get_columns(filters.periodicity, period_list,
                          filters.accumulated_values, filters.company)

    return columns, data