Merge pull request #37393 from ruthra-kumar/import_financial_statements_in_bundle
refactor: import 'financial_statements.js' in erpnext bundle
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.js b/erpnext/accounts/report/balance_sheet/balance_sheet.js
index ecc13d7..c2b57f7 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.js
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.js
@@ -1,25 +1,23 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
-frappe.require("assets/erpnext/js/financial_statements.js", function () {
- frappe.query_reports["Balance Sheet"] = $.extend(
- {},
- erpnext.financial_statements
- );
+frappe.query_reports["Balance Sheet"] = $.extend(
+ {},
+ erpnext.financial_statements
+);
- erpnext.utils.add_dimensions("Balance Sheet", 10);
+erpnext.utils.add_dimensions("Balance Sheet", 10);
- frappe.query_reports["Balance Sheet"]["filters"].push({
- fieldname: "accumulated_values",
- label: __("Accumulated Values"),
- fieldtype: "Check",
- default: 1,
- });
+frappe.query_reports["Balance Sheet"]["filters"].push({
+ fieldname: "accumulated_values",
+ label: __("Accumulated Values"),
+ fieldtype: "Check",
+ default: 1,
+});
- frappe.query_reports["Balance Sheet"]["filters"].push({
- fieldname: "include_default_book_entries",
- label: __("Include Default Book Entries"),
- fieldtype: "Check",
- default: 1,
- });
+frappe.query_reports["Balance Sheet"]["filters"].push({
+ fieldname: "include_default_book_entries",
+ label: __("Include Default Book Entries"),
+ fieldtype: "Check",
+ default: 1,
});
diff --git a/erpnext/accounts/report/cash_flow/cash_flow.js b/erpnext/accounts/report/cash_flow/cash_flow.js
index a2c34c6..6b8ed27 100644
--- a/erpnext/accounts/report/cash_flow/cash_flow.js
+++ b/erpnext/accounts/report/cash_flow/cash_flow.js
@@ -1,24 +1,24 @@
// Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.require("assets/erpnext/js/financial_statements.js", function() {
- frappe.query_reports["Cash Flow"] = $.extend({},
- erpnext.financial_statements);
+frappe.query_reports["Cash Flow"] = $.extend(
+ {},
+ erpnext.financial_statements
+);
- erpnext.utils.add_dimensions('Cash Flow', 10);
+erpnext.utils.add_dimensions('Cash Flow', 10);
- // The last item in the array is the definition for Presentation Currency
- // filter. It won't be used in cash flow for now so we pop it. Please take
- // of this if you are working here.
+// The last item in the array is the definition for Presentation Currency
+// filter. It won't be used in cash flow for now so we pop it. Please take
+// of this if you are working here.
- frappe.query_reports["Cash Flow"]["filters"].splice(8, 1);
+frappe.query_reports["Cash Flow"]["filters"].splice(8, 1);
- frappe.query_reports["Cash Flow"]["filters"].push(
- {
- "fieldname": "include_default_book_entries",
- "label": __("Include Default Book Entries"),
- "fieldtype": "Check",
- "default": 1
- }
- );
-});
+frappe.query_reports["Cash Flow"]["filters"].push(
+ {
+ "fieldname": "include_default_book_entries",
+ "label": __("Include Default Book Entries"),
+ "fieldtype": "Check",
+ "default": 1
+ }
+);
diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
index 1afa8d5..590408c 100644
--- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
+++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.js
@@ -2,152 +2,150 @@
// For license information, please see license.txt
-frappe.require("assets/erpnext/js/financial_statements.js", function() {
- frappe.query_reports["Consolidated Financial Statement"] = {
- "filters": [
- {
- "fieldname":"company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "reqd": 1
- },
- {
- "fieldname":"filter_based_on",
- "label": __("Filter Based On"),
- "fieldtype": "Select",
- "options": ["Fiscal Year", "Date Range"],
- "default": ["Fiscal Year"],
- "reqd": 1,
- on_change: function() {
- let filter_based_on = frappe.query_report.get_filter_value('filter_based_on');
- frappe.query_report.toggle_filter_display('from_fiscal_year', filter_based_on === 'Date Range');
- frappe.query_report.toggle_filter_display('to_fiscal_year', filter_based_on === 'Date Range');
- frappe.query_report.toggle_filter_display('period_start_date', filter_based_on === 'Fiscal Year');
- frappe.query_report.toggle_filter_display('period_end_date', filter_based_on === 'Fiscal Year');
-
- frappe.query_report.refresh();
- }
- },
- {
- "fieldname":"period_start_date",
- "label": __("Start Date"),
- "fieldtype": "Date",
- "hidden": 1,
- "reqd": 1
- },
- {
- "fieldname":"period_end_date",
- "label": __("End Date"),
- "fieldtype": "Date",
- "hidden": 1,
- "reqd": 1
- },
- {
- "fieldname":"from_fiscal_year",
- "label": __("Start Year"),
- "fieldtype": "Link",
- "options": "Fiscal Year",
- "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
- "reqd": 1,
- on_change: () => {
- frappe.model.with_doc("Fiscal Year", frappe.query_report.get_filter_value('from_fiscal_year'), function(r) {
- let year_start_date = frappe.model.get_value("Fiscal Year", frappe.query_report.get_filter_value('from_fiscal_year'), "year_start_date");
- frappe.query_report.set_filter_value({
- period_start_date: year_start_date
- });
- });
- }
- },
- {
- "fieldname":"to_fiscal_year",
- "label": __("End Year"),
- "fieldtype": "Link",
- "options": "Fiscal Year",
- "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
- "reqd": 1,
- on_change: () => {
- frappe.model.with_doc("Fiscal Year", frappe.query_report.get_filter_value('to_fiscal_year'), function(r) {
- let year_end_date = frappe.model.get_value("Fiscal Year", frappe.query_report.get_filter_value('to_fiscal_year'), "year_end_date");
- frappe.query_report.set_filter_value({
- period_end_date: year_end_date
- });
- });
- }
- },
- {
- "fieldname":"finance_book",
- "label": __("Finance Book"),
- "fieldtype": "Link",
- "options": "Finance Book"
- },
- {
- "fieldname":"report",
- "label": __("Report"),
- "fieldtype": "Select",
- "options": ["Profit and Loss Statement", "Balance Sheet", "Cash Flow"],
- "default": "Balance Sheet",
- "reqd": 1
- },
- {
- "fieldname": "presentation_currency",
- "label": __("Currency"),
- "fieldtype": "Select",
- "options": erpnext.get_presentation_currency_list(),
- "default": frappe.defaults.get_user_default("Currency")
- },
- {
- "fieldname":"accumulated_in_group_company",
- "label": __("Accumulated Values in Group Company"),
- "fieldtype": "Check",
- "default": 0
- },
- {
- "fieldname": "include_default_book_entries",
- "label": __("Include Default Book Entries"),
- "fieldtype": "Check",
- "default": 1
- },
- {
- "fieldname": "show_zero_values",
- "label": __("Show zero values"),
- "fieldtype": "Check"
- }
- ],
- "formatter": function(value, row, column, data, default_formatter) {
- if (data && column.fieldname=="account") {
- value = data.account_name || value;
-
- column.link_onclick =
- "erpnext.financial_statements.open_general_ledger(" + JSON.stringify(data) + ")";
- column.is_tree = true;
- }
-
- if (data && data.account && column.apply_currency_formatter) {
- data.currency = erpnext.get_currency(column.company_name);
- }
-
- value = default_formatter(value, row, column, data);
- if (!data.parent_account) {
- value = $(`<span>${value}</span>`);
-
- var $value = $(value).css("font-weight", "bold");
-
- value = $value.wrap("<p></p>").parent().html();
- }
- return value;
+frappe.query_reports["Consolidated Financial Statement"] = {
+ "filters": [
+ {
+ "fieldname":"company",
+ "label": __("Company"),
+ "fieldtype": "Link",
+ "options": "Company",
+ "default": frappe.defaults.get_user_default("Company"),
+ "reqd": 1
},
- onload: function() {
- let fiscal_year = erpnext.utils.get_fiscal_year(frappe.datetime.get_today());
+ {
+ "fieldname":"filter_based_on",
+ "label": __("Filter Based On"),
+ "fieldtype": "Select",
+ "options": ["Fiscal Year", "Date Range"],
+ "default": ["Fiscal Year"],
+ "reqd": 1,
+ on_change: function() {
+ let filter_based_on = frappe.query_report.get_filter_value('filter_based_on');
+ frappe.query_report.toggle_filter_display('from_fiscal_year', filter_based_on === 'Date Range');
+ frappe.query_report.toggle_filter_display('to_fiscal_year', filter_based_on === 'Date Range');
+ frappe.query_report.toggle_filter_display('period_start_date', filter_based_on === 'Fiscal Year');
+ frappe.query_report.toggle_filter_display('period_end_date', filter_based_on === 'Fiscal Year');
- frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
- var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
- frappe.query_report.set_filter_value({
- period_start_date: fy.year_start_date,
- period_end_date: fy.year_end_date
+ frappe.query_report.refresh();
+ }
+ },
+ {
+ "fieldname":"period_start_date",
+ "label": __("Start Date"),
+ "fieldtype": "Date",
+ "hidden": 1,
+ "reqd": 1
+ },
+ {
+ "fieldname":"period_end_date",
+ "label": __("End Date"),
+ "fieldtype": "Date",
+ "hidden": 1,
+ "reqd": 1
+ },
+ {
+ "fieldname":"from_fiscal_year",
+ "label": __("Start Year"),
+ "fieldtype": "Link",
+ "options": "Fiscal Year",
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
+ "reqd": 1,
+ on_change: () => {
+ frappe.model.with_doc("Fiscal Year", frappe.query_report.get_filter_value('from_fiscal_year'), function(r) {
+ let year_start_date = frappe.model.get_value("Fiscal Year", frappe.query_report.get_filter_value('from_fiscal_year'), "year_start_date");
+ frappe.query_report.set_filter_value({
+ period_start_date: year_start_date
+ });
});
- });
+ }
+ },
+ {
+ "fieldname":"to_fiscal_year",
+ "label": __("End Year"),
+ "fieldtype": "Link",
+ "options": "Fiscal Year",
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
+ "reqd": 1,
+ on_change: () => {
+ frappe.model.with_doc("Fiscal Year", frappe.query_report.get_filter_value('to_fiscal_year'), function(r) {
+ let year_end_date = frappe.model.get_value("Fiscal Year", frappe.query_report.get_filter_value('to_fiscal_year'), "year_end_date");
+ frappe.query_report.set_filter_value({
+ period_end_date: year_end_date
+ });
+ });
+ }
+ },
+ {
+ "fieldname":"finance_book",
+ "label": __("Finance Book"),
+ "fieldtype": "Link",
+ "options": "Finance Book"
+ },
+ {
+ "fieldname":"report",
+ "label": __("Report"),
+ "fieldtype": "Select",
+ "options": ["Profit and Loss Statement", "Balance Sheet", "Cash Flow"],
+ "default": "Balance Sheet",
+ "reqd": 1
+ },
+ {
+ "fieldname": "presentation_currency",
+ "label": __("Currency"),
+ "fieldtype": "Select",
+ "options": erpnext.get_presentation_currency_list(),
+ "default": frappe.defaults.get_user_default("Currency")
+ },
+ {
+ "fieldname":"accumulated_in_group_company",
+ "label": __("Accumulated Values in Group Company"),
+ "fieldtype": "Check",
+ "default": 0
+ },
+ {
+ "fieldname": "include_default_book_entries",
+ "label": __("Include Default Book Entries"),
+ "fieldtype": "Check",
+ "default": 1
+ },
+ {
+ "fieldname": "show_zero_values",
+ "label": __("Show zero values"),
+ "fieldtype": "Check"
}
+ ],
+ "formatter": function(value, row, column, data, default_formatter) {
+ if (data && column.fieldname=="account") {
+ value = data.account_name || value;
+
+ column.link_onclick =
+ "erpnext.financial_statements.open_general_ledger(" + JSON.stringify(data) + ")";
+ column.is_tree = true;
+ }
+
+ if (data && data.account && column.apply_currency_formatter) {
+ data.currency = erpnext.get_currency(column.company_name);
+ }
+
+ value = default_formatter(value, row, column, data);
+ if (!data.parent_account) {
+ value = $(`<span>${value}</span>`);
+
+ var $value = $(value).css("font-weight", "bold");
+
+ value = $value.wrap("<p></p>").parent().html();
+ }
+ return value;
+ },
+ onload: function() {
+ let fiscal_year = erpnext.utils.get_fiscal_year(frappe.datetime.get_today());
+
+ frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
+ var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
+ frappe.query_report.set_filter_value({
+ period_start_date: fy.year_start_date,
+ period_end_date: fy.year_end_date
+ });
+ });
}
-});
+}
diff --git a/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.js b/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.js
index 79e5a09..51fa8c8 100644
--- a/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.js
+++ b/erpnext/accounts/report/dimension_wise_accounts_balance_report/dimension_wise_accounts_balance_report.js
@@ -2,83 +2,81 @@
// For license information, please see license.txt
-frappe.require("assets/erpnext/js/financial_statements.js", function() {
- frappe.query_reports["Dimension-wise Accounts Balance Report"] = {
- "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": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
- "reqd": 1,
- "on_change": function(query_report) {
- var fiscal_year = query_report.get_values().fiscal_year;
- if (!fiscal_year) {
- return;
- }
- frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
- var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
- frappe.query_report.set_filter_value({
- from_date: fy.year_start_date,
- to_date: fy.year_end_date
- });
- });
+frappe.query_reports["Dimension-wise Accounts Balance Report"] = {
+ "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": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
+ "reqd": 1,
+ "on_change": function(query_report) {
+ var fiscal_year = query_report.get_values().fiscal_year;
+ if (!fiscal_year) {
+ return;
}
- },
- {
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
- "reqd": 1
- },
- {
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
- "reqd": 1
- },
- {
- "fieldname": "finance_book",
- "label": __("Finance Book"),
- "fieldtype": "Link",
- "options": "Finance Book",
- },
- {
- "fieldname": "dimension",
- "label": __("Select Dimension"),
- "fieldtype": "Select",
- "default": "Cost Center",
- "options": get_accounting_dimension_options(),
- "reqd": 1,
- },
- ],
- "formatter": erpnext.financial_statements.formatter,
- "tree": true,
- "name_field": "account",
- "parent_field": "parent_account",
- "initial_depth": 3
- }
+ frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
+ var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
+ frappe.query_report.set_filter_value({
+ from_date: fy.year_start_date,
+ to_date: fy.year_end_date
+ });
+ });
+ }
+ },
+ {
+ "fieldname": "from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
+ "reqd": 1
+ },
+ {
+ "fieldname": "to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
+ "reqd": 1
+ },
+ {
+ "fieldname": "finance_book",
+ "label": __("Finance Book"),
+ "fieldtype": "Link",
+ "options": "Finance Book",
+ },
+ {
+ "fieldname": "dimension",
+ "label": __("Select Dimension"),
+ "fieldtype": "Select",
+ "default": "Cost Center",
+ "options": get_accounting_dimension_options(),
+ "reqd": 1,
+ },
+ ],
+ "formatter": erpnext.financial_statements.formatter,
+ "tree": true,
+ "name_field": "account",
+ "parent_field": "parent_account",
+ "initial_depth": 3
+}
-});
function get_accounting_dimension_options() {
let options =["Cost Center", "Project"];
frappe.db.get_list('Accounting Dimension',
- {fields:['document_type']}).then((res) => {
- res.forEach((dimension) => {
- options.push(dimension.document_type);
- });
- });
+ {fields:['document_type']}).then((res) => {
+ res.forEach((dimension) => {
+ options.push(dimension.document_type);
+ });
+ });
return options
}
diff --git a/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.js b/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.js
index f6b0b8c..40d4259 100644
--- a/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.js
+++ b/erpnext/accounts/report/gross_and_net_profit_report/gross_and_net_profit_report.js
@@ -2,20 +2,15 @@
// For license information, please see license.txt
-frappe.query_reports["Gross and Net Profit Report"] = {
- "filters": [
+frappe.query_reports["Gross and Net Profit Report"] = $.extend(
+ {},
+ erpnext.financial_statements
+);
- ]
-}
-frappe.require("assets/erpnext/js/financial_statements.js", function() {
- frappe.query_reports["Gross and Net Profit Report"] = $.extend({},
- erpnext.financial_statements);
-
- frappe.query_reports["Gross and Net Profit Report"]["filters"].push(
- {
- "fieldname": "accumulated_values",
- "label": __("Accumulated Values"),
- "fieldtype": "Check"
- }
- );
-});
+frappe.query_reports["Gross and Net Profit Report"]["filters"].push(
+ {
+ "fieldname": "accumulated_values",
+ "label": __("Accumulated Values"),
+ "fieldtype": "Check"
+ }
+);
diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
index 9fe93b9..e5898bf 100644
--- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
+++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.js
@@ -1,18 +1,16 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
-frappe.require("assets/erpnext/js/financial_statements.js", function () {
- frappe.query_reports["Profit and Loss Statement"] = $.extend(
- {},
- erpnext.financial_statements
- );
+frappe.query_reports["Profit and Loss Statement"] = $.extend(
+ {},
+ erpnext.financial_statements
+);
- erpnext.utils.add_dimensions("Profit and Loss Statement", 10);
+erpnext.utils.add_dimensions("Profit and Loss Statement", 10);
- frappe.query_reports["Profit and Loss Statement"]["filters"].push({
- fieldname: "accumulated_values",
- label: __("Accumulated Values"),
- fieldtype: "Check",
- default: 1,
- });
+frappe.query_reports["Profit and Loss Statement"]["filters"].push({
+ fieldname: "accumulated_values",
+ label: __("Accumulated Values"),
+ fieldtype: "Check",
+ default: 1,
});
diff --git a/erpnext/accounts/report/profitability_analysis/profitability_analysis.js b/erpnext/accounts/report/profitability_analysis/profitability_analysis.js
index ebd0ec1..4a3d9bb 100644
--- a/erpnext/accounts/report/profitability_analysis/profitability_analysis.js
+++ b/erpnext/accounts/report/profitability_analysis/profitability_analysis.js
@@ -1,133 +1,131 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
-frappe.require("assets/erpnext/js/financial_statements.js", function() {
- frappe.query_reports["Profitability Analysis"] = {
- "filters": [
- {
- "fieldname": "company",
- "label": __("Company"),
- "fieldtype": "Link",
- "options": "Company",
- "default": frappe.defaults.get_user_default("Company"),
- "reqd": 1
- },
- {
- "fieldname": "based_on",
- "label": __("Based On"),
- "fieldtype": "Select",
- "options": ["Cost Center", "Project", "Accounting Dimension"],
- "default": "Cost Center",
- "reqd": 1,
- "on_change": function(query_report){
- let based_on = query_report.get_values().based_on;
- if(based_on!='Accounting Dimension'){
- frappe.query_report.set_filter_value({
- accounting_dimension: ''
- });
- }
- }
- },
- {
- "fieldname": "accounting_dimension",
- "label": __("Accounting Dimension"),
- "fieldtype": "Link",
- "options": "Accounting Dimension",
- "get_query": () =>{
- return {
- filters: {
- "disabled": 0
- }
- }
- }
- },
- {
- "fieldname": "fiscal_year",
- "label": __("Fiscal Year"),
- "fieldtype": "Link",
- "options": "Fiscal Year",
- "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
- "reqd": 1,
- "on_change": function(query_report) {
- var fiscal_year = query_report.get_values().fiscal_year;
- if (!fiscal_year) {
- return;
- }
- frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
- var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
- frappe.query_report.set_filter_value({
- from_date: fy.year_start_date,
- to_date: fy.year_end_date
- });
+frappe.query_reports["Profitability Analysis"] = {
+ "filters": [
+ {
+ "fieldname": "company",
+ "label": __("Company"),
+ "fieldtype": "Link",
+ "options": "Company",
+ "default": frappe.defaults.get_user_default("Company"),
+ "reqd": 1
+ },
+ {
+ "fieldname": "based_on",
+ "label": __("Based On"),
+ "fieldtype": "Select",
+ "options": ["Cost Center", "Project", "Accounting Dimension"],
+ "default": "Cost Center",
+ "reqd": 1,
+ "on_change": function(query_report){
+ let based_on = query_report.get_values().based_on;
+ if(based_on!='Accounting Dimension'){
+ frappe.query_report.set_filter_value({
+ accounting_dimension: ''
});
}
- },
- {
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
- },
- {
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
- },
- {
- "fieldname": "show_zero_values",
- "label": __("Show zero values"),
- "fieldtype": "Check"
}
- ],
- "formatter": function(value, row, column, data, default_formatter) {
- if (column.fieldname=="account") {
- value = data.account_name;
-
- column.link_onclick =
- "frappe.query_reports['Profitability Analysis'].open_profit_and_loss_statement(" + JSON.stringify(data) + ")";
- column.is_tree = true;
- }
-
- value = default_formatter(value, row, column, data);
-
- if (!data.parent_account && data.based_on != 'project') {
- value = $(`<span>${value}</span>`);
- var $value = $(value).css("font-weight", "bold");
- if (data.warn_if_negative && data[column.fieldname] < 0) {
- $value.addClass("text-danger");
+ },
+ {
+ "fieldname": "accounting_dimension",
+ "label": __("Accounting Dimension"),
+ "fieldtype": "Link",
+ "options": "Accounting Dimension",
+ "get_query": () =>{
+ return {
+ filters: {
+ "disabled": 0
+ }
}
+ }
+ },
+ {
+ "fieldname": "fiscal_year",
+ "label": __("Fiscal Year"),
+ "fieldtype": "Link",
+ "options": "Fiscal Year",
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
+ "reqd": 1,
+ "on_change": function(query_report) {
+ var fiscal_year = query_report.get_values().fiscal_year;
+ if (!fiscal_year) {
+ return;
+ }
+ frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
+ var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
+ frappe.query_report.set_filter_value({
+ from_date: fy.year_start_date,
+ to_date: fy.year_end_date
+ });
+ });
+ }
+ },
+ {
+ "fieldname": "from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
+ },
+ {
+ "fieldname": "to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
+ },
+ {
+ "fieldname": "show_zero_values",
+ "label": __("Show zero values"),
+ "fieldtype": "Check"
+ }
+ ],
+ "formatter": function(value, row, column, data, default_formatter) {
+ if (column.fieldname=="account") {
+ value = data.account_name;
- value = $value.wrap("<p></p>").parent().html();
+ column.link_onclick =
+ "frappe.query_reports['Profitability Analysis'].open_profit_and_loss_statement(" + JSON.stringify(data) + ")";
+ column.is_tree = true;
+ }
+
+ value = default_formatter(value, row, column, data);
+
+ if (!data.parent_account && data.based_on != 'project') {
+ value = $(`<span>${value}</span>`);
+ var $value = $(value).css("font-weight", "bold");
+ if (data.warn_if_negative && data[column.fieldname] < 0) {
+ $value.addClass("text-danger");
}
- return value;
- },
- "open_profit_and_loss_statement": function(data) {
- if (!data.account) return;
+ value = $value.wrap("<p></p>").parent().html();
+ }
- frappe.route_options = {
- "company": frappe.query_report.get_filter_value('company'),
- "from_fiscal_year": data.fiscal_year,
- "to_fiscal_year": data.fiscal_year
- };
+ return value;
+ },
+ "open_profit_and_loss_statement": function(data) {
+ if (!data.account) return;
- if(data.based_on == 'Cost Center'){
- frappe.route_options["cost_center"] = data.account
- } else {
- frappe.route_options["project"] = data.account
- }
+ frappe.route_options = {
+ "company": frappe.query_report.get_filter_value('company'),
+ "from_fiscal_year": data.fiscal_year,
+ "to_fiscal_year": data.fiscal_year
+ };
- frappe.set_route("query-report", "Profit and Loss Statement");
- },
- "tree": true,
- "name_field": "account",
- "parent_field": "parent_account",
- "initial_depth": 3
- }
+ if(data.based_on == 'Cost Center'){
+ frappe.route_options["cost_center"] = data.account
+ } else {
+ frappe.route_options["project"] = data.account
+ }
- erpnext.dimension_filters.forEach((dimension) => {
- frappe.query_reports["Profitability Analysis"].filters[1].options.push(dimension["document_type"]);
- });
+ frappe.set_route("query-report", "Profit and Loss Statement");
+ },
+ "tree": true,
+ "name_field": "account",
+ "parent_field": "parent_account",
+ "initial_depth": 3
+}
+erpnext.dimension_filters.forEach((dimension) => {
+ frappe.query_reports["Profitability Analysis"].filters[1].options.push(dimension["document_type"]);
});
+
diff --git a/erpnext/accounts/report/trial_balance/trial_balance.js b/erpnext/accounts/report/trial_balance/trial_balance.js
index c12ab0f..edd40b6 100644
--- a/erpnext/accounts/report/trial_balance/trial_balance.js
+++ b/erpnext/accounts/report/trial_balance/trial_balance.js
@@ -1,118 +1,116 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
-frappe.require("assets/erpnext/js/financial_statements.js", function() {
- frappe.query_reports["Trial Balance"] = {
- "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": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
- "reqd": 1,
- "on_change": function(query_report) {
- var fiscal_year = query_report.get_values().fiscal_year;
- if (!fiscal_year) {
- return;
- }
- frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
- var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
- frappe.query_report.set_filter_value({
- from_date: fy.year_start_date,
- to_date: fy.year_end_date
- });
+frappe.query_reports["Trial Balance"] = {
+ "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": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
+ "reqd": 1,
+ "on_change": function(query_report) {
+ var fiscal_year = query_report.get_values().fiscal_year;
+ if (!fiscal_year) {
+ return;
+ }
+ frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
+ var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
+ frappe.query_report.set_filter_value({
+ from_date: fy.year_start_date,
+ to_date: fy.year_end_date
});
- }
- },
- {
- "fieldname": "from_date",
- "label": __("From Date"),
- "fieldtype": "Date",
- "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
- },
- {
- "fieldname": "to_date",
- "label": __("To Date"),
- "fieldtype": "Date",
- "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
- },
- {
- "fieldname": "cost_center",
- "label": __("Cost Center"),
- "fieldtype": "Link",
- "options": "Cost Center",
- "get_query": function() {
- var company = frappe.query_report.get_filter_value('company');
- return {
- "doctype": "Cost Center",
- "filters": {
- "company": company,
- }
+ });
+ }
+ },
+ {
+ "fieldname": "from_date",
+ "label": __("From Date"),
+ "fieldtype": "Date",
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[1],
+ },
+ {
+ "fieldname": "to_date",
+ "label": __("To Date"),
+ "fieldtype": "Date",
+ "default": erpnext.utils.get_fiscal_year(frappe.datetime.get_today(), true)[2],
+ },
+ {
+ "fieldname": "cost_center",
+ "label": __("Cost Center"),
+ "fieldtype": "Link",
+ "options": "Cost Center",
+ "get_query": function() {
+ var company = frappe.query_report.get_filter_value('company');
+ return {
+ "doctype": "Cost Center",
+ "filters": {
+ "company": company,
}
}
- },
- {
- "fieldname": "project",
- "label": __("Project"),
- "fieldtype": "Link",
- "options": "Project"
- },
- {
- "fieldname": "finance_book",
- "label": __("Finance Book"),
- "fieldtype": "Link",
- "options": "Finance Book",
- },
- {
- "fieldname": "presentation_currency",
- "label": __("Currency"),
- "fieldtype": "Select",
- "options": erpnext.get_presentation_currency_list()
- },
- {
- "fieldname": "with_period_closing_entry",
- "label": __("Period Closing Entry"),
- "fieldtype": "Check",
- "default": 1
- },
- {
- "fieldname": "show_zero_values",
- "label": __("Show zero values"),
- "fieldtype": "Check"
- },
- {
- "fieldname": "show_unclosed_fy_pl_balances",
- "label": __("Show unclosed fiscal year's P&L balances"),
- "fieldtype": "Check"
- },
- {
- "fieldname": "include_default_book_entries",
- "label": __("Include Default Book Entries"),
- "fieldtype": "Check",
- "default": 1
- },
- {
- "fieldname": "show_net_values",
- "label": __("Show net values in opening and closing columns"),
- "fieldtype": "Check",
- "default": 1
}
- ],
- "formatter": erpnext.financial_statements.formatter,
- "tree": true,
- "name_field": "account",
- "parent_field": "parent_account",
- "initial_depth": 3
- }
+ },
+ {
+ "fieldname": "project",
+ "label": __("Project"),
+ "fieldtype": "Link",
+ "options": "Project"
+ },
+ {
+ "fieldname": "finance_book",
+ "label": __("Finance Book"),
+ "fieldtype": "Link",
+ "options": "Finance Book",
+ },
+ {
+ "fieldname": "presentation_currency",
+ "label": __("Currency"),
+ "fieldtype": "Select",
+ "options": erpnext.get_presentation_currency_list()
+ },
+ {
+ "fieldname": "with_period_closing_entry",
+ "label": __("Period Closing Entry"),
+ "fieldtype": "Check",
+ "default": 1
+ },
+ {
+ "fieldname": "show_zero_values",
+ "label": __("Show zero values"),
+ "fieldtype": "Check"
+ },
+ {
+ "fieldname": "show_unclosed_fy_pl_balances",
+ "label": __("Show unclosed fiscal year's P&L balances"),
+ "fieldtype": "Check"
+ },
+ {
+ "fieldname": "include_default_book_entries",
+ "label": __("Include Default Book Entries"),
+ "fieldtype": "Check",
+ "default": 1
+ },
+ {
+ "fieldname": "show_net_values",
+ "label": __("Show net values in opening and closing columns"),
+ "fieldtype": "Check",
+ "default": 1
+ }
+ ],
+ "formatter": erpnext.financial_statements.formatter,
+ "tree": true,
+ "name_field": "account",
+ "parent_field": "parent_account",
+ "initial_depth": 3
+}
- erpnext.utils.add_dimensions('Trial Balance', 6);
-});
+erpnext.utils.add_dimensions('Trial Balance', 6);
diff --git a/erpnext/public/js/erpnext.bundle.js b/erpnext/public/js/erpnext.bundle.js
index 0e1b23b..dee9a06 100644
--- a/erpnext/public/js/erpnext.bundle.js
+++ b/erpnext/public/js/erpnext.bundle.js
@@ -30,5 +30,6 @@
import "./utils/sales_common.js";
import "./controllers/buying.js";
import "./utils/demo.js";
+import "./financial_statements.js";
// import { sum } from 'frappe/public/utils/util.js'