mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 04:15:10 +00:00
fix: set company based expense account
(cherry picked from commit d54d0c25a2)
This commit is contained in:
@@ -1260,6 +1260,7 @@ def make_landed_cost_voucher(**args):
|
|||||||
lcv = frappe.new_doc("Landed Cost Voucher")
|
lcv = frappe.new_doc("Landed Cost Voucher")
|
||||||
lcv.company = args.company or "_Test Company"
|
lcv.company = args.company or "_Test Company"
|
||||||
lcv.distribute_charges_based_on = args.distribute_charges_based_on or "Amount"
|
lcv.distribute_charges_based_on = args.distribute_charges_based_on or "Amount"
|
||||||
|
expense_account = get_expense_account(args.company or "_Test Company")
|
||||||
|
|
||||||
lcv.set(
|
lcv.set(
|
||||||
"purchase_receipts",
|
"purchase_receipts",
|
||||||
@@ -1280,7 +1281,7 @@ def make_landed_cost_voucher(**args):
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"description": "Shipping Charges",
|
"description": "Shipping Charges",
|
||||||
"expense_account": args.expense_account or "Expenses Included In Valuation - TCP1",
|
"expense_account": args.expense_account or expense_account,
|
||||||
"amount": args.charges,
|
"amount": args.charges,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1300,6 +1301,7 @@ def create_landed_cost_voucher(receipt_document_type, receipt_document, company,
|
|||||||
lcv = frappe.new_doc("Landed Cost Voucher")
|
lcv = frappe.new_doc("Landed Cost Voucher")
|
||||||
lcv.company = company
|
lcv.company = company
|
||||||
lcv.distribute_charges_based_on = "Amount"
|
lcv.distribute_charges_based_on = "Amount"
|
||||||
|
expense_account = get_expense_account(company)
|
||||||
|
|
||||||
lcv.set(
|
lcv.set(
|
||||||
"purchase_receipts",
|
"purchase_receipts",
|
||||||
@@ -1319,7 +1321,7 @@ def create_landed_cost_voucher(receipt_document_type, receipt_document, company,
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"description": "Insurance Charges",
|
"description": "Insurance Charges",
|
||||||
"expense_account": "Expenses Included In Valuation - TCP1",
|
"expense_account": expense_account,
|
||||||
"amount": charges,
|
"amount": charges,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -1334,6 +1336,11 @@ def create_landed_cost_voucher(receipt_document_type, receipt_document, company,
|
|||||||
return lcv
|
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):
|
def distribute_landed_cost_on_items(lcv):
|
||||||
based_on = lcv.distribute_charges_based_on.lower()
|
based_on = lcv.distribute_charges_based_on.lower()
|
||||||
total = sum(flt(d.get(based_on)) for d in lcv.get("items"))
|
total = sum(flt(d.get(based_on)) for d in lcv.get("items"))
|
||||||
|
|||||||
Reference in New Issue
Block a user