fix: multiple minor fixes

This commit is contained in:
khushi8112
2025-11-20 12:18:03 +05:30
parent acec1a7a9d
commit c3ff5e3748
4 changed files with 11 additions and 3 deletions

View File

@@ -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)

View File

@@ -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,

View File

@@ -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)),
)

View File

@@ -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)