[minor] Set expense account as Stock RBNB for perpetual inventory after mapping
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 65f39aa..861ec8e 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -133,6 +133,14 @@
def set_missing_item_details(self):
"""set missing item values"""
from erpnext.stock.get_item_details import get_item_details
+
+ if self.doctype == "Purchase Invoice":
+ auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
+
+ if auto_accounting_for_stock:
+ stock_not_billed_account = self.get_company_default("stock_received_but_not_billed")
+
+ stock_items = self.get_stock_items()
if hasattr(self, "items"):
parent_dict = {}
@@ -170,6 +178,15 @@
if item.price_list_rate:
item.rate = flt(item.price_list_rate *
(1.0 - (flt(item.discount_percentage) / 100.0)), item.precision("rate"))
+
+ if self.doctype == "Purchase Invoice":
+ if auto_accounting_for_stock and item.item_code in stock_items \
+ and self.is_opening == 'No' \
+ and (not item.po_detail or not frappe.db.get_value("Purchase Order Item",
+ item.po_detail, "delivered_by_supplier")):
+
+ item.expense_account = stock_not_billed_account
+ item.cost_center = None
def set_taxes(self):
if not self.meta.get_field("taxes"):