Skip to content

Commit

Permalink
fix: consider qty field precision
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Apr 3, 2023
1 parent 7c42b72 commit 6ec7590
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions erpnext/utilities/transaction_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,15 @@ def validate_uom_is_integer(doc, uom_field, qty_fields, child_dt=None):
for f in qty_fields:
qty = d.get(f)
if qty:
if abs(cint(qty) - flt(qty)) > 0.0000001:
if abs(cint(qty) - flt(qty, d.precision(f))) > 0.0000001:
frappe.throw(
_(
"Row {1}: Quantity ({0}) cannot be a fraction. To allow this, disable '{2}' in UOM {3}."
).format(
qty, d.idx, frappe.bold(_("Must be Whole Number")), frappe.bold(d.get(uom_field))
flt(qty, d.precision(f)),
d.idx,
frappe.bold(_("Must be Whole Number")),
frappe.bold(d.get(uom_field)),
),
UOMMustBeIntegerError,
)

0 comments on commit 6ec7590

Please sign in to comment.