mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 15:09:20 +00:00
fix: purchase receipt item showing wrong expense account (#51362)
This commit is contained in:
@@ -25,7 +25,6 @@ from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
|||||||
get_accounting_dimensions,
|
get_accounting_dimensions,
|
||||||
)
|
)
|
||||||
from erpnext.accounts.doctype.subscription_plan.subscription_plan import get_plan_rate
|
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):
|
class InvoiceCancelled(frappe.ValidationError):
|
||||||
|
|||||||
@@ -653,7 +653,7 @@ def reset_settings():
|
|||||||
|
|
||||||
def create_subscription(**kwargs):
|
def create_subscription(**kwargs):
|
||||||
subscription = frappe.new_doc("Subscription")
|
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.company = kwargs.get("company") or "_Test Company"
|
||||||
subscription.party = kwargs.get("party") or "_Test Customer"
|
subscription.party = kwargs.get("party") or "_Test Customer"
|
||||||
subscription.trial_period_start = kwargs.get("trial_period_start")
|
subscription.trial_period_start = kwargs.get("trial_period_start")
|
||||||
|
|||||||
@@ -748,6 +748,7 @@ def make_purchase_receipt(source_name, target_doc=None, args=None):
|
|||||||
"sales_order_item": "sales_order_item",
|
"sales_order_item": "sales_order_item",
|
||||||
"wip_composite_asset": "wip_composite_asset",
|
"wip_composite_asset": "wip_composite_asset",
|
||||||
},
|
},
|
||||||
|
"field_no_map": ["expense_account"],
|
||||||
"postprocess": update_item,
|
"postprocess": update_item,
|
||||||
"condition": lambda doc: (
|
"condition": lambda doc: (
|
||||||
True if is_unit_price_row(doc) else abs(doc.received_qty) < abs(doc.qty)
|
True if is_unit_price_row(doc) else abs(doc.received_qty) < abs(doc.qty)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
import json
|
import json
|
||||||
import unittest
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|||||||
@@ -755,7 +755,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
stock_asset_rbnb = (
|
stock_asset_rbnb = (
|
||||||
self.get_company_default("asset_received_but_not_billed")
|
self.get_company_default("asset_received_but_not_billed")
|
||||||
if d.is_fixed_asset
|
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()
|
landed_cost_entries = self.get_item_account_wise_lcv_entries()
|
||||||
if d.is_fixed_asset:
|
if d.is_fixed_asset:
|
||||||
@@ -809,7 +809,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
stock_asset_rbnb = (
|
stock_asset_rbnb = (
|
||||||
self.get_company_default("asset_received_but_not_billed")
|
self.get_company_default("asset_received_but_not_billed")
|
||||||
if d.is_fixed_asset
|
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)
|
stock_value_diff = get_stock_value_difference(self.name, d.name, d.rejected_warehouse)
|
||||||
|
|||||||
@@ -434,6 +434,19 @@ def get_basic_details(ctx: ItemDetailsCtx, item, overwrite_warehouse=True) -> It
|
|||||||
expense_account = get_asset_category_account(
|
expense_account = get_asset_category_account(
|
||||||
fieldname="fixed_asset_account", item=ctx.item_code, company=ctx.company
|
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
|
# Set the UOM to the Default Sales UOM or Default Purchase UOM if configured in the Item Master
|
||||||
if not ctx.uom:
|
if not ctx.uom:
|
||||||
|
|||||||
Reference in New Issue
Block a user