From ed67a85887fba3b706623d5973a4bb057b0acfea Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Sat, 18 Nov 2023 09:04:36 +0530 Subject: [PATCH] refactor: provision to set `remarks` length in accounts settings --- .../accounts_settings/accounts_settings.json | 38 ++++++++++++++++++- .../report/general_ledger/general_ledger.py | 7 +++- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 061bab320e65..84fdc83f6800 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -66,7 +66,12 @@ "show_balance_in_coa", "banking_tab", "enable_party_matching", - "enable_fuzzy_matching" + "enable_fuzzy_matching", + "reports_tab", + "general_ledger_section", + "general_ledger_remarks_length", + "accounts_receivable_payable_section", + "receivable_payable_remarks_length" ], "fields": [ { @@ -422,6 +427,35 @@ "fieldname": "round_row_wise_tax", "fieldtype": "Check", "label": "Round Tax Amount Row-wise" + }, + { + "fieldname": "reports_tab", + "fieldtype": "Tab Break", + "label": "Reports" + }, + { + "fieldname": "general_ledger_section", + "fieldtype": "Section Break", + "label": "General Ledger" + }, + { + "default": "0", + "description": "Truncates 'Remarks' column to set character length", + "fieldname": "general_ledger_remarks_length", + "fieldtype": "Int", + "label": "Remarks Length" + }, + { + "default": "0", + "description": "Truncates 'Remarks' column to set character length", + "fieldname": "receivable_payable_remarks_length", + "fieldtype": "Int", + "label": "Remarks Length" + }, + { + "fieldname": "accounts_receivable_payable_section", + "fieldtype": "Section Break", + "label": "Accounts Receivable/Payable" } ], "icon": "icon-cog", @@ -429,7 +463,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2023-08-28 00:12:02.740633", + "modified": "2023-11-18 10:30:00.001071", "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index 94cd29361532..fa557a133f09 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -164,7 +164,12 @@ def get_gl_entries(filters, accounting_dimensions): credit_in_account_currency """ if filters.get("show_remarks"): - select_fields += """,remarks""" + if remarks_length := frappe.db.get_single_value( + "Accounts Settings", "general_ledger_remarks_length" + ): + select_fields += f",substr(remarks, 1, {remarks_length}) as 'remarks'" + else: + select_fields += """,remarks""" order_by_statement = "order by posting_date, account, creation"