fix: renaming group by fieldname and value in reports (backport #47352) (#47360)

* fix: renaming group by fieldname and value in reports (#47352)

* fix: renaming in general ledger report

* fix: renaming in supplier quotation comparison report

* fix: renaming group by to categorize by in process statement of accounts

* fix: added patch

* fix: patch update to all documents

* chore: added patches to patch.txt

* chore: removing patch from v14

(cherry picked from commit 13a84e7f82)

# Conflicts:
#	erpnext/accounts/doctype/process_statement_of_accounts/process_statement_of_accounts.json

* chore: resolve conflict

---------

Co-authored-by: Diptanil Saha <diptanil@frappe.io>
This commit is contained in:
mergify[bot]
2025-04-30 17:19:43 +05:30
committed by GitHub
parent d3445b3079
commit 85a8adf804
9 changed files with 77 additions and 54 deletions

View File

@@ -12,7 +12,7 @@
"posting_date", "posting_date",
"company", "company",
"account", "account",
"group_by", "categorize_by",
"cost_center", "cost_center",
"territory", "territory",
"ignore_exchange_rate_revaluation_journals", "ignore_exchange_rate_revaluation_journals",
@@ -174,14 +174,6 @@
"fieldtype": "Date", "fieldtype": "Date",
"label": "Start Date" "label": "Start Date"
}, },
{
"default": "Group by Voucher (Consolidated)",
"depends_on": "eval:(doc.report == 'General Ledger');",
"fieldname": "group_by",
"fieldtype": "Select",
"label": "Group By",
"options": "\nGroup by Voucher\nGroup by Voucher (Consolidated)"
},
{ {
"depends_on": "eval: (doc.report == 'General Ledger');", "depends_on": "eval: (doc.report == 'General Ledger');",
"fieldname": "currency", "fieldname": "currency",
@@ -397,10 +389,18 @@
"fieldname": "show_remarks", "fieldname": "show_remarks",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Show Remarks" "label": "Show Remarks"
},
{
"default": "Categorize by Voucher (Consolidated)",
"depends_on": "eval:(doc.report == 'General Ledger');",
"fieldname": "categorize_by",
"fieldtype": "Select",
"label": "Categorize By",
"options": "\nCategorize by Voucher\nCategorize by Voucher (Consolidated)"
} }
], ],
"links": [], "links": [],
"modified": "2024-12-11 12:11:13.543134", "modified": "2025-04-30 14:43:23.643006",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Process Statement Of Accounts", "name": "Process Statement Of Accounts",
@@ -436,4 +436,4 @@
"sort_order": "DESC", "sort_order": "DESC",
"states": [], "states": [],
"track_changes": 1 "track_changes": 1
} }

View File

@@ -44,6 +44,7 @@ class ProcessStatementOfAccounts(Document):
ageing_based_on: DF.Literal["Due Date", "Posting Date"] ageing_based_on: DF.Literal["Due Date", "Posting Date"]
based_on_payment_terms: DF.Check based_on_payment_terms: DF.Check
body: DF.TextEditor | None body: DF.TextEditor | None
categorize_by: DF.Literal["", "Categorize by Voucher", "Categorize by Voucher (Consolidated)"]
cc_to: DF.TableMultiSelect[ProcessStatementOfAccountsCC] cc_to: DF.TableMultiSelect[ProcessStatementOfAccountsCC]
collection_name: DF.DynamicLink | None collection_name: DF.DynamicLink | None
company: DF.Link company: DF.Link
@@ -56,7 +57,6 @@ class ProcessStatementOfAccounts(Document):
finance_book: DF.Link | None finance_book: DF.Link | None
frequency: DF.Literal["Weekly", "Monthly", "Quarterly"] frequency: DF.Literal["Weekly", "Monthly", "Quarterly"]
from_date: DF.Date | None from_date: DF.Date | None
group_by: DF.Literal["", "Group by Voucher", "Group by Voucher (Consolidated)"]
ignore_cr_dr_notes: DF.Check ignore_cr_dr_notes: DF.Check
ignore_exchange_rate_revaluation_journals: DF.Check ignore_exchange_rate_revaluation_journals: DF.Check
include_ageing: DF.Check include_ageing: DF.Check
@@ -204,7 +204,7 @@ def get_gl_filters(doc, entry, tax_id, presentation_currency):
"party": [entry.customer], "party": [entry.customer],
"party_name": [entry.customer_name] if entry.customer_name else None, "party_name": [entry.customer_name] if entry.customer_name else None,
"presentation_currency": presentation_currency, "presentation_currency": presentation_currency,
"group_by": doc.group_by, "categorize_by": doc.categorize_by,
"currency": doc.currency, "currency": doc.currency,
"project": [p.project_name for p in doc.project], "project": [p.project_name for p in doc.project],
"show_opening_entries": 0, "show_opening_entries": 0,

