From c63ed0ac845110a11cee13339b79730ad04a524a Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Wed, 31 Jan 2024 09:27:05 +0100 Subject: [PATCH] fix: Set start and end date if not provided in filter --- .../monthly_recurring_revenue.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/erpnext/accounts/report/monthly_recurring_revenue/monthly_recurring_revenue.py b/erpnext/accounts/report/monthly_recurring_revenue/monthly_recurring_revenue.py index 1f6ee20943a..dd3493693c4 100644 --- a/erpnext/accounts/report/monthly_recurring_revenue/monthly_recurring_revenue.py +++ b/erpnext/accounts/report/monthly_recurring_revenue/monthly_recurring_revenue.py @@ -7,11 +7,14 @@ from frappe.utils import date_diff, flt, getdate, month_diff, nowdate from erpnext.accounts.report.financial_statements import get_columns, get_period_list from erpnext.accounts.utils import get_currency_precision +from erpnext.accounts.utils import get_fiscal_year PERIOD_MAP = {"Month": "Monthly", "Year": "Yearly"} def execute(filters=None): + validate_filters(filters) + period_list = get_period_list( filters.from_fiscal_year, filters.to_fiscal_year, @@ -44,6 +47,14 @@ def execute(filters=None): return columns, data, [], get_chart_data(columns, data) +def validate_filters(filters): + if not filters.period_start_date and filters.from_fiscal_year: + filters.period_start_date = get_fiscal_year(fiscal_year=filters.from_fiscal_year)[1] + + if not filters.period_end_date and filters.to_fiscal_year: + filters.period_end_date = get_fiscal_year(fiscal_year=filters.to_fiscal_year)[2] + + def get_data(filters, period_list): invoices = frappe.get_all( "Sales Invoice", -- GitLab