From 4e2d0aa892739ee06a0681fd5700b07df58379c2 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Sat, 18 Nov 2023 09:04:36 +0530 Subject: [PATCH 1/3] refactor: provision to set `remarks` length in accounts settings (cherry picked from commit 97090ff3679104d77a031f29d4acafb8b7ac1580) # Conflicts: # erpnext/accounts/doctype/accounts_settings/accounts_settings.json --- .../accounts_settings/accounts_settings.json | 44 +++++++++++++++++++ .../report/general_ledger/general_ledger.py | 7 ++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index 3ab9d2b60d5b..d266468d8b92 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -67,8 +67,16 @@ "banking_tab", "enable_party_matching", "enable_fuzzy_matching", +<<<<<<< HEAD "tab_break_dpet", "show_balance_in_coa" +======= + "reports_tab", + "remarks_section", + "general_ledger_remarks_length", + "column_break_lvjk", + "receivable_payable_remarks_length" +>>>>>>> 97090ff367 (refactor: provision to set `remarks` length in accounts settings) ], "fields": [ { @@ -428,7 +436,39 @@ "default": "1", "fieldname": "show_balance_in_coa", "fieldtype": "Check", +<<<<<<< HEAD "label": "Show Balances in Chart Of Accounts" +======= + "label": "Round Tax Amount Row-wise" + }, + { + "fieldname": "reports_tab", + "fieldtype": "Tab Break", + "label": "Reports" + }, + { + "default": "0", + "description": "Truncates 'Remarks' column to set character length", + "fieldname": "general_ledger_remarks_length", + "fieldtype": "Int", + "label": "General Ledger" + }, + { + "default": "0", + "description": "Truncates 'Remarks' column to set character length", + "fieldname": "receivable_payable_remarks_length", + "fieldtype": "Int", + "label": "Accounts Receivable/Payable" + }, + { + "fieldname": "column_break_lvjk", + "fieldtype": "Column Break" + }, + { + "fieldname": "remarks_section", + "fieldtype": "Section Break", + "label": "Remarks Column Length" +>>>>>>> 97090ff367 (refactor: provision to set `remarks` length in accounts settings) } ], "icon": "icon-cog", @@ -436,7 +476,11 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], +<<<<<<< HEAD "modified": "2023-07-27 15:05:34.000264", +======= + "modified": "2023-11-20 09:37:47.650347", +>>>>>>> 97090ff367 (refactor: provision to set `remarks` length in accounts settings) "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 754f17c118ef..2e0a9c5f738e 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" From ae319760a05058c5e5b4e7ba7c5ddc11c1d2079f Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Sat, 18 Nov 2023 10:35:56 +0530 Subject: [PATCH 2/3] refactor: add substring logic in ar/ap report (cherry picked from commit a9bf906545dc7c89613c7f6211c35e62b8d7b989) --- .../report/accounts_receivable/accounts_receivable.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index c077d829939d..18217f8d3beb 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -7,7 +7,7 @@ import frappe from frappe import _, qb, scrub from frappe.query_builder import Criterion -from frappe.query_builder.functions import Date, Sum +from frappe.query_builder.functions import Date, Substring, Sum from frappe.utils import cint, cstr, flt, getdate, nowdate from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( @@ -762,7 +762,12 @@ def get_ple_entries(self): ) if self.filters.get("show_remarks"): - query = query.select(ple.remarks) + if remarks_length := frappe.db.get_single_value( + "Accounts Settings", "receivable_payable_remarks_length" + ): + query = query.select(Substring(ple.remarks, 1, remarks_length).as_("remarks")) + else: + query = query.select(ple.remarks) if self.filters.get("group_by_party"): query = query.orderby(self.ple.party, self.ple.posting_date) From b868e2bd5b568f3ca27e69d22e7c9ad5cd05eb5d Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 20 Nov 2023 10:18:29 +0530 Subject: [PATCH 3/3] chore: resolve conflicts --- .../accounts_settings/accounts_settings.json | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index d266468d8b92..0370fa2ce87a 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -67,16 +67,13 @@ "banking_tab", "enable_party_matching", "enable_fuzzy_matching", -<<<<<<< HEAD "tab_break_dpet", - "show_balance_in_coa" -======= + "show_balance_in_coa", "reports_tab", "remarks_section", "general_ledger_remarks_length", "column_break_lvjk", "receivable_payable_remarks_length" ->>>>>>> 97090ff367 (refactor: provision to set `remarks` length in accounts settings) ], "fields": [ { @@ -436,10 +433,7 @@ "default": "1", "fieldname": "show_balance_in_coa", "fieldtype": "Check", -<<<<<<< HEAD "label": "Show Balances in Chart Of Accounts" -======= - "label": "Round Tax Amount Row-wise" }, { "fieldname": "reports_tab", @@ -468,7 +462,6 @@ "fieldname": "remarks_section", "fieldtype": "Section Break", "label": "Remarks Column Length" ->>>>>>> 97090ff367 (refactor: provision to set `remarks` length in accounts settings) } ], "icon": "icon-cog", @@ -476,11 +469,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], -<<<<<<< HEAD - "modified": "2023-07-27 15:05:34.000264", -======= "modified": "2023-11-20 09:37:47.650347", ->>>>>>> 97090ff367 (refactor: provision to set `remarks` length in accounts settings) "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings",