mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-19 09:28:46 +00:00
fix: GL entries for purchase expense with LCV (#57475)
This commit is contained in:
@@ -338,9 +338,6 @@ class BuyingController(SubcontractingController):
|
||||
if not details.get(field):
|
||||
details[field] = frappe.get_cached_value("Company", self.company, field)
|
||||
|
||||
if not any(details.get(field) for field in fields):
|
||||
return None
|
||||
|
||||
for field in fields:
|
||||
if not details.get(field):
|
||||
frappe.throw(
|
||||
@@ -364,6 +361,9 @@ class BuyingController(SubcontractingController):
|
||||
continue
|
||||
|
||||
amount = flt(row.valuation_rate * row.stock_qty, row.precision("base_amount"))
|
||||
if row.landed_cost_voucher_amount:
|
||||
amount -= flt(row.landed_cost_voucher_amount, row.precision("base_amount"))
|
||||
|
||||
self.add_gl_entry(
|
||||
gl_entries=gl_entries,
|
||||
account=details.purchase_expense_account,
|
||||
|
||||
@@ -120,6 +120,10 @@
|
||||
"service_expense_account",
|
||||
"column_break_ereg",
|
||||
"purchase_expense_contra_account",
|
||||
"stock_expense_section",
|
||||
"expenses_added_to_stock_account",
|
||||
"column_break_gthb",
|
||||
"expenses_added_to_stock_contra_account",
|
||||
"stock_tab",
|
||||
"auto_accounting_for_stock_settings",
|
||||
"enable_perpetual_inventory",
|
||||
@@ -137,10 +141,6 @@
|
||||
"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",
|
||||
@@ -1104,7 +1104,7 @@
|
||||
"image_field": "company_logo",
|
||||
"is_tree": 1,
|
||||
"links": [],
|
||||
"modified": "2026-07-15 15:38:29.214020",
|
||||
"modified": "2026-07-26 21:14:52.739814",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
|
||||
@@ -200,9 +200,6 @@ class BaseStockGLComposer(BaseGLComposer):
|
||||
fields = ("expenses_added_to_stock_account", "expenses_added_to_stock_contra_account")
|
||||
details = get_expenses_added_to_stock_accounts(item_code, doc.company)
|
||||
|
||||
if not any(details.get(field) for field in fields):
|
||||
return
|
||||
|
||||
for field in fields:
|
||||
if not details.get(field):
|
||||
frappe.throw(
|
||||
|
||||
@@ -140,22 +140,6 @@ class TestExpensesAddedToStock(ERPNextTestSuite):
|
||||
self.assertEqual(debits[self.eats_account], 0)
|
||||
self.assertEqual(credits[self.eats_contra_account], 0)
|
||||
|
||||
def test_unconfigured_company_skips_booking(self):
|
||||
frappe.db.set_value(
|
||||
"Company",
|
||||
COMPANY,
|
||||
{
|
||||
"expenses_added_to_stock_account": None,
|
||||
"expenses_added_to_stock_contra_account": None,
|
||||
},
|
||||
)
|
||||
|
||||
se = make_stock_entry(item_code=self.item, to_warehouse=WAREHOUSE, qty=10, rate=100, company=COMPANY)
|
||||
|
||||
_balances, debits, credits = self.get_gl_balances("Stock Entry", se.name)
|
||||
self.assertEqual(debits[self.eats_account], 0)
|
||||
self.assertEqual(credits[self.eats_contra_account], 0)
|
||||
|
||||
def test_missing_contra_account_raises_when_feature_enabled(self):
|
||||
frappe.db.set_value("Company", COMPANY, "expenses_added_to_stock_contra_account", None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user