def get(filters=None): filters = frappe._dict({ "from_fiscal_year" : filters.get("from_fiscal_year"), "to_fiscal_year" : filters.get("to_fiscal_year"), "periodicity": filters.get("periodicity"), "accumulated_values": 1, "company": filters.get("company") }) period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.accumulated_values, 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) columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, filters.company) chart = get_chart_data(filters, columns, income, expense, net_profit_loss) return chart
def get_income_expense_data(companies, fiscal_year, filters, cost_center_wise=False): company_currency = get_company_currency(filters) income = get_data(companies, "Income", "Credit", fiscal_year, filters, ignore_closing_entries=True, cost_center_wise=cost_center_wise) expense = get_data(companies, "Expense", "Debit", fiscal_year, filters, ignore_closing_entries=True, cost_center_wise=cost_center_wise) net_profit_loss = get_net_profit_loss(income, expense, companies, filters.company, company_currency, True) return income, expense, net_profit_loss
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
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.periodicity, filters.accumulated_values, 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
def get_income_expense_data(companies, fiscal_year, filters): company_currency = get_company_currency(filters) income = get_data(companies, "Income", "Credit", fiscal_year, filters, True) expense = get_data(companies, "Expense", "Debit", fiscal_year, filters, True) net_profit_loss = get_net_profit_loss(income, expense, companies, filters.company, company_currency, True) return income, expense, net_profit_loss
def get_income_expense_data(companies, fiscal_year, filters): company_currency = get_company_currency(filters) income = get_data(companies, "Income", "Credit", fiscal_year, filters, True) expense = get_data(companies, "Expense", "Debit", fiscal_year, filters, True) net_profit_loss = get_net_profit_loss(income, expense, companies, filters.company, company_currency, True) return income, expense, net_profit_loss
def get_income_expense_data(companies, fiscal_year, filters): company_currency = frappe.get_cached_value('Company', filters.company, "default_currency") income = get_data(companies, "Income", "Credit", fiscal_year, filters, True) expense = get_data(companies, "Expense", "Debit", fiscal_year, filters, True) net_profit_loss = get_net_profit_loss(income, expense, companies, filters.company, company_currency, True) return income, expense, net_profit_loss
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
def execute(filters=None): period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.accumulated_values, 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) cost_of_goods_entries, expense = extract_cost_of_goods_sold(expense) print(expense[0]) data = [] data.extend(income or []) data.extend(cost_of_goods_entries 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) return columns, data, None, chart
def execute(filters=None): period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, 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 = [] cash_flow_accounts.append(operation_accounts) cash_flow_accounts.append(investing_accounts) cash_flow_accounts.append(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
def execute(filters=None): period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, 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 = [] cash_flow_accounts.append(operation_accounts) cash_flow_accounts.append(investing_accounts) cash_flow_accounts.append(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