mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-23 05:04:52 +01:00
fix: set company based expense account
(cherry picked from commit d54d0c25a2)
# Conflicts:
# erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
This commit is contained in:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user