View File

@@ -49,7 +49,7 @@ frappe.query_reports["General Ledger"] = {
label: __("Voucher No"), label: __("Voucher No"),
fieldtype: "Data", fieldtype: "Data",
on_change: function () { on_change: function () {
frappe.query_report.set_filter_value("group_by", "Group by Voucher (Consolidated)"); frappe.query_report.set_filter_value("categorize_by", "Categorize by Voucher (Consolidated)");
}, },
}, },
{ {
@@ -112,29 +112,29 @@ frappe.query_reports["General Ledger"] = {
hidden: 1, hidden: 1,
}, },
{ {
fieldname: "group_by", fieldname: "categorize_by",
label: __("Group by"), label: __("Categorize by"),
fieldtype: "Select", fieldtype: "Select",
options: [ options: [
"", "",
{ {
label: __("Group by Voucher"), label: __("Categorize by Voucher"),
value: "Group by Voucher", value: "Categorize by Voucher",
}, },
{ {
label: __("Group by Voucher (Consolidated)"), label: __("Categorize by Voucher (Consolidated)"),
value: "Group by Voucher (Consolidated)", value: "Categorize by Voucher (Consolidated)",
}, },
{ {
label: __("Group by Account"), label: __("Categorize by Account"),
value: "Group by Account", value: "Categorize by Account",
}, },
{ {
label: __("Group by Party"), label: __("Categorize by Party"),
value: "Group by Party", value: "Categorize by Party",
}, },
], ],
default: "Group by Voucher (Consolidated)", default: "Categorize by Voucher (Consolidated)",
}, },
{ {
fieldname: "tax_id", fieldname: "tax_id",

View File

@@ -63,13 +63,13 @@ def validate_filters(filters, account_details):
if not account_details.get(account): if not account_details.get(account):
frappe.throw(_("Account {0} does not exists").format(account)) frappe.throw(_("Account {0} does not exists").format(account))
if filters.get("account") and filters.get("group_by") == "Group by Account": if filters.get("account") and filters.get("categorize_by") == "Categorize by Account":
filters.account = frappe.parse_json(filters.get("account")) filters.account = frappe.parse_json(filters.get("account"))
for account in filters.account: for account in filters.account:
if account_details[account].is_group == 0: if account_details[account].is_group == 0:
frappe.throw(_("Can not filter based on Child Account, if grouped by Account")) frappe.throw(_("Can not filter based on Child Account, if grouped by Account"))
if filters.get("voucher_no") and filters.get("group_by") in ["Group by Voucher"]: if filters.get("voucher_no") and filters.get("categorize_by") in ["Categorize by Voucher"]:
frappe.throw(_("Can not filter based on Voucher No, if grouped by Voucher")) frappe.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
if filters.from_date > filters.to_date: if filters.from_date > filters.to_date:
@@ -163,9 +163,9 @@ def get_gl_entries(filters, accounting_dimensions):
if filters.get("include_dimensions"): if filters.get("include_dimensions"):
order_by_statement = "order by posting_date, creation" order_by_statement = "order by posting_date, creation"
if filters.get("group_by") == "Group by Voucher": if filters.get("categorize_by") == "Categorize by Voucher":
order_by_statement = "order by posting_date, voucher_type, voucher_no" order_by_statement = "order by posting_date, voucher_type, voucher_no"
if filters.get("group_by") == "Group by Account": if filters.get("categorize_by") == "Categorize by Account":
order_by_statement = "order by account, posting_date, creation" order_by_statement = "order by account, posting_date, creation"
if filters.get("include_default_book_entries"): if filters.get("include_default_book_entries"):
@@ -260,7 +260,7 @@ def get_conditions(filters):
if filters.get("voucher_no_not_in"): if filters.get("voucher_no_not_in"):
conditions.append("voucher_no not in %(voucher_no_not_in)s") conditions.append("voucher_no not in %(voucher_no_not_in)s")
if filters.get("group_by") == "Group by Party" and not filters.get("party_type"): if filters.get("categorize_by") == "Categorize by Party" and not filters.get("party_type"):
conditions.append("party_type in ('Customer', 'Supplier')") conditions.append("party_type in ('Customer', 'Supplier')")
if filters.get("party_type"): if filters.get("party_type"):
@@ -272,7 +272,7 @@ def get_conditions(filters):
if not ( if not (
filters.get("account") filters.get("account")
or filters.get("party") or filters.get("party")
or filters.get("group_by") in ["Group by Account", "Group by Party"] or filters.get("categorize_by") in ["Categorize by Account", "Categorize by Party"]
): ):
if not ignore_is_opening: if not ignore_is_opening:
conditions.append("(posting_date >=%(from_date)s or is_opening = 'Yes')") conditions.append("(posting_date >=%(from_date)s or is_opening = 'Yes')")
@@ -374,26 +374,26 @@ def get_data_with_opening_closing(filters, account_details, accounting_dimension
# Opening for filtered account # Opening for filtered account
data.append(totals.opening) data.append(totals.opening)
if filters.get("group_by") != "Group by Voucher (Consolidated)": if filters.get("categorize_by") != "Categorize by Voucher (Consolidated)":
for _acc, acc_dict in gle_map.items(): for _acc, acc_dict in gle_map.items():
# acc # acc
if acc_dict.entries: if acc_dict.entries:
# opening # opening
data.append({"debit_in_transaction_currency": None, "credit_in_transaction_currency": None}) data.append({"debit_in_transaction_currency": None, "credit_in_transaction_currency": None})
if (not filters.get("group_by") and not filters.get("voucher_no")) or ( if (not filters.get("categorize_by") and not filters.get("voucher_no")) or (
filters.get("group_by") and filters.get("group_by") != "Group by Voucher" filters.get("categorize_by") and filters.get("categorize_by") != "Categorize by Voucher"
): ):
data.append(acc_dict.totals.opening) data.append(acc_dict.totals.opening)
data += acc_dict.entries data += acc_dict.entries
# totals # totals
if filters.get("group_by") or not filters.voucher_no: if filters.get("categorize_by") or not filters.voucher_no:
data.append(acc_dict.totals.total) data.append(acc_dict.totals.total)
# closing # closing
if (not filters.get("group_by") and not filters.get("voucher_no")) or ( if (not filters.get("categorize_by") and not filters.get("voucher_no")) or (
filters.get("group_by") and filters.get("group_by") != "Group by Voucher" filters.get("categorize_by") and filters.get("categorize_by") != "Categorize by Voucher"
): ):
data.append(acc_dict.totals.closing) data.append(acc_dict.totals.closing)
@@ -430,9 +430,9 @@ def get_totals_dict():
def group_by_field(group_by): def group_by_field(group_by):
if group_by == "Group by Party": if group_by == "Categorize by Party":
return "party" return "party"
elif group_by in ["Group by Voucher (Consolidated)", "Group by Account"]: elif group_by in ["Categorize by Voucher (Consolidated)", "Categorize by Account"]:
return "account" return "account"
else: else:
return "voucher_no" return "voucher_no"
@@ -440,7 +440,7 @@ def group_by_field(group_by):
def initialize_gle_map(gl_entries, filters, totals_dict): def initialize_gle_map(gl_entries, filters, totals_dict):
gle_map = OrderedDict() gle_map = OrderedDict()
group_by = group_by_field(filters.get("group_by")) group_by = group_by_field(filters.get("categorize_by"))
for gle in gl_entries: for gle in gl_entries:
gle_map.setdefault(gle.get(group_by), _dict(totals=copy.deepcopy(totals_dict), entries=[])) gle_map.setdefault(gle.get(group_by), _dict(totals=copy.deepcopy(totals_dict), entries=[]))
@@ -450,8 +450,8 @@ def initialize_gle_map(gl_entries, filters, totals_dict):
def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map, totals): def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map, totals):
entries = [] entries = []
consolidated_gle = OrderedDict() consolidated_gle = OrderedDict()
group_by = group_by_field(filters.get("group_by")) group_by = group_by_field(filters.get("categorize_by"))
group_by_voucher_consolidated = filters.get("group_by") == "Group by Voucher (Consolidated)" group_by_voucher_consolidated = filters.get("categorize_by") == "Categorize by Voucher (Consolidated)"
if filters.get("show_net_values_in_party_account"): if filters.get("show_net_values_in_party_account"):
account_type_map = get_account_type_map(filters.get("company")) account_type_map = get_account_type_map(filters.get("company"))

View File

@@ -155,7 +155,7 @@ class TestGeneralLedger(FrappeTestCase):
"from_date": today(), "from_date": today(),
"to_date": today(), "to_date": today(),
"account": [account.name], "account": [account.name],
"group_by": "Group by Voucher (Consolidated)", "categorize_by": "Categorize by Voucher (Consolidated)",
} }
) )
) )
@@ -246,7 +246,7 @@ class TestGeneralLedger(FrappeTestCase):
"from_date": today(), "from_date": today(),
"to_date": today(), "to_date": today(),
"account": [account.name], "account": [account.name],
"group_by": "Group by Voucher (Consolidated)", "categorize_by": "Categorize by Voucher (Consolidated)",
"ignore_err": True, "ignore_err": True,
} }
) )
@@ -261,7 +261,7 @@ class TestGeneralLedger(FrappeTestCase):
"from_date": today(), "from_date": today(),
"to_date": today(), "to_date": today(),
"account": [account.name], "account": [account.name],
"group_by": "Group by Voucher (Consolidated)", "categorize_by": "Categorize by Voucher (Consolidated)",
"ignore_err": False, "ignore_err": False,
} }
) )
@@ -308,7 +308,7 @@ class TestGeneralLedger(FrappeTestCase):
"from_date": si.posting_date, "from_date": si.posting_date,
"to_date": si.posting_date, "to_date": si.posting_date,
"account": [si.debit_to], "account": [si.debit_to],
"group_by": "Group by Voucher (Consolidated)", "categorize_by": "Categorize by Voucher (Consolidated)",
"ignore_cr_dr_notes": False, "ignore_cr_dr_notes": False,
} }
) )
@@ -325,7 +325,7 @@ class TestGeneralLedger(FrappeTestCase):
"from_date": si.posting_date, "from_date": si.posting_date,
"to_date": si.posting_date, "to_date": si.posting_date,
"account": [si.debit_to], "account": [si.debit_to],
"group_by": "Group by Voucher (Consolidated)", "categorize_by": "Categorize by Voucher (Consolidated)",
"ignore_cr_dr_notes": True, "ignore_cr_dr_notes": True,
} }
) )

