2014-07-18 12:35:26 +00:00
|
|
|
frappe.provide("erpnext.financial_statements");
|
|
|
|
|
|
|
|
erpnext.financial_statements = {
|
|
|
|
"filters": [
|
|
|
|
{
|
|
|
|
"fieldname":"company",
|
|
|
|
"label": __("Company"),
|
|
|
|
"fieldtype": "Link",
|
|
|
|
"options": "Company",
|
2015-12-23 11:07:00 +00:00
|
|
|
"default": frappe.defaults.get_user_default("Company"),
|
2014-07-18 12:35:26 +00:00
|
|
|
"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",
|
2016-01-04 10:18:37 +00:00
|
|
|
"options": [
|
|
|
|
{ "value": "Monthly", "label": __("Monthly") },
|
|
|
|
{ "value": "Quarterly", "label": __("Quarterly") },
|
|
|
|
{ "value": "Half-Yearly", "label": __("Half-Yearly") },
|
|
|
|
{ "value": "Yearly", "label": __("Yearly") }
|
|
|
|
],
|
2016-05-20 06:14:08 +00:00
|
|
|
"default": "Monthly",
|
2014-07-18 12:35:26 +00:00
|
|
|
"reqd": 1
|
2016-02-02 13:35:30 +00:00
|
|
|
}
|
2014-07-18 12:35:26 +00:00
|
|
|
],
|
2014-07-22 13:32:11 +00:00
|
|
|
"formatter": function(row, cell, value, columnDef, dataContext, default_formatter) {
|
2014-07-18 12:35:26 +00:00
|
|
|
if (columnDef.df.fieldname=="account") {
|
2014-07-22 13:32:11 +00:00
|
|
|
value = dataContext.account_name;
|
2014-07-18 12:35:26 +00:00
|
|
|
|
2016-02-16 06:26:53 +00:00
|
|
|
columnDef.df.link_onclick =
|
2016-02-02 13:35:30 +00:00
|
|
|
"erpnext.financial_statements.open_general_ledger(" + JSON.stringify(dataContext) + ")";
|
2014-07-22 13:32:11 +00:00
|
|
|
columnDef.df.is_tree = true;
|
2014-07-18 12:35:26 +00:00
|
|
|
}
|
|
|
|
|
2014-07-22 13:32:11 +00:00
|
|
|
value = default_formatter(row, cell, value, columnDef, dataContext);
|
|
|
|
|
2014-07-18 12:35:26 +00:00
|
|
|
if (!dataContext.parent_account) {
|
2014-07-21 10:43:06 +00:00
|
|
|
var $value = $(value).css("font-weight", "bold");
|
2014-07-22 13:32:11 +00:00
|
|
|
if (dataContext.warn_if_negative && dataContext[columnDef.df.fieldname] < 0) {
|
2014-07-21 10:43:06 +00:00
|
|
|
$value.addClass("text-danger");
|
|
|
|
}
|
|
|
|
|
|
|
|
value = $value.wrap("<p></p>").parent().html();
|
2014-07-18 12:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
},
|
2014-07-21 10:43:06 +00:00
|
|
|
"open_general_ledger": function(data) {
|
|
|
|
if (!data.account) return;
|
2014-07-18 12:35:26 +00:00
|
|
|
|
|
|
|
frappe.route_options = {
|
2014-07-21 10:43:06 +00:00
|
|
|
"account": data.account,
|
|
|
|
"company": frappe.query_report.filters_by_name.company.get_value(),
|
2016-02-16 06:26:53 +00:00
|
|
|
"from_date": data.from_date || data.year_start_date,
|
|
|
|
"to_date": data.to_date || data.year_end_date
|
2014-07-18 12:35:26 +00:00
|
|
|
};
|
|
|
|
frappe.set_route("query-report", "General Ledger");
|
2014-07-22 13:32:11 +00:00
|
|
|
},
|
|
|
|
"tree": true,
|
|
|
|
"name_field": "account",
|
|
|
|
"parent_field": "parent_account",
|
2016-04-18 13:57:36 +00:00
|
|
|
"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');
|
2016-05-20 06:14:08 +00:00
|
|
|
}
|
2014-07-18 12:35:26 +00:00
|
|
|
};
|