mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-13 22:51:49 +00:00
fix: compare ordered qty to min order qty at stock_qty precision
stock_qty is stored as raw qty * conversion_factor, so a UOM-converted order for exactly the minimum (e.g. LB to Kg) produces values like 1999.999999131832 vs a min_order_qty of 2000 and blocks the Purchase Order. Round both sides to the stock_qty field precision before comparing, and show the rounded qty in the error message.
This commit is contained in:
@@ -310,12 +310,13 @@ class PurchaseOrder(BuyingController):
|
||||
itemwise_qty.setdefault(d.item_code, 0)
|
||||
itemwise_qty[d.item_code] += flt(d.stock_qty)
|
||||
|
||||
precision = self.items[0].precision("stock_qty")
|
||||
for item_code, qty in itemwise_qty.items():
|
||||
if flt(qty) < flt(itemwise_min_order_qty.get(item_code)):
|
||||
if flt(qty, precision) < flt(itemwise_min_order_qty.get(item_code), precision):
|
||||
frappe.throw(
|
||||
_(
|
||||
"Item {0}: Ordered qty {1} cannot be less than minimum order qty {2} (defined in Item)."
|
||||
).format(item_code, qty, itemwise_min_order_qty.get(item_code))
|
||||
).format(item_code, flt(qty, precision), itemwise_min_order_qty.get(item_code))
|
||||
)
|
||||
|
||||
def get_schedule_dates(self):
|
||||
|
||||
Reference in New Issue
Block a user