View File

@@ -76,14 +76,14 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
}, },
}, },
{ {
fieldname: "group_by", fieldname: "categorize_by",
label: __("Group by"), label: __("Categorize by"),
fieldtype: "Select", fieldtype: "Select",
options: [ options: [
{ label: __("Group by Supplier"), value: "Group by Supplier" }, { label: __("Categorize by Supplier"), value: "Categorize by Supplier" },
{ label: __("Group by Item"), value: "Group by Item" }, { label: __("Categorize by Item"), value: "Categorize by Item" },
], ],
default: __("Group by Supplier"), default: __("Categorize by Supplier"),
}, },
{ {
fieldtype: "Check", fieldtype: "Check",

View File

@@ -82,7 +82,9 @@ def prepare_data(supplier_quotation_data, filters):
group_wise_map = defaultdict(list) group_wise_map = defaultdict(list)
supplier_qty_price_map = {} supplier_qty_price_map = {}
group_by_field = "supplier_name" if filters.get("group_by") == "Group by Supplier" else "item_code" group_by_field = (
"supplier_name" if filters.get("categorize_by") == "Categorize by Supplier" else "item_code"
)
float_precision = cint(frappe.db.get_default("float_precision")) or 2 float_precision = cint(frappe.db.get_default("float_precision")) or 2
for data in supplier_quotation_data: for data in supplier_quotation_data:
@@ -266,7 +268,7 @@ def get_columns(filters):
}, },
] ]
if filters.get("group_by") == "Group by Item": if filters.get("categorize_by") == "Categorize by Item":
group_by_columns.reverse() group_by_columns.reverse()
columns[0:0] = group_by_columns # add positioned group by columns to the report columns[0:0] = group_by_columns # add positioned group by columns to the report

