blob: 9a1a05afaa9cc03bad470a7796ccf23ad05a8911 [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",
10 "default": frappe.defaults.get_user_default("company"),
11 "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",
25 "options": "Yearly\nHalf-yearly\nQuarterly\nMonthly",
26 "default": "Yearly",
27 "reqd": 1
Anand Doshi825d0142014-07-18 18:05:26 +053028 }
29 ],
Anand Doshicb86d592014-07-22 19:02:11 +053030 "formatter": function(row, cell, value, columnDef, dataContext, default_formatter) {
Anand Doshi825d0142014-07-18 18:05:26 +053031 if (columnDef.df.fieldname=="account") {
Anand Doshicb86d592014-07-22 19:02:11 +053032 value = dataContext.account_name;
Anand Doshi825d0142014-07-18 18:05:26 +053033
Anand Doshicb86d592014-07-22 19:02:11 +053034 columnDef.df.link_onclick = "erpnext.financial_statements.open_general_ledger(" + JSON.stringify(dataContext) + ")";
35 columnDef.df.is_tree = true;
Anand Doshi825d0142014-07-18 18:05:26 +053036 }
37
Anand Doshicb86d592014-07-22 19:02:11 +053038 value = default_formatter(row, cell, value, columnDef, dataContext);
39
Anand Doshi825d0142014-07-18 18:05:26 +053040 if (!dataContext.parent_account) {
Anand Doshi5f0459c2014-07-21 16:13:06 +053041 var $value = $(value).css("font-weight", "bold");
Anand Doshicb86d592014-07-22 19:02:11 +053042 if (dataContext.warn_if_negative && dataContext[columnDef.df.fieldname] < 0) {
Anand Doshi5f0459c2014-07-21 16:13:06 +053043 $value.addClass("text-danger");
44 }
45
46 value = $value.wrap("<p></p>").parent().html();
Anand Doshi825d0142014-07-18 18:05:26 +053047 }
48
49 return value;
50 },
Anand Doshi5f0459c2014-07-21 16:13:06 +053051 "open_general_ledger": function(data) {
52 if (!data.account) return;
Anand Doshi825d0142014-07-18 18:05:26 +053053
54 frappe.route_options = {
Anand Doshi5f0459c2014-07-21 16:13:06 +053055 "account": data.account,
56 "company": frappe.query_report.filters_by_name.company.get_value(),
Anand Doshicb86d592014-07-22 19:02:11 +053057 "from_date": data.from_date,
58 "to_date": data.to_date
Anand Doshi825d0142014-07-18 18:05:26 +053059 };
60 frappe.set_route("query-report", "General Ledger");
Anand Doshicb86d592014-07-22 19:02:11 +053061 },
62 "tree": true,
63 "name_field": "account",
64 "parent_field": "parent_account",
65 "initial_depth": 3
Anand Doshi825d0142014-07-18 18:05:26 +053066};