mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-06 15:00:27 +00:00
chore: minor fix
This commit is contained in:
@@ -203,21 +203,6 @@ class FormattingRule:
|
|||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
|
||||||
FILTER_LABELS = {
|
|
||||||
"report_template": _("Report Template"),
|
|
||||||
"filter_based_on": _("Filter Based On"),
|
|
||||||
"period_start_date": _("Start Date"),
|
|
||||||
"period_end_date": _("End Date"),
|
|
||||||
"from_fiscal_year": _("Start Year"),
|
|
||||||
"to_fiscal_year": _("End Year"),
|
|
||||||
}
|
|
||||||
|
|
||||||
REQUIRED_FILTERS_BY_BASIS = {
|
|
||||||
"Date Range": ("period_start_date", "period_end_date"),
|
|
||||||
"Fiscal Year": ("from_fiscal_year", "to_fiscal_year"),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class FinancialReportEngine:
|
class FinancialReportEngine:
|
||||||
def execute(self, filters: dict[str, Any]) -> tuple[list[dict], list[dict]]:
|
def execute(self, filters: dict[str, Any]) -> tuple[list[dict], list[dict]]:
|
||||||
"""Execute the complete report generation"""
|
"""Execute the complete report generation"""
|
||||||
@@ -237,15 +222,29 @@ class FinancialReportEngine:
|
|||||||
return context.get_result()
|
return context.get_result()
|
||||||
|
|
||||||
def _validate_filters(self, filters: dict[str, Any]) -> None:
|
def _validate_filters(self, filters: dict[str, Any]) -> None:
|
||||||
|
filter_labels = {
|
||||||
|
"report_template": _("Report Template"),
|
||||||
|
"filter_based_on": _("Filter Based On"),
|
||||||
|
"period_start_date": _("Start Date"),
|
||||||
|
"period_end_date": _("End Date"),
|
||||||
|
"from_fiscal_year": _("Start Year"),
|
||||||
|
"to_fiscal_year": _("End Year"),
|
||||||
|
}
|
||||||
|
|
||||||
|
required_filters_by_basis = {
|
||||||
|
"Date Range": ("period_start_date", "period_end_date"),
|
||||||
|
"Fiscal Year": ("from_fiscal_year", "to_fiscal_year"),
|
||||||
|
}
|
||||||
|
|
||||||
required_filters = ["report_template", "filter_based_on"]
|
required_filters = ["report_template", "filter_based_on"]
|
||||||
required_filters.extend(REQUIRED_FILTERS_BY_BASIS.get(filters.get("filter_based_on"), ()))
|
required_filters.extend(required_filters_by_basis.get(filters.get("filter_based_on"), ()))
|
||||||
|
|
||||||
for filter_key in required_filters:
|
for filter_key in required_filters:
|
||||||
if not filters.get(filter_key):
|
if not filters.get(filter_key):
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
title=_("Missing Required Filter"),
|
title=_("Missing Required Filter"),
|
||||||
msg=_("Missing required filter: {0}").format(
|
msg=_("Missing required filter: {0}").format(
|
||||||
frappe.bold(FILTER_LABELS.get(filter_key, filter_key))
|
frappe.bold(filter_labels.get(filter_key, filter_key))
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user