mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-07 23:31:20 +00:00
fix: General Ledger translation issues (#27298)
* fix: remove translations from GL report options
Options need not be translated, their display label gets translated
client side.
* fix: make group by options translatable
* ci: semgrep rule for translated options in report
Co-authored-by: Ankush Menat <ankush@iwebnotes.com>
(cherry picked from commit fa819f2fb0)
# Conflicts:
# .github/helper/semgrep_rules/report.yml
# erpnext/accounts/report/general_ledger/general_ledger.py
This commit is contained in:
34
.github/helper/semgrep_rules/report.yml
vendored
Normal file
34
.github/helper/semgrep_rules/report.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
rules:
|
||||
- id: frappe-missing-translate-function-in-report-python
|
||||
paths:
|
||||
include:
|
||||
- "**/report"
|
||||
exclude:
|
||||
- "**/regional"
|
||||
pattern-either:
|
||||
- patterns:
|
||||
- pattern: |
|
||||
{..., "label": "...", ...}
|
||||
- pattern-not: |
|
||||
{..., "label": _("..."), ...}
|
||||
- patterns:
|
||||
- pattern: dict(..., label="...", ...)
|
||||
- pattern-not: dict(..., label=_("..."), ...)
|
||||
message: |
|
||||
All user facing text must be wrapped in translate function. Please refer to translation documentation. https://frappeframework.com/docs/user/en/guides/basics/translations
|
||||
languages: [python]
|
||||
severity: ERROR
|
||||
|
||||
- id: frappe-translated-values-in-business-logic
|
||||
paths:
|
||||
include:
|
||||
- "**/report"
|
||||
patterns:
|
||||
- pattern-inside: |
|
||||
{..., filters: [...], ...}
|
||||
- pattern: |
|
||||
{..., options: [..., __("..."), ...], ...}
|
||||
message: |
|
||||
Using translated values in options field will require you to translate the values while comparing in business logic. Instead of passing translated labels provide objects that contain both label and value. e.g. { label: __("Option value"), value: "Option value"}
|
||||
languages: [javascript]
|
||||
severity: ERROR
|
||||
@@ -73,13 +73,23 @@ def validate_filters(filters, account_details):
|
||||
if not account_details.get(account):
|
||||
frappe.throw(_("Account {0} does not exists").format(account))
|
||||
|
||||
<<<<<<< HEAD
|
||||
if filters.get("account") and filters.get("group_by") == "Group by Account":
|
||||
filters.account = frappe.parse_json(filters.get("account"))
|
||||
=======
|
||||
if (filters.get("account") and filters.get("group_by") == 'Group by Account'):
|
||||
filters.account = frappe.parse_json(filters.get('account'))
|
||||
>>>>>>> fa819f2fb0 (fix: General Ledger translation issues (#27298))
|
||||
for account in filters.account:
|
||||
if account_details[account].is_group == 0:
|
||||
frappe.throw(_("Can not filter based on Child Account, if grouped by Account"))
|
||||
|
||||
<<<<<<< HEAD
|
||||
if filters.get("voucher_no") and filters.get("group_by") in ["Group by Voucher"]:
|
||||
=======
|
||||
if (filters.get("voucher_no")
|
||||
and filters.get("group_by") in ['Group by Voucher']):
|
||||
>>>>>>> fa819f2fb0 (fix: General Ledger translation issues (#27298))
|
||||
frappe.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
|
||||
|
||||
if filters.from_date > filters.to_date:
|
||||
@@ -359,7 +369,11 @@ def get_data_with_opening_closing(filters, account_details, accounting_dimension
|
||||
# Opening for filtered account
|
||||
data.append(totals.opening)
|
||||
|
||||
<<<<<<< HEAD
|
||||
if filters.get("group_by") != "Group by Voucher (Consolidated)":
|
||||
=======
|
||||
if filters.get("group_by") != 'Group by Voucher (Consolidated)':
|
||||
>>>>>>> fa819f2fb0 (fix: General Ledger translation issues (#27298))
|
||||
for acc, acc_dict in iteritems(gle_map):
|
||||
# acc
|
||||
if acc_dict.entries:
|
||||
@@ -407,10 +421,17 @@ def get_totals_dict():
|
||||
|
||||
|
||||
def group_by_field(group_by):
|
||||
<<<<<<< HEAD
|
||||
if group_by == "Group by Party":
|
||||
return "party"
|
||||
elif group_by in ["Group by Voucher (Consolidated)", "Group by Account"]:
|
||||
return "account"
|
||||
=======
|
||||
if group_by == 'Group by Party':
|
||||
return 'party'
|
||||
elif group_by in ['Group by Voucher (Consolidated)', 'Group by Account']:
|
||||
return 'account'
|
||||
>>>>>>> fa819f2fb0 (fix: General Ledger translation issues (#27298))
|
||||
else:
|
||||
return "voucher_no"
|
||||
|
||||
@@ -500,6 +521,19 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map):
|
||||
keylist.append(gle.get(dim))
|
||||
keylist.append(gle.get("cost_center"))
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
elif gle.posting_date <= to_date:
|
||||
update_value_in_dict(gle_map[gle.get(group_by)].totals, 'total', gle)
|
||||
update_value_in_dict(totals, 'total', gle)
|
||||
if filters.get("group_by") != 'Group by Voucher (Consolidated)':
|
||||
gle_map[gle.get(group_by)].entries.append(gle)
|
||||
elif filters.get("group_by") == 'Group by Voucher (Consolidated)':
|
||||
keylist = [gle.get("voucher_type"), gle.get("voucher_no"), gle.get("account")]
|
||||
for dim in accounting_dimensions:
|
||||
keylist.append(gle.get(dim))
|
||||
keylist.append(gle.get("cost_center"))
|
||||
>>>>>>> fa819f2fb0 (fix: General Ledger translation issues (#27298))
|
||||
key = tuple(keylist)
|
||||
if key not in consolidated_gle:
|
||||
consolidated_gle.setdefault(key, gle)
|
||||
|
||||
Reference in New Issue
Block a user