Fix some misleading corporation errors

This commit is contained in:
TheRealMaxion 2022-03-16 12:08:00 +01:00 committed by GitHub
parent e704843d91
commit 208af6ce9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -119,17 +119,17 @@ export function SellMaterial(mat: Material, amt: string, price: string): void {
try { try {
tempQty = eval(tempQty); tempQty = eval(tempQty);
} catch (e) { } catch (e) {
throw new Error("Invalid value or expression for sell price field: " + e); throw new Error("Invalid value or expression for sell quantity field: " + e);
} }
if (tempQty == null || isNaN(parseFloat(tempQty)) || parseFloat(tempQty) < 0) { if (tempQty == null || isNaN(parseFloat(tempQty)) || parseFloat(tempQty) < 0) {
throw new Error("Invalid value or expression for sell price field"); throw new Error("Invalid value or expression for sell quantity field");
} }
mat.sllman[0] = true; mat.sllman[0] = true;
mat.sllman[1] = q; //Use sanitized input mat.sllman[1] = q; //Use sanitized input
} else if (isNaN(parseFloat(amt)) || parseFloat(amt) < 0) { } else if (isNaN(parseFloat(amt)) || parseFloat(amt) < 0) {
throw new Error("Invalid value for sell quantity field! Must be numeric or 'MAX'"); throw new Error("Invalid value for sell quantity field! Must be numeric or 'PROD' or 'MAX'");
} else { } else {
let q = parseFloat(amt); let q = parseFloat(amt);
if (isNaN(q)) { if (isNaN(q)) {
@ -156,10 +156,10 @@ export function SellProduct(product: Product, city: string, amt: string, price:
try { try {
temp = eval(temp); temp = eval(temp);
} catch (e) { } catch (e) {
throw new Error("Invalid value or expression for sell quantity field: " + e); throw new Error("Invalid value or expression for sell price field: " + e);
} }
if (temp == null || isNaN(parseFloat(temp)) || parseFloat(temp) < 0) { if (temp == null || isNaN(parseFloat(temp)) || parseFloat(temp) < 0) {
throw new Error("Invalid value or expression for sell quantity field."); throw new Error("Invalid value or expression for sell price field.");
} }
product.sCost = price; //Use sanitized price product.sCost = price; //Use sanitized price
} else { } else {
@ -184,11 +184,11 @@ export function SellProduct(product: Product, city: string, amt: string, price:
try { try {
temp = eval(temp); temp = eval(temp);
} catch (e) { } catch (e) {
throw new Error("Invalid value or expression for sell price field: " + e); throw new Error("Invalid value or expression for sell quantity field: " + e);
} }
if (temp == null || isNaN(parseFloat(temp)) || parseFloat(temp) < 0) { if (temp == null || isNaN(parseFloat(temp)) || parseFloat(temp) < 0) {
throw new Error("Invalid value or expression for sell price field"); throw new Error("Invalid value or expression for sell quantity field");
} }
if (all) { if (all) {
for (let i = 0; i < cities.length; ++i) { for (let i = 0; i < cities.length; ++i) {
@ -201,7 +201,7 @@ export function SellProduct(product: Product, city: string, amt: string, price:
product.sllman[city][1] = qty; //Use sanitized input product.sllman[city][1] = qty; //Use sanitized input
} }
} else if (isNaN(parseFloat(amt)) || parseFloat(amt) < 0) { } else if (isNaN(parseFloat(amt)) || parseFloat(amt) < 0) {
throw new Error("Invalid value for sell quantity field! Must be numeric"); throw new Error("Invalid value for sell quantity field! Must be numeric or 'PROD' or 'MAX'");
} else { } else {
let qty = parseFloat(amt); let qty = parseFloat(amt);
if (isNaN(qty)) { if (isNaN(qty)) {