diff --git a/erpnext/accounts/doctype/budget/budget.js b/erpnext/accounts/doctype/budget/budget.js index d1f9da66c0a..263a6eebc41 100644 --- a/erpnext/accounts/doctype/budget/budget.js +++ b/erpnext/accounts/doctype/budget/budget.js @@ -136,6 +136,9 @@ function set_total_budget_amount(frm) { function toggle_distribution_fields(frm) { const grid = frm.fields_dict.budget_distribution.grid; + frm.set_df_property("budget_distribution", "cannot_add_rows", true); + frm.set_df_property("budget_distribution", "cannot_delete_rows", true); + ["amount", "percent"].forEach((field) => { grid.update_docfield_property(field, "read_only", frm.doc.distribute_equally); }); diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py index 595dcf16de6..c1baea189fc 100644 --- a/erpnext/accounts/doctype/budget/budget.py +++ b/erpnext/accounts/doctype/budget/budget.py @@ -353,8 +353,8 @@ class Budget(Document): if self.should_regenerate_budget_distribution(): return - total_amount = sum(d.amount for d in self.budget_distribution) - total_percent = sum(d.percent for d in self.budget_distribution) + total_amount = sum(flt(d.amount) for d in self.budget_distribution) + total_percent = sum(flt(d.percent) for d in self.budget_distribution) if flt(abs(total_amount - self.budget_amount), 2) > 0.10: frappe.throw( diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.json b/erpnext/accounts/doctype/budget_distribution/budget_distribution.json index 85d14599cec..4c9322794e2 100644 --- a/erpnext/accounts/doctype/budget_distribution/budget_distribution.json +++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.json @@ -18,6 +18,7 @@ "in_list_view": 1, "label": "Start Date", "read_only": 1, + "reqd": 1, "search_index": 1 }, { @@ -25,26 +26,29 @@ "fieldtype": "Date", "in_list_view": 1, "label": "End Date", - "read_only": 1 + "read_only": 1, + "reqd": 1 }, { "fieldname": "amount", "fieldtype": "Currency", "in_list_view": 1, - "label": "Amount" + "label": "Amount", + "reqd": 1 }, { "fieldname": "percent", "fieldtype": "Percent", "in_list_view": 1, - "label": "Percent" + "label": "Percent", + "reqd": 1 } ], "grid_page_length": 50, "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2025-11-03 13:18:28.398198", + "modified": "2026-06-18 11:23:17.669733", "modified_by": "Administrator", "module": "Accounts", "name": "Budget Distribution", diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.py b/erpnext/accounts/doctype/budget_distribution/budget_distribution.py index 4c2cb3bb1bf..c8946f76e93 100644 --- a/erpnext/accounts/doctype/budget_distribution/budget_distribution.py +++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.py @@ -15,12 +15,12 @@ class BudgetDistribution(Document): from frappe.types import DF amount: DF.Currency - end_date: DF.Date | None + end_date: DF.Date parent: DF.Data parentfield: DF.Data parenttype: DF.Data percent: DF.Percent - start_date: DF.Date | None + start_date: DF.Date # end: auto-generated types pass 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 c839d26490d..cf4d32416c4 100644 --- a/erpnext/accounts/report/budget_variance_report/budget_variance_report.py +++ b/erpnext/accounts/report/budget_variance_report/budget_variance_report.py @@ -84,7 +84,13 @@ def build_budget_map(budget_records, filters): budget_distributions = get_budget_distributions(budget) for row in budget_distributions: + if not row.start_date or not row.end_date: + continue + months = get_months_in_range(row.start_date, row.end_date) + if not months: + continue + monthly_budget = flt(row.amount) / len(months) for month_date in months: