Skip to content

Commit 9805745

Browse files
fix: shipping rule applied twice on non stock items (backport #53655) (#53687)
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com> fix: shipping rule applied twice on non stock items (#53655)
1 parent 5f9533f commit 9805745

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

erpnext/accounts/doctype/shipping_rule/shipping_rule.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ def add_shipping_rule_to_tax_table(self, doc, shipping_amount):
152152
frappe.throw(_("Shipping rule only applicable for Buying"))
153153

154154
shipping_charge["doctype"] = "Purchase Taxes and Charges"
155-
shipping_charge["category"] = "Valuation and Total"
155+
shipping_charge["category"] = (
156+
"Valuation and Total" if doc.get_stock_items() or doc.get_asset_items() else "Total"
157+
)
156158
shipping_charge["add_deduct_tax"] = "Add"
157159

158160
existing_shipping_charge = doc.get("taxes", filters=shipping_charge)

erpnext/controllers/accounts_controller.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,6 +2289,16 @@ def get_stock_items(self):
22892289

22902290
return stock_items
22912291

2292+
def get_asset_items(self):
2293+
asset_items = []
2294+
item_codes = list(set(item.item_code for item in self.get("items")))
2295+
if item_codes:
2296+
asset_items = frappe.db.get_values(
2297+
"Item", {"name": ["in", item_codes], "is_fixed_asset": 1}, pluck="name", cache=True
2298+
)
2299+
2300+
return asset_items
2301+
22922302
def calculate_total_advance_from_ledger(self):
22932303
adv = frappe.qb.DocType("Advance Payment Ledger Entry")
22942304
return (

0 commit comments

Comments
 (0)