Skip to content

Commit 25c134d

Browse files
Sudharsanan11mergify[bot]
authored andcommitted
fix: set company based expense account
(cherry picked from commit d54d0c2)
1 parent c6e0eb6 commit 25c134d

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,7 @@ def make_landed_cost_voucher(**args):
12601260
lcv = frappe.new_doc("Landed Cost Voucher")
12611261
lcv.company = args.company or "_Test Company"
12621262
lcv.distribute_charges_based_on = args.distribute_charges_based_on or "Amount"
1263+
expense_account = get_expense_account(args.company or "_Test Company")
12631264

12641265
lcv.set(
12651266
"purchase_receipts",
@@ -1280,7 +1281,7 @@ def make_landed_cost_voucher(**args):
12801281
[
12811282
{
12821283
"description": "Shipping Charges",
1283-
"expense_account": args.expense_account or "Expenses Included In Valuation - TCP1",
1284+
"expense_account": args.expense_account or expense_account,
12841285
"amount": args.charges,
12851286
}
12861287
],
@@ -1300,6 +1301,7 @@ def create_landed_cost_voucher(receipt_document_type, receipt_document, company,
13001301
lcv = frappe.new_doc("Landed Cost Voucher")
13011302
lcv.company = company
13021303
lcv.distribute_charges_based_on = "Amount"
1304+
expense_account = get_expense_account(company)
13031305

13041306
lcv.set(
13051307
"purchase_receipts",
@@ -1319,7 +1321,7 @@ def create_landed_cost_voucher(receipt_document_type, receipt_document, company,
13191321
[
13201322
{
13211323
"description": "Insurance Charges",
1322-
"expense_account": "Expenses Included In Valuation - TCP1",
1324+
"expense_account": expense_account,
13231325
"amount": charges,
13241326
}
13251327
],
@@ -1334,6 +1336,11 @@ def create_landed_cost_voucher(receipt_document_type, receipt_document, company,
13341336
return lcv
13351337

13361338

1339+
def get_expense_account(company):
1340+
company_abbr = frappe.get_cached_value("Company", company, "abbr")
1341+
return f"Expenses Included In Valuation - {company_abbr}"
1342+
1343+
13371344
def distribute_landed_cost_on_items(lcv):
13381345
based_on = lcv.distribute_charges_based_on.lower()
13391346
total = sum(flt(d.get(based_on)) for d in lcv.get("items"))

0 commit comments

Comments
 (0)