mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-17 00:18:39 +00:00
feat: book Expenses Added To Stock GL entries for stock vouchers (configurable) (#57190)
* feat: book Expenses Added To Stock GL entries for Stock Entry, Stock Reconciliation and LCV Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * feat: make stock expense GL booking configurable via Accounts Settings Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: skip stock expense booking for unconfigured companies, check flag once per compose --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -323,6 +323,8 @@ erpnext.company.setup_queries = function (frm) {
|
||||
["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" }],
|
||||
["expenses_added_to_stock_account", { root_type: "Expense" }],
|
||||
["expenses_added_to_stock_contra_account", { root_type: "Expense" }],
|
||||
],
|
||||
function (i, v) {
|
||||
erpnext.company.set_custom_query(frm, v);
|
||||
|
||||
@@ -137,6 +137,10 @@
|
||||
"disable_sdbnb_in_sr",
|
||||
"default_provisional_account",
|
||||
"default_in_transit_warehouse",
|
||||
"stock_expense_section",
|
||||
"expenses_added_to_stock_account",
|
||||
"column_break_gthb",
|
||||
"expenses_added_to_stock_contra_account",
|
||||
"manufacturing_section",
|
||||
"default_operating_cost_account",
|
||||
"column_break_9prc",
|
||||
@@ -962,6 +966,18 @@
|
||||
"label": "Service Expense Account",
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
"fieldname": "expenses_added_to_stock_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Expenses Added To Stock Account",
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
"fieldname": "expenses_added_to_stock_contra_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Expenses Added To Stock Contra Account",
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"description": "If enabled, the system will use the inventory account set in the Item Master or Item Group or Brand. Otherwise, it will use the inventory account set in the Warehouse.",
|
||||
@@ -1071,6 +1087,15 @@
|
||||
"fieldname": "enable_stock_delivered_but_not_billed",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enable Stock Delivered But Not Billed"
|
||||
},
|
||||
{
|
||||
"fieldname": "stock_expense_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Stock Expense"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_gthb",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"grid_page_length": 50,
|
||||
@@ -1079,7 +1104,7 @@
|
||||
"image_field": "company_logo",
|
||||
"is_tree": 1,
|
||||
"links": [],
|
||||
"modified": "2026-07-02 07:21:21.794533",
|
||||
"modified": "2026-07-15 15:38:29.214020",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
|
||||
@@ -104,6 +104,8 @@ class Company(NestedSet):
|
||||
exception_budget_approver_role: DF.Link | None
|
||||
exchange_gain_loss_account: DF.Link | None
|
||||
existing_company: DF.Link | None
|
||||
expenses_added_to_stock_account: DF.Link | None
|
||||
expenses_added_to_stock_contra_account: DF.Link | None
|
||||
fax: DF.Data | None
|
||||
is_group: DF.Check
|
||||
lft: DF.Int
|
||||
|
||||
@@ -75,6 +75,23 @@ frappe.ui.form.on("Item Group", {
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
["expenses_added_to_stock_account", "expenses_added_to_stock_contra_account"].forEach((field) => {
|
||||
frm.fields_dict["item_group_defaults"].grid.get_field(field).get_query = function (
|
||||
doc,
|
||||
cdt,
|
||||
cdn
|
||||
) {
|
||||
const row = locals[cdt][cdn];
|
||||
return {
|
||||
filters: {
|
||||
root_type: "Expense",
|
||||
company: row.company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function (frm) {
|
||||
@@ -174,6 +191,8 @@ const COMPANY_DEFAULTS_TO_VF = {
|
||||
default_discount_account: "vf_default_discount_account",
|
||||
default_supplier: "vf_default_supplier",
|
||||
purchase_expense_contra_account: "vf_purchase_expense_contra_account",
|
||||
expenses_added_to_stock_account: "vf_expenses_added_to_stock_account",
|
||||
expenses_added_to_stock_contra_account: "vf_expenses_added_to_stock_contra_account",
|
||||
};
|
||||
|
||||
const FIELD_DEFAULT_SOURCE = {
|
||||
@@ -192,6 +211,8 @@ const FIELD_DEFAULT_SOURCE = {
|
||||
default_discount_account: "Company",
|
||||
default_supplier: null,
|
||||
purchase_expense_contra_account: "Company",
|
||||
expenses_added_to_stock_account: "Company",
|
||||
expenses_added_to_stock_contra_account: "Company",
|
||||
};
|
||||
|
||||
function populate_item_group_company_defaults(frm, cdt, cdn, row) {
|
||||
|
||||
@@ -126,6 +126,8 @@ def get_company_resolved_defaults(company: str) -> dict:
|
||||
"deferred_revenue_account": company_doc.get("default_deferred_revenue_account"),
|
||||
"default_discount_account": company_doc.get("default_discount_account"),
|
||||
"purchase_expense_contra_account": company_doc.get("purchase_expense_contra_account"),
|
||||
"expenses_added_to_stock_account": company_doc.get("expenses_added_to_stock_account"),
|
||||
"expenses_added_to_stock_contra_account": company_doc.get("expenses_added_to_stock_contra_account"),
|
||||
"default_price_list": "",
|
||||
"default_supplier": "",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user