chore: minor fix

This commit is contained in:
Abdeali Chharchhoda
2026-04-23 17:13:01 +05:30
parent 1fd6c3ba1a
commit 3854d2cbf6

View File

@@ -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:
def execute(self, filters: dict[str, Any]) -> tuple[list[dict], list[dict]]:
"""Execute the complete report generation"""
@@ -237,15 +222,29 @@ class FinancialReportEngine:
return context.get_result()
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.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:
if not filters.get(filter_key):
frappe.throw(
title=_("Missing Required Filter"),
msg=_("Missing required filter: {0}").format(
frappe.bold(FILTER_LABELS.get(filter_key, filter_key))
frappe.bold(filter_labels.get(filter_key, filter_key))
),
)