Skip to content

Commit

Permalink
fix: precision issue while submitting the stock entry (#36575)
Browse files Browse the repository at this point in the history
fix: precision issue while submmiting the stock entry
  • Loading branch information
rohitwaghchaure authored Aug 10, 2023
1 parent 19cfcea commit a864e07
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions erpnext/stock/doctype/material_request/material_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,13 @@ def update_completed_qty(self, mr_items=None, update_modified=True):
mr_qty_allowance = frappe.db.get_single_value("Stock Settings", "mr_qty_allowance")

for d in self.get("items"):
precision = d.precision("ordered_qty")
if d.name in mr_items:
if self.material_request_type in ("Material Issue", "Material Transfer", "Customer Provided"):
d.ordered_qty = flt(mr_items_ordered_qty.get(d.name))

if mr_qty_allowance:
allowed_qty = flt((d.qty + (d.qty * (mr_qty_allowance / 100))), d.precision("ordered_qty"))
allowed_qty = flt((d.qty + (d.qty * (mr_qty_allowance / 100))), precision)

if d.ordered_qty and d.ordered_qty > allowed_qty:
frappe.throw(
Expand All @@ -237,11 +238,11 @@ def update_completed_qty(self, mr_items=None, update_modified=True):
).format(d.ordered_qty, d.parent, allowed_qty, d.item_code)
)

elif d.ordered_qty and d.ordered_qty > d.stock_qty:
elif d.ordered_qty and flt(d.ordered_qty, precision) > flt(d.stock_qty, precision):
frappe.throw(
_(
"The total Issue / Transfer quantity {0} in Material Request {1} cannot be greater than requested quantity {2} for Item {3}"
).format(d.ordered_qty, d.parent, d.qty, d.item_code)
).format(d.ordered_qty, d.parent, d.stock_qty, d.item_code)
)

elif self.material_request_type == "Manufacture":
Expand Down

0 comments on commit a864e07

Please sign in to comment.