From 4605051903e4077139aa406b69de43425a98f191 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 10 Oct 2025 15:21:17 +0530 Subject: [PATCH] feat: service expense account in the company --- .../test_repost_accounting_ledger.py | 2 +- erpnext/setup/doctype/company/company.js | 1 + erpnext/setup/doctype/company/company.json | 10 +++++++++- erpnext/setup/doctype/company/company.py | 16 ++++++++++++++++ erpnext/stock/get_item_details.py | 3 +++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/repost_accounting_ledger/test_repost_accounting_ledger.py b/erpnext/accounts/doctype/repost_accounting_ledger/test_repost_accounting_ledger.py index 6dc1fd18ad1..cde007d14f6 100644 --- a/erpnext/accounts/doctype/repost_accounting_ledger/test_repost_accounting_ledger.py +++ b/erpnext/accounts/doctype/repost_accounting_ledger/test_repost_accounting_ledger.py @@ -232,7 +232,7 @@ class TestRepostAccountingLedger(AccountsTestMixin, IntegrationTestCase): company.save() test_cc = company.cost_center - default_expense_account = company.default_expense_account + default_expense_account = company.service_expense_account item = make_item(properties={"is_stock_item": 0}) diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index 1035fa3fb58..1018036c11b 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -289,6 +289,7 @@ erpnext.company.setup_queries = function (frm) { ["default_provisional_account", { root_type: ["in", ["Liability", "Asset"]] }], ["default_advance_received_account", { root_type: "Liability", account_type: "Receivable" }], ["default_advance_paid_account", { root_type: "Asset", account_type: "Payable" }], + ["service_expense_account", { root_type: "Expense" }], ], function (i, v) { erpnext.company.set_custom_query(frm, v); diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index 8d713600ba7..349fe5c0771 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -108,6 +108,7 @@ "transactions_annual_history", "purchase_expense_section", "purchase_expense_account", + "service_expense_account", "column_break_ereg", "purchase_expense_contra_account", "stock_tab", @@ -869,6 +870,13 @@ "fieldtype": "Link", "label": "Purchase Expense Contra Account", "options": "Account" + }, + { + "description": "For service item", + "fieldname": "service_expense_account", + "fieldtype": "Link", + "label": "Service Expense Account", + "options": "Account" } ], "icon": "fa fa-building", @@ -876,7 +884,7 @@ "image_field": "company_logo", "is_tree": 1, "links": [], - "modified": "2025-10-01 17:34:10.971627", + "modified": "2025-10-10 15:12:37.941251", "modified_by": "Administrator", "module": "Setup", "name": "Company", diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 56f88c215ae..60788b98d2a 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -100,6 +100,7 @@ class Company(NestedSet): round_off_for_opening: DF.Link | None sales_monthly_history: DF.SmallText | None series_for_depreciation_entry: DF.Data | None + service_expense_account: DF.Link | None stock_adjustment_account: DF.Link | None stock_received_but_not_billed: DF.Link | None submit_err_jv: DF.Check @@ -570,6 +571,21 @@ class Company(NestedSet): self.db_set("disposal_account", disposal_acct) + if not self.service_expense_account: + service_expense_acct = frappe.db.get_value( + "Account", + { + "account_name": _("Marketing Expenses"), + "company": self.name, + "is_group": 0, + "root_type": "Expense", + }, + "name", + ) + + if service_expense_acct: + self.db_set("service_expense_account", service_expense_acct) + def _set_default_account(self, fieldname, account_type): if self.get(fieldname): return diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 22e0c69e8f4..2a8f144b790 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -502,6 +502,9 @@ def get_basic_details(ctx: ItemDetailsCtx, item, overwrite_warehouse=True) -> It } ) + if not item.is_stock_item and not out.expense_account: + out.expense_account = frappe.get_cached_value("Company", ctx.company, "service_expense_account") + default_supplier = get_default_supplier(ctx, item_defaults, item_group_defaults, brand_defaults) if default_supplier: out.supplier = default_supplier