From 638c94451e987dee6a8097f70fa95d32150ed5fe Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:18:29 +0530 Subject: [PATCH] fix: get assets received but not billed account only if any asset item is received (backport #41734) (#41735) fix: get assets received but not billed account only if any asset item is received (#41734) fix: get assets received but not billed account only if any asset item received (cherry picked from commit 39885b2b010b25257ca82d41d316ca3b87c7dfca) Co-authored-by: Nabin Hait --- .../doctype/purchase_invoice/purchase_invoice.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 49ba9f459f2..afccc21c313 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -448,7 +448,7 @@ class PurchaseInvoice(BuyingController): stock_not_billed_account = self.get_company_default("stock_received_but_not_billed") stock_items = self.get_stock_items() - asset_received_but_not_billed = self.get_company_default("asset_received_but_not_billed") + self.asset_received_but_not_billed = None if self.update_stock: self.validate_item_code() @@ -534,18 +534,23 @@ class PurchaseInvoice(BuyingController): elif item.is_fixed_asset: account = None if item.pr_detail: + if not self.asset_received_but_not_billed: + self.asset_received_but_not_billed = self.get_company_default( + "asset_received_but_not_billed" + ) + # check if 'Asset Received But Not Billed' account is credited in Purchase receipt or not arbnb_booked_in_pr = frappe.db.get_value( "GL Entry", { "voucher_type": "Purchase Receipt", "voucher_no": item.purchase_receipt, - "account": asset_received_but_not_billed, + "account": self.asset_received_but_not_billed, }, "name", ) if arbnb_booked_in_pr: - account = asset_received_but_not_billed + account = self.asset_received_but_not_billed if not account: account_type = (