diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py index d9b7b0a408f..3ec11364afa 100644 --- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py +++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py @@ -152,7 +152,9 @@ class ShippingRule(Document): frappe.throw(_("Shipping rule only applicable for Buying")) shipping_charge["doctype"] = "Purchase Taxes and Charges" - shipping_charge["category"] = "Valuation and Total" + shipping_charge["category"] = ( + "Valuation and Total" if doc.get_stock_items() or doc.get_asset_items() else "Total" + ) shipping_charge["add_deduct_tax"] = "Add" existing_shipping_charge = doc.get("taxes", filters=shipping_charge) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 43eaffa786b..24819c3ee19 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2289,6 +2289,16 @@ class AccountsController(TransactionBase): return stock_items + def get_asset_items(self): + asset_items = [] + item_codes = list(set(item.item_code for item in self.get("items"))) + if item_codes: + asset_items = frappe.db.get_values( + "Item", {"name": ["in", item_codes], "is_fixed_asset": 1}, pluck="name", cache=True + ) + + return asset_items + def calculate_total_advance_from_ledger(self): adv = frappe.qb.DocType("Advance Payment Ledger Entry") return (