Closed HKuz closed 10 months ago
@fproldan @agritheory - in testing my code changes for this issue, I made the following tweaks to the over-consumption validation code below. This checks that the doc's row qty is not larger than the qty in the HU, within "precision" decimal accuracy:
if doc.doctype == "Stock Entry":
# qty_field = "actual_qty" # Changed to transfer_qty EDIT: actual_qty is total qty available for item in given WH (checks source WH, if not defined uses target WH)
qty_field = "transfer_qty"
else:
qty_field = "stock_qty"
# [... other code in for loop]
# New error check:
precision = int(frappe.get_precision(row.doctype, qty_field))
if row.get(qty_field) - hu.stock_qty > 1 / (10**precision):
frappe.throw(
_(f"Row #{row.idx}: the Handling Unit for Item {row.item_code} has qty of {hu.stock_qty}.")
)
Here's the example in inventory_tools that checks for float equality (within "precision" decimal accuracy). In this case, the precision was 3, so the absolute difference can't be more than 0.001.
precision = int(frappe.get_precision("Purchase Order Item", "stock_qty"))
diff = abs(items_fg_qty - subc_fg_qty)
if diff > (1 / (10**precision)):
# ...
I'll add human-readable comment explanations in both areas.
This problem is in scope of the larger net quantity issue. We will want a test that addresses this case specifically to make sure there's no regression.
Resolved with #63
Creating Stock Entries of type
Material Transfer for Manufacture
(off a work order) and a plainMaterial Transfer
, the stock ledger entries didn't show the handling unit for any of the items moved. (Screen shot shows one example). Both stock entries moved quantities less than the full handling unit qty.Expected behavior: