From f56a673baaa82cbd3b17c2e674f4f896d1678100 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Wed, 31 Dec 2025 11:40:15 +0530 Subject: [PATCH] refactor: formatted code --- .../budget_variance_report.py | 71 +++++++------------ 1 file changed, 24 insertions(+), 47 deletions(-) diff --git a/erpnext/accounts/report/budget_variance_report/budget_variance_report.py b/erpnext/accounts/report/budget_variance_report/budget_variance_report.py index fb87f7390f1..aa4cb5f34de 100644 --- a/erpnext/accounts/report/budget_variance_report/budget_variance_report.py +++ b/erpnext/accounts/report/budget_variance_report/budget_variance_report.py @@ -27,22 +27,6 @@ def execute(filters=None): return columns, data -def get_fiscal_year_dates(fiscal_year): - fy = frappe.get_doc("Fiscal Year", fiscal_year) - return fy.year_start_date, fy.year_end_date - - -def get_month_list(start_date, end_date): - months = [] - current = start_date - - while current <= end_date: - months.append(current.strftime("%Y-%m")) - current = add_months(current, 1) - - return months - - def fetch_budget_accounts(filters, dimensions): budget_against_field = frappe.scrub(filters["budget_against"]) @@ -118,30 +102,6 @@ def build_budget_map(budget_records, filters): return budget_map -def get_months_in_range(start_date, end_date): - months = [] - current = start_date - - while current <= end_date: - months.append(current) - current = add_months(current, 1) - - return months - - -def get_budget_distributions(budget): - return frappe.db.sql( - """ - SELECT start_date, end_date, amount, percent - FROM `tabBudget Distribution` - WHERE parent = %s - ORDER BY start_date ASC - """, - (budget.name,), - as_dict=True, - ) - - def get_actual_details(name, filters): budget_against = frappe.scrub(filters.get("budget_against")) cond = "" @@ -196,6 +156,30 @@ def get_actual_details(name, filters): return cc_actual_details +def get_budget_distributions(budget): + return frappe.db.sql( + """ + SELECT start_date, end_date, amount, percent + FROM `tabBudget Distribution` + WHERE parent = %s + ORDER BY start_date ASC + """, + (budget.name,), + as_dict=True, + ) + + +def get_months_in_range(start_date, end_date): + months = [] + current = start_date + + while current <= end_date: + months.append(current) + current = add_months(current, 1) + + return months + + def get_data_from_budget_map(budget_map, filters): data = [] @@ -278,13 +262,6 @@ def get_budget_actual(budget_map, dim, acc, fy, month): return 0, 0 -def get_fiscal_year_range_dates(from_fy, to_fy): - start_fy = frappe.get_doc("Fiscal Year", from_fy) - end_fy = frappe.get_doc("Fiscal Year", to_fy) - - return start_fy.year_start_date, end_fy.year_end_date - - def get_columns(filters): columns = [ {