From 74e71f386807bc87a92a5c9176cdd5925198749d Mon Sep 17 00:00:00 2001 From: Sudharsanan11 Date: Fri, 20 Feb 2026 12:15:40 +0530 Subject: [PATCH] fix: set company based expense account (cherry picked from commit d54d0c25a23ac65c6fe1fd971bdcc0c1cab5ca1a) # Conflicts: # erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py --- .../test_landed_cost_voucher.py | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py index 39f9ecb915d..a9b36f8661f 100644 --- a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py +++ b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py @@ -1076,6 +1076,7 @@ def make_landed_cost_voucher(**args): lcv = frappe.new_doc("Landed Cost Voucher") lcv.company = args.company or "_Test Company" lcv.distribute_charges_based_on = args.distribute_charges_based_on or "Amount" + expense_account = get_expense_account(args.company or "_Test Company") lcv.set( "purchase_receipts", @@ -1090,6 +1091,7 @@ def make_landed_cost_voucher(**args): ], ) +<<<<<<< HEAD lcv.set( "taxes", [ @@ -1100,6 +1102,19 @@ def make_landed_cost_voucher(**args): } ], ) +======= + if args.charges: + lcv.set( + "taxes", + [ + { + "description": "Shipping Charges", + "expense_account": args.expense_account or expense_account, + "amount": args.charges, + } + ], + ) +>>>>>>> d54d0c25a2 (fix: set company based expense account) if not args.do_not_save: lcv.insert() @@ -1115,6 +1130,7 @@ def create_landed_cost_voucher(receipt_document_type, receipt_document, company, lcv = frappe.new_doc("Landed Cost Voucher") lcv.company = company lcv.distribute_charges_based_on = "Amount" + expense_account = get_expense_account(company) lcv.set( "purchase_receipts", @@ -1134,7 +1150,7 @@ def create_landed_cost_voucher(receipt_document_type, receipt_document, company, [ { "description": "Insurance Charges", - "expense_account": "Expenses Included In Valuation - TCP1", + "expense_account": expense_account, "amount": charges, } ], @@ -1149,6 +1165,11 @@ def create_landed_cost_voucher(receipt_document_type, receipt_document, company, return lcv +def get_expense_account(company): + company_abbr = frappe.get_cached_value("Company", company, "abbr") + return f"Expenses Included In Valuation - {company_abbr}" + + def distribute_landed_cost_on_items(lcv): based_on = lcv.distribute_charges_based_on.lower() total = sum(flt(d.get(based_on)) for d in lcv.get("items"))