frappe.provide("erpnext.financial_statements"); erpnext.financial_statements = { "filters": [ { "fieldname":"company", "label": __("Company"), "fieldtype": "Link", "options": "Company", "default": frappe.defaults.get_user_default("Company"), "reqd": 1 }, { "fieldname":"fiscal_year", "label": __("Fiscal Year"), "fieldtype": "Link", "options": "Fiscal Year", "default": frappe.defaults.get_user_default("fiscal_year"), "reqd": 1 }, { "fieldname": "periodicity", "label": __("Periodicity"), "fieldtype": "Select", "options": [ { "value": "Monthly", "label": __("Monthly") }, { "value": "Quarterly", "label": __("Quarterly") }, { "value": "Half-Yearly", "label": __("Half-Yearly") }, { "value": "Yearly", "label": __("Yearly") } ], "default": "Yearly", "reqd": 1 } ], "formatter": function(row, cell, value, columnDef, dataContext, default_formatter) { if (columnDef.df.fieldname=="account") { value = dataContext.account_name; columnDef.df.link_onclick = "erpnext.financial_statements.open_general_ledger(" + JSON.stringify(dataContext) + ")"; columnDef.df.is_tree = true; } value = default_formatter(row, cell, value, columnDef, dataContext); if (!dataContext.parent_account) { var $value = $(value).css("font-weight", "bold"); if (dataContext.warn_if_negative && dataContext[columnDef.df.fieldname] < 0) { $value.addClass("text-danger"); } value = $value.wrap("
").parent().html(); } return value; }, "open_general_ledger": function(data) { if (!data.account) return; frappe.route_options = { "account": data.account, "company": frappe.query_report.filters_by_name.company.get_value(), "from_date": data.from_date || data.year_start_date, "to_date": data.to_date || data.year_end_date }; frappe.set_route("query-report", "General Ledger"); }, "tree": true, "name_field": "account", "parent_field": "parent_account", "initial_depth": 3, onload: function(report) { // dropdown for links to other financial statements report.page.add_inner_button(__("Balance Sheet"), function() { var filters = report.get_values(); frappe.set_route('query-report', 'Balance Sheet', {company: filters.company}); }, 'Financial Statements'); report.page.add_inner_button(__("Profit and Loss"), function() { var filters = report.get_values(); frappe.set_route('query-report', 'Profit and Loss Statement', {company: filters.company}); }, 'Financial Statements'); report.page.add_inner_button(__("Cash Flow Statement"), function() { var filters = report.get_values(); frappe.set_route('query-report', 'Cash Flow', {company: filters.company}); }, 'Financial Statements'); }, };