Updated supplies usage validation to allow for free supplies.

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD 2024-05-28 14:54:12 -06:00
parent c1ca63edc0
commit dde9688f96

View File

@ -110,7 +110,7 @@
var inStockQuantity = globalParseFloat(inStock.text()); var inStockQuantity = globalParseFloat(inStock.text());
var unitPrice = globalParseFloat(priceField.text()); var unitPrice = globalParseFloat(priceField.text());
//validation //validation
if (isNaN(requestedQuantity) || requestedQuantity > inStockQuantity) { if (isNaN(requestedQuantity) || requestedQuantity > inStockQuantity || requestedQuantity <= 0) {
textField.addClass("is-invalid"); textField.addClass("is-invalid");
hasError = true; hasError = true;
} else { } else {
@ -131,7 +131,7 @@
var parsedFloat = globalFloatToString(totalSum); var parsedFloat = globalFloatToString(totalSum);
$("#supplySumLabel").text(`Total: ${parsedFloat}`); $("#supplySumLabel").text(`Total: ${parsedFloat}`);
} }
$("#selectSuppliesButton").attr('disabled', (hasError || totalSum == 0)); $("#selectSuppliesButton").attr('disabled', (hasError || selectedSupplies.toArray().length == 0));
if (!hasError) { if (!hasError) {
return { return {
totalSum: globalFloatToString(totalSum), totalSum: globalFloatToString(totalSum),