Пример #1
0
def execute(filters=None):
	if not filters.periodicity: filters.periodicity = "Monthly"
	period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
		filters.period_start_date, filters.period_end_date, filters.filter_based_on,
		filters.periodicity, company=filters.company)

	mappers = get_mappers_from_db()

	cash_flow_accounts = setup_mappers(mappers)

	# 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)

	company_currency = frappe.get_cached_value('Company',  filters.company,  "default_currency")

	data = compute_data(filters, company_currency, net_profit_loss, period_list, mappers, cash_flow_accounts)

	_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
Пример #2
0
def execute(filters=None):
    period_list = get_period_list(filters.from_fiscal_year,
                                  filters.to_fiscal_year,
                                  filters.period_start_date,
                                  filters.period_end_date,
                                  filters.filter_based_on,
                                  filters.periodicity,
                                  company=filters.company)

    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,
                                          filters.presentation_currency)

    data = []
    data.extend(income or [])
    data.extend(expense or [])
    if net_profit_loss:
        data.append(net_profit_loss)

    columns = get_columns(filters.periodicity, period_list,
                          filters.accumulated_values, filters.company)

    chart = get_chart_data(filters, columns, income, expense, net_profit_loss)

    currency = filters.presentation_currency or frappe.get_cached_value(
        'Company', filters.company, "default_currency")
    report_summary = get_report_summary(period_list, filters.periodicity,
                                        income, expense, net_profit_loss,
                                        currency)

    return columns, data, None, chart, report_summary
Пример #3
0
def execute(filters=None):
    if cint(
            frappe.db.get_single_value('Accounts Settings',
                                       'use_custom_cash_flow')):
        from erpbee.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.period_start_date,
                                  filters.period_end_date,
                                  filters.filter_based_on,
                                  filters.periodicity,
                                  company=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 = []
    summary_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, 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'], period_list,
                              company_currency, summary_data)

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

    chart = get_chart_data(columns, data)

    report_summary = get_report_summary(summary_data, company_currency)

    return columns, data, None, chart, report_summary
Пример #4
0
def execute(filters=None):
    period_list = get_period_list(filters.from_fiscal_year,
                                  filters.to_fiscal_year,
                                  filters.period_start_date,
                                  filters.period_end_date,
                                  filters.filter_based_on, filters.periodicity,
                                  filters.accumulated_values, filters.company)

    columns, data = [], []

    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,
                      total=False)

    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,
                       total=False)

    columns = get_columns(filters.periodicity, period_list,
                          filters.accumulated_values, filters.company)

    gross_income = get_revenue(income, period_list)
    gross_expense = get_revenue(expense, period_list)

    if (len(gross_income) == 0 and len(gross_expense) == 0):
        data.append({
            "account_name": "'" + _("Nothing is included in gross") + "'",
            "account": "'" + _("Nothing is included in gross") + "'"
        })
        return columns, data

    # to avoid error eg: gross_income[0] : list index out of range
    if not gross_income:
        gross_income = [{}]
    if not gross_expense:
        gross_expense = [{}]

    data.append({
        "account_name": "'" + _("Included in Gross Profit") + "'",
        "account": "'" + _("Included in Gross Profit") + "'"
    })

    data.append({})
    data.extend(gross_income or [])

    data.append({})
    data.extend(gross_expense or [])

    data.append({})
    gross_profit = get_profit(gross_income, gross_expense, period_list,
                              filters.company, 'Gross Profit',
                              filters.presentation_currency)
    data.append(gross_profit)

    non_gross_income = get_revenue(income, period_list, 0)
    data.append({})
    data.extend(non_gross_income or [])

    non_gross_expense = get_revenue(expense, period_list, 0)
    data.append({})
    data.extend(non_gross_expense or [])

    net_profit = get_net_profit(non_gross_income, gross_income, gross_expense,
                                non_gross_expense, period_list,
                                filters.company, filters.presentation_currency)
    data.append({})
    data.append(net_profit)

    return columns, data
Пример #5
0
def execute(filters=None):
    period_list = get_period_list(filters.from_fiscal_year,
                                  filters.to_fiscal_year,
                                  filters.period_start_date,
                                  filters.period_end_date,
                                  filters.filter_based_on,
                                  filters.periodicity,
                                  company=filters.company)

    currency = filters.presentation_currency or frappe.get_cached_value(
        'Company', filters.company, "default_currency")

    asset = get_data(filters.company,
                     "Asset",
                     "Debit",
                     period_list,
                     only_current_fiscal_year=False,
                     filters=filters,
                     accumulated_values=filters.accumulated_values)

    liability = get_data(filters.company,
                         "Liability",
                         "Credit",
                         period_list,
                         only_current_fiscal_year=False,
                         filters=filters,
                         accumulated_values=filters.accumulated_values)

    equity = get_data(filters.company,
                      "Equity",
                      "Credit",
                      period_list,
                      only_current_fiscal_year=False,
                      filters=filters,
                      accumulated_values=filters.accumulated_values)

    provisional_profit_loss, total_credit = get_provisional_profit_loss(
        asset, liability, equity, period_list, filters.company, currency)

    message, opening_balance = check_opening_balance(asset, liability, equity)

    data = []
    data.extend(asset or [])
    data.extend(liability or [])
    data.extend(equity or [])
    if opening_balance and round(opening_balance, 2) != 0:
        unclosed = {
            "account_name":
            "'" + _("Unclosed Fiscal Years Profit / Loss (Credit)") + "'",
            "account":
            "'" + _("Unclosed Fiscal Years Profit / Loss (Credit)") + "'",
            "warn_if_negative":
            True,
            "currency":
            currency
        }
        for period in period_list:
            unclosed[period.key] = opening_balance
            if provisional_profit_loss:
                provisional_profit_loss[period.key] = provisional_profit_loss[
                    period.key] - opening_balance

        unclosed["total"] = opening_balance
        data.append(unclosed)

    if provisional_profit_loss:
        data.append(provisional_profit_loss)
    if total_credit:
        data.append(total_credit)

    columns = get_columns(filters.periodicity,
                          period_list,
                          filters.accumulated_values,
                          company=filters.company)

    chart = get_chart_data(filters, columns, asset, liability, equity)

    report_summary = get_report_summary(period_list, asset, liability, equity,
                                        provisional_profit_loss, total_credit,
                                        currency, filters)

    return columns, data, message, chart, report_summary