From c66d57d4906ccc6eaa908052f135fbb1f8bf0e97 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 26 Nov 2024 15:33:04 +0530 Subject: [PATCH 1/3] fix: broken export on statements --- erpnext/accounts/report/financial_statements.py | 2 +- erpnext/public/js/financial_statements.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 2b8f93d6996..44b74463336 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -619,7 +619,7 @@ def get_cost_centers_with_children(cost_centers): def get_columns(periodicity, period_list, accumulated_values=1, company=None, cash_flow=False): columns = [ { - "fieldname": "stub", + "fieldname": "account", "label": _("Account") if not cash_flow else _("Section"), "fieldtype": "Link", "options": "Account", diff --git a/erpnext/public/js/financial_statements.js b/erpnext/public/js/financial_statements.js index 5ad879f639a..1d323ccd46e 100644 --- a/erpnext/public/js/financial_statements.js +++ b/erpnext/public/js/financial_statements.js @@ -33,7 +33,7 @@ erpnext.financial_statements = { return value; } else if (frappe.query_report.get_filter_value("selected_view") == "Margin" && data) { - if (column.fieldname == "stub" && data.account_name == __("Income")) { + if (column.fieldname == "account" && data.account_name == __("Income")) { //Taking the total income from each column (for all the financial years) as the base (100%) this.baseData = row; } @@ -52,7 +52,7 @@ erpnext.financial_statements = { } } - if (data && column.fieldname == "stub") { + if (data && column.fieldname == "account") { // first column value = data.section_name || data.account_name || value; From 1da61a43e771580d503305c8b0f13031f30af54e Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 26 Nov 2024 15:48:46 +0530 Subject: [PATCH 2/3] chore: remove debugging statement --- erpnext/accounts/report/cash_flow/cash_flow.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py index 562ac5efb81..bdc4083cedb 100644 --- a/erpnext/accounts/report/cash_flow/cash_flow.py +++ b/erpnext/accounts/report/cash_flow/cash_flow.py @@ -263,7 +263,6 @@ def get_report_summary(summary_data, currency): def get_chart_data(columns, data, currency): labels = [d.get("label") for d in columns[2:]] - print(data) datasets = [ { "name": section.get("section").replace("'", ""), From ea6e022fada87e6027e10e5144215161ee22ecd6 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 26 Nov 2024 16:36:18 +0530 Subject: [PATCH 3/3] test: export functionality on P&L statement --- .../test_profit_and_loss_statement.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/erpnext/accounts/report/profit_and_loss_statement/test_profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/test_profit_and_loss_statement.py index 82c530cdc78..7e2d4a7afe0 100644 --- a/erpnext/accounts/report/profit_and_loss_statement/test_profit_and_loss_statement.py +++ b/erpnext/accounts/report/profit_and_loss_statement/test_profit_and_loss_statement.py @@ -2,6 +2,7 @@ # MIT License. See license.txt import frappe +from frappe.desk.query_report import export_query from frappe.tests import IntegrationTestCase from frappe.utils import getdate, today @@ -90,3 +91,21 @@ class TestProfitAndLossStatement(AccountsTestMixin, IntegrationTestCase): with self.subTest(current_period_key=current_period_key): self.assertEqual(acc[current_period_key], 150) self.assertEqual(acc["total"], 150) + + def test_p_and_l_export(self): + self.create_sales_invoice(qty=1, rate=150) + + filters = self.get_report_filters() + frappe.local.form_dict = frappe._dict( + { + "report_name": "Profit and Loss Statement", + "file_format_type": "CSV", + "filters": filters, + "visible_idx": [0, 1, 2, 3, 4, 5, 6], + } + ) + export_query() + contents = frappe.response["filecontent"].decode() + sales_account = frappe.db.get_value("Company", self.company, "default_income_account") + + self.assertIn(sales_account, contents)