feat: show budget total

This commit is contained in:
khushi8112
2025-10-06 15:15:13 +05:30
parent be40b5bbff
commit b6e452a695
2 changed files with 31 additions and 3 deletions

View File

@@ -33,7 +33,11 @@
"action_if_annual_exceeded_on_cumulative_expense",
"action_if_accumulated_monthly_exceeded_on_cumulative_expense",
"section_break_21",
"accounts"
"accounts",
"section_break_hqka",
"column_break_gnot",
"column_break_ybiq",
"total_budget_amount"
],
"fields": [
{
@@ -188,7 +192,8 @@
},
{
"fieldname": "section_break_21",
"fieldtype": "Section Break"
"fieldtype": "Section Break",
"hide_border": 1
},
{
"fieldname": "accounts",
@@ -232,13 +237,31 @@
"fieldtype": "Select",
"label": "Action if Accumulative Monthly Budget Exceeded on Cumulative Expense",
"options": "\nStop\nWarn\nIgnore"
},
{
"fieldname": "section_break_hqka",
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_gnot",
"fieldtype": "Column Break"
},
{
"fieldname": "column_break_ybiq",
"fieldtype": "Column Break"
},
{
"fieldname": "total_budget_amount",
"fieldtype": "Currency",
"label": "Total Budget Amount",
"read_only": 1
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2025-06-16 15:57:13.114981",
"modified": "2025-10-06 14:55:07.247313",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Budget",

View File

@@ -53,6 +53,7 @@ class Budget(Document):
monthly_distribution: DF.Link | None
naming_series: DF.Literal["BUDGET-.YYYY.-"]
project: DF.Link | None
total_budget_amount: DF.Currency
# end: auto-generated types
def validate(self):
@@ -62,6 +63,7 @@ class Budget(Document):
self.validate_accounts()
self.set_null_value()
self.validate_applicable_for()
self.set_total_budget_amount()
def validate_duplicate(self):
budget_against_field = frappe.scrub(self.budget_against)
@@ -139,6 +141,9 @@ class Budget(Document):
):
self.applicable_on_booking_actual_expenses = 1
def set_total_budget_amount(self):
self.total_budget_amount = flt(sum(d.budget_amount for d in self.accounts))
def validate_expense_against_budget(args, expense_amount=0):
args = frappe._dict(args)