diff --git a/erpnext/accounts/doctype/subscription/subscription.py b/erpnext/accounts/doctype/subscription/subscription.py index e2cd4127049..a86a860016e 100644 --- a/erpnext/accounts/doctype/subscription/subscription.py +++ b/erpnext/accounts/doctype/subscription/subscription.py @@ -25,7 +25,6 @@ from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( get_accounting_dimensions, ) from erpnext.accounts.doctype.subscription_plan.subscription_plan import get_plan_rate -from erpnext.accounts.party import get_party_account_currency class InvoiceCancelled(frappe.ValidationError): diff --git a/erpnext/accounts/doctype/subscription/test_subscription.py b/erpnext/accounts/doctype/subscription/test_subscription.py index 7bb72a1dcd7..d9459948b58 100644 --- a/erpnext/accounts/doctype/subscription/test_subscription.py +++ b/erpnext/accounts/doctype/subscription/test_subscription.py @@ -653,7 +653,7 @@ def reset_settings(): def create_subscription(**kwargs): subscription = frappe.new_doc("Subscription") - subscription.party_type = (kwargs.get("party_type") or "Customer",) + subscription.party_type = kwargs.get("party_type") or "Customer" subscription.company = kwargs.get("company") or "_Test Company" subscription.party = kwargs.get("party") or "_Test Customer" subscription.trial_period_start = kwargs.get("trial_period_start") diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py index 5eeb25e093b..066735abc03 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.py +++ b/erpnext/buying/doctype/purchase_order/purchase_order.py @@ -748,6 +748,7 @@ def make_purchase_receipt(source_name, target_doc=None, args=None): "sales_order_item": "sales_order_item", "wip_composite_asset": "wip_composite_asset", }, + "field_no_map": ["expense_account"], "postprocess": update_item, "condition": lambda doc: ( True if is_unit_price_row(doc) else abs(doc.received_qty) < abs(doc.qty) diff --git a/erpnext/setup/doctype/company/test_company.py b/erpnext/setup/doctype/company/test_company.py index d30f7367dbf..3c2500c0826 100644 --- a/erpnext/setup/doctype/company/test_company.py +++ b/erpnext/setup/doctype/company/test_company.py @@ -1,7 +1,6 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt import json -import unittest import frappe from frappe import _ diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 69971410b2c..ca2f4d4ac72 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -755,7 +755,7 @@ class PurchaseReceipt(BuyingController): stock_asset_rbnb = ( self.get_company_default("asset_received_but_not_billed") if d.is_fixed_asset - else self.get_company_default("stock_received_but_not_billed") + else (d.expense_account or self.get_company_default("stock_received_but_not_billed")) ) landed_cost_entries = self.get_item_account_wise_lcv_entries() if d.is_fixed_asset: @@ -809,7 +809,7 @@ class PurchaseReceipt(BuyingController): stock_asset_rbnb = ( self.get_company_default("asset_received_but_not_billed") if d.is_fixed_asset - else self.get_company_default("stock_received_but_not_billed") + else (d.expense_account or self.get_company_default("stock_received_but_not_billed")) ) stock_value_diff = get_stock_value_difference(self.name, d.name, d.rejected_warehouse) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index a1f431c883e..1b3b9a97f3b 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -434,6 +434,19 @@ def get_basic_details(ctx: ItemDetailsCtx, item, overwrite_warehouse=True) -> It expense_account = get_asset_category_account( fieldname="fixed_asset_account", item=ctx.item_code, company=ctx.company ) + elif ctx.doctype == "Purchase Receipt": + from erpnext.accounts.utils import get_company_default + + if not ( + frappe.get_value("Company", ctx.company, "enable_provisional_accounting_for_non_stock_items") + and not item.is_stock_item + and ctx.qty + ): + expense_account = ( + get_company_default(ctx.company, "stock_received_but_not_billed") + if not frappe.in_test + else f'Stock Received But Not Billed - {frappe.get_value("Company", ctx.company, "abbr")}' + ) # Set the UOM to the Default Sales UOM or Default Purchase UOM if configured in the Item Master if not ctx.uom: