Merge pull request #34713 from s-aga-r/FIX-ISS-22-23-06369

fix: consider qty field precision
This commit is contained in:
Sagar Sharma 2023-04-03 15:36:19 +05:30 committed by GitHub
commit 5f2874743b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,12 +209,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,
)