From c3ff5e3748977f4f8648d4fed096d493c7d33915 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Thu, 20 Nov 2025 12:18:03 +0530 Subject: [PATCH] fix: multiple minor fixes --- erpnext/accounts/doctype/budget/budget.py | 8 ++++++++ erpnext/accounts/doctype/budget/test_budget.py | 2 +- erpnext/controllers/budget_controller.py | 2 +- .../v16_0/migrate_budget_records_to_new_structure.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py index 15ed0eb7317..d798da5b589 100644 --- a/erpnext/accounts/doctype/budget/budget.py +++ b/erpnext/accounts/doctype/budget/budget.py @@ -69,6 +69,7 @@ class Budget(Document): def validate(self): if not self.get(frappe.scrub(self.budget_against)): frappe.throw(_("{0} is mandatory").format(self.budget_against)) + self.validate_budget_amount() self.validate_fiscal_year() self.set_fiscal_year_dates() self.validate_duplicate() @@ -77,6 +78,10 @@ class Budget(Document): self.validate_applicable_for() self.validate_existing_expenses() + def validate_budget_amount(self): + if self.budget_amount <= 0: + frappe.throw(_("Budget Amount can not be {0}.").format(self.budget_amount)) + def validate_fiscal_year(self): if self.from_fiscal_year: self.validate_fiscal_year_company(self.from_fiscal_year, self.company) @@ -370,6 +375,9 @@ def validate_expense_against_budget(params, expense_amount=0): if not params.account: params.account = params.get("expense_account") + if not params.get("expense_account") and params.get("account"): + params.expense_account = params.account + if not (params.get("account") and params.get("cost_center")) and params.item_code: params.cost_center, params.account = get_item_details(params) diff --git a/erpnext/accounts/doctype/budget/test_budget.py b/erpnext/accounts/doctype/budget/test_budget.py index dd31cdc636f..ba9b4c04e08 100644 --- a/erpnext/accounts/doctype/budget/test_budget.py +++ b/erpnext/accounts/doctype/budget/test_budget.py @@ -619,7 +619,7 @@ def set_total_expense_zero(posting_date, budget_against_field=None, budget_again { "account": "_Test Account Cost for Goods Sold - _TC", "cost_center": "_Test Cost Center - _TC", - "monthly_end_date": posting_date, + "month_end_date": posting_date, "company": "_Test Company", "from_fiscal_year": fiscal_year, "to_fiscal_year": fiscal_year, diff --git a/erpnext/controllers/budget_controller.py b/erpnext/controllers/budget_controller.py index 33afac4df22..5c7692a4433 100644 --- a/erpnext/controllers/budget_controller.py +++ b/erpnext/controllers/budget_controller.py @@ -428,7 +428,7 @@ class BudgetValidation: frappe.bold(key[2]), frappe.bold(frappe.unscrub(key[0])), frappe.bold(key[1]), - frappe.bold(fmt_money(v_map.accumulated_montly_budget, currency=currency)), + frappe.bold(fmt_money(v_map.accumulated_monthly_budget, currency=currency)), self.budget_applicable_for(v_map, current_amt), frappe.bold(fmt_money(monthly_diff, currency=currency)), ) diff --git a/erpnext/patches/v16_0/migrate_budget_records_to_new_structure.py b/erpnext/patches/v16_0/migrate_budget_records_to_new_structure.py index bde5c2984c7..c9a18ebff31 100644 --- a/erpnext/patches/v16_0/migrate_budget_records_to_new_structure.py +++ b/erpnext/patches/v16_0/migrate_budget_records_to_new_structure.py @@ -44,7 +44,7 @@ def migrate_single_budget(budget_name): if not account_rows: return - frappe.db.delete("Budget Account", {"parent": budget_doc.name}) + frappe.db.delete("Budget Account", filters={"parent": budget_doc.name}) percentage_allocations = get_percentage_allocations(budget_doc)