2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-04 04:30:56 +00:00

Fixes for "auto allocate" concept

This commit is contained in:
Oliver Walters
2020-10-29 00:49:01 +11:00
parent 551064b3a4
commit a263d2fdcd
6 changed files with 104 additions and 23 deletions

View File

@ -555,12 +555,23 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
qB *= buildInfo.quantity;
}
if (aA == 0 && aB == 0) {
// Handle the case where both numerators are zero
if ((aA == 0) && (aB == 0)) {
return (qA > qB) ? 1 : -1;
}
// Handle the case where either denominator is zero
if ((qA == 0) || (qB == 0)) {
return 1;
}
var progressA = parseFloat(aA) / qA;
var progressB = parseFloat(aB) / qB;
// Handle the case where both are at 100%
if (progressA == 1.0 && progressB == 1.0) {
return (qA < qB) ? 1 : -1;
}
return (progressA < progressB) ? 1 : -1;
}