I am working on a function to add a product when I scan an unknown barcode. The issue I am encountering is that I cannot input decimal numbers for the price. For example if I enter 10.10 it is stored as 1010.00 in the SQL database. The problem lies in the number grouping in the region settings of the PC. Is there a solution to this problem without changing the region settings?
function addProduct(name, portion, category, price, barcode)
{
var response = gql.Exec(‘mutation m {addProduct(name: "’+name+‘", groupCode: "’+category+‘“,barcode:”’+barcode+‘", portions: [{name: "’+portion+‘", price: ‘+price+’}]) { id name groupCode }}’);
var result = JSON.parse(response);
if (!result || !result.data || !result.data.addProduct) return “ Fout: Product kon niet worden toegevoegd via GraphQL.”;
var ProductID = result.data.addProduct.id;
return “ Product '”+name+“’ met portie '”+portion+“’ en prijs “+price+” toegevoegd via GraphQL!”;
}
function addProduct(name, portion, category, price, barcode)
{
var response = gql.Exec('mutation m {addProduct(name: "'+name+'", groupCode: "'+category+'",barcode:"'+barcode+'", portions: [{name: "'+portion+'", price: 1}]) { id name groupCode }}');
var result = JSON.parse(response);
if (!result || !result.data || !result.data.addProduct) return ":x: Fout: Product kon niet worden toegevoegd via GraphQL.";
var ProductID = result.data.addProduct.id;
gql.Exec('mutation m{postResetProductCacheMessage {id}}');
var portionID = JSON.parse(gql.Exec('{getProduct(id:'+ProductID+'){portions{id}, tags{name,value} }}')).data.getProduct.portions[0].id;
sql.ExecSql("UPDATE MenuItemPrices SET Price = '"+price+"' WHERE MenuItemPortionId = "+portionID+"")
return ":white_check_mark: Product '"+name+"' met portie '"+portion+"' en prijs "+price+" toegevoegd via GraphQL!";
}