feat: account name and number columns on financial statements report on export (#48630)

* feat: account name and number columns on trial balance report on export

* feat: account name and number columns on financial statement reports on export

* test: fixed test_profit_and_loss_output_and_summary for new columns
This commit is contained in:
Diptanil Saha
2025-07-16 15:24:43 +05:30
committed by GitHub
6 changed files with 44 additions and 2 deletions

View File

@@ -30,3 +30,5 @@ frappe.query_reports["Balance Sheet"]["filters"].push({
fieldtype: "Check",
default: 1,
});
frappe.query_reports["Balance Sheet"]["export_hidden_cols"] = true;

View File

@@ -295,6 +295,8 @@ def prepare_data(accounts, balance_must_be, period_list, company_currency, accum
"account_name": (
f"{_(d.account_number)} - {_(d.account_name)}" if d.account_number else _(d.account_name)
),
"acc_name": d.account_name,
"acc_number": d.account_number,
}
)
for period in period_list:
@@ -650,6 +652,25 @@ def get_columns(periodicity, period_list, accumulated_values=1, company=None, ca
"width": 300,
}
]
if not cash_flow:
columns.extend(
[
{
"fieldname": "acc_name",
"label": _("Account Name"),
"fieldtype": "Data",
"width": 250,
"hidden": 1,
},
{
"fieldname": "acc_number",
"label": _("Account Number"),
"fieldtype": "Data",
"width": 120,
"hidden": 1,
},
]
)
if company:
columns.append(
{

View File

@@ -31,3 +31,5 @@ frappe.query_reports["Profit and Loss Statement"]["filters"].push({
fieldtype: "Check",
default: 1,
});
frappe.query_reports["Profit and Loss Statement"]["export_hidden_cols"] = true;

View File

@@ -142,7 +142,7 @@ class TestProfitAndLossStatement(AccountsTestMixin, IntegrationTestCase):
accumulated_values=False,
)
result = execute(filters)
columns = [result[0][2], result[0][3]]
columns = [result[0][4], result[0][5]]
expected = {
"account": income_acc,
columns[0].get("fieldname"): 450.0,
@@ -163,7 +163,7 @@ class TestProfitAndLossStatement(AccountsTestMixin, IntegrationTestCase):
columns[1].get("fieldname"): 570.0,
}
result = execute(filters)
columns = [result[0][2], result[0][3]]
columns = [result[0][4], result[0][5]]
actual = [x for x in result[1] if x.get("account") == income_acc]
self.assertEqual(len(actual), 1)
actual = actual[0]

View File

@@ -122,6 +122,7 @@ frappe.query_reports["Trial Balance"] = {
tree: true,
name_field: "account",
parent_field: "parent_account",
export_hidden_cols: true,
initial_depth: 3,
};

View File

@@ -402,6 +402,8 @@ def prepare_data(accounts, filters, parent_children_map, company_currency):
"to_date": filters.to_date,
"currency": company_currency,
"is_group_account": d.is_group,
"acc_name": d.account_name,
"acc_number": d.account_number,
"account_name": (
f"{d.account_number} - {d.account_name}" if d.account_number else d.account_name
),
@@ -436,6 +438,20 @@ def get_columns():
"options": "Account",
"width": 300,
},
{
"fieldname": "acc_name",
"label": _("Account Name"),
"fieldtype": "Data",
"hidden": 1,
"width": 250,
},
{
"fieldname": "acc_number",
"label": _("Account Number"),
"fieldtype": "Data",
"hidden": 1,
"width": 120,
},
{
"fieldname": "currency",
"label": _("Currency"),