From e23d229e7bd3db25bc79a4167d2daba4337434c4 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Mon, 13 Oct 2025 12:20:41 +0530 Subject: [PATCH] feat: introduce budget distribution child table --- erpnext/accounts/doctype/budget/budget.json | 16 +++++- erpnext/accounts/doctype/budget/budget.py | 2 + .../doctype/budget_distribution/__init__.py | 0 .../budget_distribution.json | 56 +++++++++++++++++++ .../budget_distribution.py | 26 +++++++++ 5 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 erpnext/accounts/doctype/budget_distribution/__init__.py create mode 100644 erpnext/accounts/doctype/budget_distribution/budget_distribution.json create mode 100644 erpnext/accounts/doctype/budget_distribution/budget_distribution.py diff --git a/erpnext/accounts/doctype/budget/budget.json b/erpnext/accounts/doctype/budget/budget.json index 5b62b7eec92..ef347a37082 100644 --- a/erpnext/accounts/doctype/budget/budget.json +++ b/erpnext/accounts/doctype/budget/budget.json @@ -37,7 +37,9 @@ "section_break_hqka", "column_break_gnot", "column_break_ybiq", - "total_budget_amount" + "total_budget_amount", + "section_break_fpdt", + "budget_distribution" ], "fields": [ { @@ -255,13 +257,23 @@ "fieldtype": "Currency", "label": "Total Budget Amount", "read_only": 1 + }, + { + "fieldname": "section_break_fpdt", + "fieldtype": "Section Break" + }, + { + "fieldname": "budget_distribution", + "fieldtype": "Table", + "label": "Budget Distribution", + "options": "Budget Distribution" } ], "grid_page_length": 50, "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2025-10-06 14:55:07.247313", + "modified": "2025-10-12 23:44:49.632709", "modified_by": "Administrator", "module": "Accounts", "name": "Budget", diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py index 2472e813cd1..3c7e2b04b8d 100644 --- a/erpnext/accounts/doctype/budget/budget.py +++ b/erpnext/accounts/doctype/budget/budget.py @@ -31,6 +31,7 @@ class Budget(Document): from frappe.types import DF from erpnext.accounts.doctype.budget_account.budget_account import BudgetAccount + from erpnext.accounts.doctype.budget_distribution.budget_distribution import BudgetDistribution accounts: DF.Table[BudgetAccount] action_if_accumulated_monthly_budget_exceeded: DF.Literal["", "Stop", "Warn", "Ignore"] @@ -47,6 +48,7 @@ class Budget(Document): applicable_on_material_request: DF.Check applicable_on_purchase_order: DF.Check budget_against: DF.Literal["", "Cost Center", "Project"] + budget_distribution: DF.Table[BudgetDistribution] company: DF.Link cost_center: DF.Link | None fiscal_year: DF.Link diff --git a/erpnext/accounts/doctype/budget_distribution/__init__.py b/erpnext/accounts/doctype/budget_distribution/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.json b/erpnext/accounts/doctype/budget_distribution/budget_distribution.json new file mode 100644 index 00000000000..5c633fa392b --- /dev/null +++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.json @@ -0,0 +1,56 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2025-10-12 23:31:03.841996", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "start_date", + "end_date", + "amount", + "percent" + ], + "fields": [ + { + "fieldname": "start_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "Start Date", + "search_index": 1 + }, + { + "fieldname": "end_date", + "fieldtype": "Date", + "in_list_view": 1, + "label": "End Date" + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "in_list_view": 1, + "label": "Amount" + }, + { + "fieldname": "percent", + "fieldtype": "Percent", + "in_list_view": 1, + "label": "Percent" + } + ], + "grid_page_length": 50, + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2025-10-12 23:47:30.393908", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Budget Distribution", + "owner": "Administrator", + "permissions": [], + "row_format": "Dynamic", + "rows_threshold_for_grid_search": 20, + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.py b/erpnext/accounts/doctype/budget_distribution/budget_distribution.py new file mode 100644 index 00000000000..4c2cb3bb1bf --- /dev/null +++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.py @@ -0,0 +1,26 @@ +# Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class BudgetDistribution(Document): + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + amount: DF.Currency + end_date: DF.Date | None + parent: DF.Data + parentfield: DF.Data + parenttype: DF.Data + percent: DF.Percent + start_date: DF.Date | None + # end: auto-generated types + + pass