Merge pull request #50007 from rohitwaghchaure/fixed-expense-account-in-company

feat: service expense account in the company
This commit is contained in:
rohitwaghchaure
2025-10-10 16:49:32 +05:30
committed by GitHub
5 changed files with 30 additions and 2 deletions

View File

@@ -232,7 +232,7 @@ class TestRepostAccountingLedger(AccountsTestMixin, IntegrationTestCase):
company.save() company.save()
test_cc = company.cost_center 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}) item = make_item(properties={"is_stock_item": 0})

View File

@@ -289,6 +289,7 @@ erpnext.company.setup_queries = function (frm) {
["default_provisional_account", { root_type: ["in", ["Liability", "Asset"]] }], ["default_provisional_account", { root_type: ["in", ["Liability", "Asset"]] }],
["default_advance_received_account", { root_type: "Liability", account_type: "Receivable" }], ["default_advance_received_account", { root_type: "Liability", account_type: "Receivable" }],
["default_advance_paid_account", { root_type: "Asset", account_type: "Payable" }], ["default_advance_paid_account", { root_type: "Asset", account_type: "Payable" }],
["service_expense_account", { root_type: "Expense" }],
], ],
function (i, v) { function (i, v) {
erpnext.company.set_custom_query(frm, v); erpnext.company.set_custom_query(frm, v);

View File

@@ -108,6 +108,7 @@
"transactions_annual_history", "transactions_annual_history",
"purchase_expense_section", "purchase_expense_section",
"purchase_expense_account", "purchase_expense_account",
"service_expense_account",
"column_break_ereg", "column_break_ereg",
"purchase_expense_contra_account", "purchase_expense_contra_account",
"stock_tab", "stock_tab",
@@ -869,6 +870,13 @@
"fieldtype": "Link", "fieldtype": "Link",
"label": "Purchase Expense Contra Account", "label": "Purchase Expense Contra Account",
"options": "Account" "options": "Account"
},
{
"description": "For service item",
"fieldname": "service_expense_account",
"fieldtype": "Link",
"label": "Service Expense Account",
"options": "Account"
} }
], ],
"icon": "fa fa-building", "icon": "fa fa-building",
@@ -876,7 +884,7 @@
"image_field": "company_logo", "image_field": "company_logo",
"is_tree": 1, "is_tree": 1,
"links": [], "links": [],
"modified": "2025-10-01 17:34:10.971627", "modified": "2025-10-10 15:12:37.941251",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Setup", "module": "Setup",
"name": "Company", "name": "Company",

View File

@@ -100,6 +100,7 @@ class Company(NestedSet):
round_off_for_opening: DF.Link | None round_off_for_opening: DF.Link | None
sales_monthly_history: DF.SmallText | None sales_monthly_history: DF.SmallText | None
series_for_depreciation_entry: DF.Data | None series_for_depreciation_entry: DF.Data | None
service_expense_account: DF.Link | None
stock_adjustment_account: DF.Link | None stock_adjustment_account: DF.Link | None
stock_received_but_not_billed: DF.Link | None stock_received_but_not_billed: DF.Link | None
submit_err_jv: DF.Check submit_err_jv: DF.Check
@@ -570,6 +571,21 @@ class Company(NestedSet):
self.db_set("disposal_account", disposal_acct) 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): def _set_default_account(self, fieldname, account_type):
if self.get(fieldname): if self.get(fieldname):
return return

View File

@@ -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) default_supplier = get_default_supplier(ctx, item_defaults, item_group_defaults, brand_defaults)
if default_supplier: if default_supplier:
out.supplier = default_supplier out.supplier = default_supplier