From ce323d80ea4aadd1bbf56712450eccaae3e5e812 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 27 Mar 2022 20:29:59 +1100 Subject: [PATCH 1/2] Fix floating point issues --- InvenTree/templates/js/translated/build.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 46f7f32e42..fd88144f8b 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -1025,9 +1025,10 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { } // Store the required quantity in the row data - row.required = quantity; + // Prevent weird rounding issues + row.required = parseFloat(quantity.toFixed(15)); - return quantity; + return row.required; } function sumAllocations(row) { @@ -1043,9 +1044,9 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { quantity += item.quantity; }); - row.allocated = quantity; + row.allocated = parseFloat(quantity.toFixed(15)); - return quantity; + return row.allocated; } function setupCallbacks() { From 441a947dbb30786b1bd5d7b97e5fe261621aa091 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 27 Mar 2022 21:06:11 +1100 Subject: [PATCH 2/2] Fix another quantity --- InvenTree/templates/js/translated/build.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index fd88144f8b..201d3c5c9f 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -1643,6 +1643,9 @@ function allocateStockToBuild(build_id, part_id, bom_items, options={}) { remaining = 0; } + // Ensure the quantity sent to the form field is correctly formatted + remaining = parseFloat(remaining.toFixed(15)); + // We only care about entries which are not yet fully allocated if (remaining > 0) { table_entries += renderBomItemRow(bom_item, remaining);