View File

@@ -402,3 +402,4 @@ erpnext.patches.v15_0.recalculate_amount_difference_field #2025-03-18
erpnext.patches.v15_0.rename_sla_fields #2025-03-12 erpnext.patches.v15_0.rename_sla_fields #2025-03-12
erpnext.patches.v15_0.set_purchase_receipt_row_item_to_capitalization_stock_item erpnext.patches.v15_0.set_purchase_receipt_row_item_to_capitalization_stock_item
erpnext.patches.v15_0.update_payment_schedule_fields_in_invoices erpnext.patches.v15_0.update_payment_schedule_fields_in_invoices
erpnext.patches.v15_0.rename_group_by_to_categorize_by

View File

@@ -0,0 +1,20 @@
import frappe
from frappe.model.utils.rename_field import rename_field
def execute():
rename_field("Process Statement Of Accounts", "group_by", "categorize_by")
frappe.db.sql(
"""
UPDATE
`tabProcess Statement Of Accounts`
SET
categorize_by = CASE
WHEN categorize_by = 'Group by Voucher (Consolidated)' THEN 'Categorize by Voucher (Consolidated)'
WHEN categorize_by = 'Group by Voucher' THEN 'Categorize by Voucher'
END
WHERE
categorize_by IN ('Group by Voucher (Consolidated)', 'Group by Voucher')
"""
)