@@ -207,6 +207,21 @@ def get_properties(self, row_data: RowData) -> dict[str, Any]:
207207# ============================================================================
208208
209209
210+ FILTER_LABELS = {
211+ "report_template" : _ ("Report Template" ),
212+ "filter_based_on" : _ ("Filter Based On" ),
213+ "period_start_date" : _ ("Start Date" ),
214+ "period_end_date" : _ ("End Date" ),
215+ "from_fiscal_year" : _ ("Start Year" ),
216+ "to_fiscal_year" : _ ("End Year" ),
217+ }
218+
219+ REQUIRED_FILTERS_BY_BASIS = {
220+ "Date Range" : ("period_start_date" , "period_end_date" ),
221+ "Fiscal Year" : ("from_fiscal_year" , "to_fiscal_year" ),
222+ }
223+
224+
210225class FinancialReportEngine :
211226 def execute (self , filters : dict [str , Any ]) -> tuple [list [dict ], list [dict ]]:
212227 """Execute the complete report generation"""
@@ -226,14 +241,24 @@ def execute(self, filters: dict[str, Any]) -> tuple[list[dict], list[dict]]:
226241 return context .get_result ()
227242
228243 def _validate_filters (self , filters : dict [str , Any ]) -> None :
229- required_filters = ["report_template" , "period_start_date" , "period_end_date" ]
244+ required_filters = ["report_template" , "filter_based_on" ]
245+ required_filters .extend (REQUIRED_FILTERS_BY_BASIS .get (filters .get ("filter_based_on" ), ()))
230246
231247 for filter_key in required_filters :
232248 if not filters .get (filter_key ):
233- frappe .throw (_ ("Missing required filter: {0}" ).format (filter_key ))
249+ frappe .throw (
250+ title = _ ("Missing Required Filter" ),
251+ msg = _ ("Missing required filter: {0}" ).format (
252+ frappe .bold (FILTER_LABELS .get (filter_key , filter_key ))
253+ ),
254+ )
234255
235256 if filters .get ("presentation_currency" ):
236- frappe .msgprint (_ ("Currency filters are currently unsupported in Custom Financial Report." ))
257+ frappe .msgprint (
258+ title = _ ("Unsupported Feature" ),
259+ msg = _ ("Currency filters are currently unsupported in Custom Financial Report." ),
260+ indicator = "orange" ,
261+ )
237262
238263 # Margin view is dependent on first row being an income account. Hence not supported.
239264 # Way to implement this would be using calculated rows with formulas.
0 commit comments