blob: 206be3c287b668c1356241f9cf4c5c161ffd3cfb [file] [log] [blame]
Anand Doshi825d0142014-07-18 18:05:26 +05301frappe.provide("erpnext.financial_statements");
2
3erpnext.financial_statements = {
4 "filters": [
5 {
6 "fieldname":"company",
7 "label": __("Company"),
8 "fieldtype": "Link",
9 "options": "Company",
Nabin Haitb6b56452015-12-23 16:37:00 +053010 "default": frappe.defaults.get_user_default("Company"),
Anand Doshi825d0142014-07-18 18:05:26 +053011 "reqd": 1
12 },
13 {
14 "fieldname":"fiscal_year",
15 "label": __("Fiscal Year"),
16 "fieldtype": "Link",
17 "options": "Fiscal Year",
18 "default": frappe.defaults.get_user_default("fiscal_year"),
19 "reqd": 1
20 },
21 {
22 "fieldname": "periodicity",
23 "label": __("Periodicity"),
24 "fieldtype": "Select",
Rushabh Mehtaeb961372016-01-04 15:48:37 +053025 "options": [
26 { "value": "Monthly", "label": __("Monthly") },
27 { "value": "Quarterly", "label": __("Quarterly") },
28 { "value": "Half-Yearly", "label": __("Half-Yearly") },
29 { "value": "Yearly", "label": __("Yearly") }
30 ],
Anand Doshi825d0142014-07-18 18:05:26 +053031 "default": "Yearly",
32 "reqd": 1
Anand Doshi825d0142014-07-18 18:05:26 +053033 }
34 ],
Anand Doshicb86d592014-07-22 19:02:11 +053035 "formatter": function(row, cell, value, columnDef, dataContext, default_formatter) {
Anand Doshi825d0142014-07-18 18:05:26 +053036 if (columnDef.df.fieldname=="account") {
Anand Doshicb86d592014-07-22 19:02:11 +053037 value = dataContext.account_name;
Anand Doshi825d0142014-07-18 18:05:26 +053038
Anand Doshicb86d592014-07-22 19:02:11 +053039 columnDef.df.link_onclick = "erpnext.financial_statements.open_general_ledger(" + JSON.stringify(dataContext) + ")";
40 columnDef.df.is_tree = true;
Anand Doshi825d0142014-07-18 18:05:26 +053041 }
42
Anand Doshicb86d592014-07-22 19:02:11 +053043 value = default_formatter(row, cell, value, columnDef, dataContext);
44
Anand Doshi825d0142014-07-18 18:05:26 +053045 if (!dataContext.parent_account) {
Anand Doshi5f0459c2014-07-21 16:13:06 +053046 var $value = $(value).css("font-weight", "bold");
Anand Doshicb86d592014-07-22 19:02:11 +053047 if (dataContext.warn_if_negative && dataContext[columnDef.df.fieldname] < 0) {
Anand Doshi5f0459c2014-07-21 16:13:06 +053048 $value.addClass("text-danger");
49 }
50
51 value = $value.wrap("<p></p>").parent().html();
Anand Doshi825d0142014-07-18 18:05:26 +053052 }
53
54 return value;
55 },
Anand Doshi5f0459c2014-07-21 16:13:06 +053056 "open_general_ledger": function(data) {
57 if (!data.account) return;
Anand Doshi825d0142014-07-18 18:05:26 +053058
59 frappe.route_options = {
Anand Doshi5f0459c2014-07-21 16:13:06 +053060 "account": data.account,
61 "company": frappe.query_report.filters_by_name.company.get_value(),
Anand Doshicb86d592014-07-22 19:02:11 +053062 "from_date": data.from_date,
63 "to_date": data.to_date
Anand Doshi825d0142014-07-18 18:05:26 +053064 };
65 frappe.set_route("query-report", "General Ledger");
Anand Doshicb86d592014-07-22 19:02:11 +053066 },
67 "tree": true,
68 "name_field": "account",
69 "parent_field": "parent_account",
70 "initial_depth": 3
Anand Doshi825d0142014-07-18 18:05:26 +053071};